File indexing completed on 2024-05-12 15:59:14

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2012 Arjen Hiemstra <ahiemstra@heimr.nl>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "SketchInputContext.h"
0008 #include "VirtualKeyboardController.h"
0009 
0010 #ifdef Q_OS_WIN
0011     #include <windows.h>
0012     #include <QProcess>
0013 #endif
0014 
0015 SketchInputContext::SketchInputContext(QObject* parent)
0016     : QInputContext(parent)
0017 {
0018 }
0019 
0020 SketchInputContext::~SketchInputContext()
0021 {
0022 
0023 }
0024 
0025 bool SketchInputContext::isComposing() const
0026 {
0027     return true;
0028 }
0029 
0030 void SketchInputContext::reset()
0031 {
0032 
0033 }
0034 
0035 QString SketchInputContext::language()
0036 {
0037     return QString("en_US");
0038 }
0039 
0040 QString SketchInputContext::identifierName()
0041 {
0042     return QString("SketchInputContext");
0043 }
0044 
0045 bool SketchInputContext::filterEvent(const QEvent* event)
0046 {
0047     if (event->type() == QEvent::RequestSoftwareInputPanel) {
0048         VirtualKeyboardController::instance()->requestShowKeyboard();
0049 #ifdef Q_OS_WIN
0050         QProcess::execute("cmd /c \"C:\\Program Files\\Common Files\\Microsoft Shared\\Ink\\Tabtip.exe\"");
0051 #endif
0052         return true;
0053     } else if (event->type() == QEvent::CloseSoftwareInputPanel) {
0054         VirtualKeyboardController::instance()->requestHideKeyboard();
0055 #ifdef Q_OS_WIN
0056         HWND kbd = ::FindWindow(L"IPTip_Main_Window", NULL);
0057         ::PostMessage(kbd, WM_SYSCOMMAND, SC_CLOSE, 0);
0058 #endif
0059         return true;
0060     }
0061     return false;
0062 }