1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 or (at your option) any later version 20 ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 ** included in the packaging of this file. Please review the following 23 ** information to ensure the GNU General Public License requirements will 24 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 ** 26 ** $QT_END_LICENSE$ 27 ** 28 ****************************************************************************/ 29 30 #ifndef INPUTVIEW_H 31 #define INPUTVIEW_H 32 33 #include <QDialog> 34 #include <QPushButton> 35 #include <QLineEdit> 36 #include <QLabel> 37 #include <QVBoxLayout> 38 #include <QListWidget> 39 #include <inputengine.h> 40 #include <dwkeyboard_global.h> 41 #include <QColor> 42 43 namespace QtVirtualKeyboard { 44 45 class DWKEYBOARDSHARED_EXPORT KeyBoardData : public QObjectUserData{ 46 public: KeyBoardData()47 KeyBoardData(){ value = 0; } KeyBoardData(int v)48 KeyBoardData(int v){ value = v; } 49 public: 50 int value; 51 }; 52 53 class DWKEYBOARDSHARED_EXPORT InputDialogView : public QWidget 54 { 55 Q_OBJECT 56 public: 57 explicit InputDialogView(QObject* main, QWidget *parent = 0); 58 ~InputDialogView(); 59 public: 60 enum ViewMode 61 { 62 ViewABC = 0, 63 ViewNum0 = 1, 64 ViewNum1 = 2, 65 ViewMask = 3 66 }; 67 private: 68 void InitControl(); 69 void InitTextAndIcon(); 70 bool SwitchInputMode(InputEngine::InputMode mode); 71 void SwitchShiftMode(); 72 void DoQuitView(); 73 void UpdateWordCandidate(); // 显示候选字 74 void ResetShiftStyle(bool bshift, bool bcaplock, InputEngine::InputMode mode); // Shift状态恢复 75 QString GetShowText(int key, bool bshift, bool bcaplock, InputEngine::InputMode mode); 76 QString GetValueText(int key, bool bshift, bool bcaplock, InputEngine::InputMode mode); 77 void Layout(); 78 void ResetButtonStyle(); 79 public: 80 QList<QPushButton*> GetButtonList(int key); GetViewMode()81 InputDialogView::ViewMode GetViewMode(){ return m_ViewMode; } 82 void SwitchViewMode(InputDialogView::ViewMode mode); 83 private: 84 QWidget* m_backgroud; // 背景 85 QPushButton* m_btnLine1[11];// 第一行按钮组 86 QPushButton* m_btnLine2[10];// 第一行按钮组 87 QPushButton* m_btnLine3[11];// 第一行按钮组 88 QPushButton* m_btnLine4[6]; // 第一行按钮组 89 QList<QPushButton*> m_AllbtnList; // 全部按钮集合 90 QListWidget* m_ListWidget; // 提示器 91 InputDialogView::ViewMode m_ViewMode; 92 93 QColor m_backgroundClr; // 主窗体背景颜色 94 QColor m_btnbackgroundClr; // 按钮背景颜色 95 QColor m_btnHoverClr; // 按钮hover颜色 96 QColor m_btnPressedClr; // 按钮按下颜色 97 QColor m_btnTxtClr; // 按钮字体颜色 98 QColor m_btnTxtHoverClr; // 按钮字体Hover颜色 99 QColor m_btnTxtPressClr; // 按钮字体按下颜色 100 101 QColor m_HanziClr; // 汉字背景颜色 102 QColor m_HanziHoverClr; // 汉字hover颜色 103 QColor m_HanziPressedClr; // 汉字按下颜色 104 QColor m_HanziTxtClr; // 汉字字体颜色 105 QColor m_HanziPressTxtClr; // 汉字字体颜色 106 signals: 107 void sendKeyToFocusItem(const QString &keyText); 108 bool virtualKeyPress(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers, bool isAutoRepeat); 109 bool virtualKeyRelease(Qt::Key key, const QString &text, Qt::KeyboardModifiers modifiers); 110 public slots: 111 void press(); 112 void release(); 113 void OnListWidgetItemClick(QListWidgetItem * item); 114 signals: 115 void sizeChanged(); 116 protected: 117 void resizeEvent(QResizeEvent *event); 118 public: 119 QObject* main_object; 120 }; 121 122 } // namespace QtVirtualKeyboard 123 124 #endif // INPUTVIEW_H 125