MythTV  master
mythvirtualkeyboard.h
Go to the documentation of this file.
1 #ifndef MYTHUIVIRTUALKEYBOARD_H_
2 #define MYTHUIVIRTUALKEYBOARD_H_
3 
4 #include "mythscreentype.h"
5 
6 class QKeyEvent;
7 
9 enum PopupPosition : std::uint8_t
10 {
16 };
17 
19 {
20  QString name;
21  QString type;
22  QString normal, shift, alt, altshift;
23  QString up, down, left, right;
24 };
25 
26 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
27 class KeyEventDefinition
28 {
29  public:
30  int key() const { return keyCode; };
31  Qt::KeyboardModifiers keyboardModifiers() const { return modifiers; };
32 
33  int keyCode {0};
34  Qt::KeyboardModifiers modifiers;
35 };
36 #endif
37 
49 {
50  Q_OBJECT
51 
52  public:
53  MythUIVirtualKeyboard(MythScreenStack *parentStack, MythUITextEdit *m_parentEdit);
54  ~MythUIVirtualKeyboard() override = default;
55  bool Create(void) override; // MythScreenType
56  bool keyPressEvent(QKeyEvent *e) override; // MythScreenType
57 
58  signals:
59  void keyPressed(QString key);
60 
61  protected slots:
62  void charClicked(void);
63  void shiftClicked(void);
64  void delClicked(void);
65  void lockClicked(void);
66  void altClicked(void);
67  void compClicked(void);
68  void moveleftClicked(void);
69  void moverightClicked(void);
70  void backClicked(void);
71  void returnClicked(void);
72 
73  private:
74  void loadKeyDefinitions(const QString &lang);
75  void parseKey(const QDomElement &element);
76  void updateKeys(bool connectSignals = false);
77  static QString decodeChar(QString c);
78  QString getKeyText(const KeyDefinition& key) const;
79  static void loadEventKeyDefinitions(
80 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
81  KeyEventDefinition *keyDef,
82 #else
83  QKeyCombination *keyDef,
84 #endif
85  const QString &action);
86 
87  MythUITextEdit *m_parentEdit {nullptr};
89 
90  QMap<QString, KeyDefinition> m_keyMap;
91 
92  MythUIButton *m_lockButton {nullptr};
93  MythUIButton *m_altButton {nullptr};
94  MythUIButton *m_compButton {nullptr};
95  MythUIButton *m_shiftLButton {nullptr};
96  MythUIButton *m_shiftRButton {nullptr};
97 
98  bool m_shift {false};
99  bool m_alt {false};
100  bool m_lock {false};
101 
102  bool m_composing {false};
103  QString m_composeStr;
104 
105 #if QT_VERSION < QT_VERSION_CHECK(6,0,0)
106  KeyEventDefinition m_upKey;
107  KeyEventDefinition m_downKey;
108  KeyEventDefinition m_leftKey;
109  KeyEventDefinition m_rightKey;
110  KeyEventDefinition m_newlineKey;
111 #else
112  QKeyCombination m_upKey;
113  QKeyCombination m_downKey;
114  QKeyCombination m_leftKey;
115  QKeyCombination m_rightKey;
116  QKeyCombination m_newlineKey;
117 #endif
118 };
119 
120 #endif
KeyDefinition::alt
QString alt
Definition: mythvirtualkeyboard.h:22
KeyDefinition::shift
QString shift
Definition: mythvirtualkeyboard.h:22
MUI_PUBLIC
#define MUI_PUBLIC
Definition: mythuiexp.h:9
KeyDefinition::normal
QString normal
Definition: mythvirtualkeyboard.h:22
MythUIVirtualKeyboard::m_newlineKey
QKeyCombination m_newlineKey
Definition: mythvirtualkeyboard.h:116
MythScreenStack
Definition: mythscreenstack.h:16
MythScreenType::Create
virtual bool Create(void)
Definition: mythscreentype.cpp:263
KeyDefinition::right
QString right
Definition: mythvirtualkeyboard.h:23
VK_POSCENTERDIALOG
@ VK_POSCENTERDIALOG
Definition: mythvirtualkeyboard.h:15
KeyDefinition::altshift
QString altshift
Definition: mythvirtualkeyboard.h:22
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:34
KeyDefinition::down
QString down
Definition: mythvirtualkeyboard.h:23
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
VK_POSABOVEEDIT
@ VK_POSABOVEEDIT
Definition: mythvirtualkeyboard.h:11
VK_POSTOPDIALOG
@ VK_POSTOPDIALOG
Definition: mythvirtualkeyboard.h:13
KeyDefinition::name
QString name
Definition: mythvirtualkeyboard.h:20
MythUIVirtualKeyboard::m_downKey
QKeyCombination m_downKey
Definition: mythvirtualkeyboard.h:113
MythUIVirtualKeyboard::m_rightKey
QKeyCombination m_rightKey
Definition: mythvirtualkeyboard.h:115
MythUIVirtualKeyboard::m_leftKey
QKeyCombination m_leftKey
Definition: mythvirtualkeyboard.h:114
MythUIVirtualKeyboard::m_preferredPos
PopupPosition m_preferredPos
Definition: mythvirtualkeyboard.h:88
VK_POSBELOWEDIT
@ VK_POSBELOWEDIT
Definition: mythvirtualkeyboard.h:12
VK_POSBOTTOMDIALOG
@ VK_POSBOTTOMDIALOG
Definition: mythvirtualkeyboard.h:14
KeyDefinition::up
QString up
Definition: mythvirtualkeyboard.h:23
KeyDefinition::type
QString type
Definition: mythvirtualkeyboard.h:21
MythUIButton
A single button widget.
Definition: mythuibutton.h:21
KeyDefinition
Definition: mythvirtualkeyboard.h:18
MythUIVirtualKeyboard
A popup onscreen keyboard for easy alphanumeric and text entry using a remote control or mouse.
Definition: mythvirtualkeyboard.h:48
MythScreenType::keyPressEvent
bool keyPressEvent(QKeyEvent *event) override
Key event handler.
Definition: mythscreentype.cpp:401
MythUIVirtualKeyboard::m_composeStr
QString m_composeStr
Definition: mythvirtualkeyboard.h:103
PopupPosition
PopupPosition
Preferred position to place virtual keyboard popup.
Definition: mythvirtualkeyboard.h:9
build_compdb.action
action
Definition: build_compdb.py:9
MythUIVirtualKeyboard::m_upKey
QKeyCombination m_upKey
Definition: mythvirtualkeyboard.h:112
KeyDefinition::left
QString left
Definition: mythvirtualkeyboard.h:23
MythUIVirtualKeyboard::m_keyMap
QMap< QString, KeyDefinition > m_keyMap
Definition: mythvirtualkeyboard.h:90
mythscreentype.h