xref: /OK3568_Linux_fs/app/forlinx/flapp/src/keyboard/keyboard/keyboard.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*! Keyboard 键盘根据输入部件焦点进入和离开显示键盘,键盘将现实到聚焦部件的最等曾的父窗口上.根据输入控件位置显示在最顶部和最底部.
2  * 用法:   在mainn函数加入定义即可 Keyboard k;
3   */
4 #ifndef KEYBOARD_H
5 #define KEYBOARD_H
6 #include <QWidget>
7 
8 class QLabel;
9 class KeyButton;
10 class PinyinBar;
11 class Keyboard : public QWidget
12 {
13     Q_OBJECT
14 public:
15     explicit Keyboard(QWidget *parent = 0);
16     ~Keyboard();
17 
18 protected:
19     void resizeWidget(QWidget*w);
20     bool hasInput(QWidget *w);
21     bool eventFilter(QObject *watched, QEvent *event)override;
22     void foucsChange(QWidget *old, QWidget *now);
23 
24     void createKeys();
25     void resetKey();
26     QString getKey(Qt::Key key);
27     void hideEvent(QHideEvent *event);
28 private slots:
29     void handleKey();
30     void clearpinyin();
31     void addSearch(const QString &s=QString());
32     void textChose(const QString &text, int index);
33 private:
34     QList<KeyButton*> m_buttons;
35     QWidget *m_inputWidget;
36     QStringList m_list;
37     PinyinBar *m_bar;
38     int m_candidates;
39     int m_number;
40     int m_type;
41     bool m_shift;
42     bool m_upper;
43 };
44 
45 #endif // KEYBOARD_H
46