QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskVirtualKeyboard.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_VIRTUAL_KEYBOARD_H
7#define QSK_VIRTUAL_KEYBOARD_H
8
9#include "QskBox.h"
10#include "QskPushButton.h"
11
13{
14 public:
15 using Layout = QVector< QVector< QVector< int > > >;
16
17 Layout bg; // Bulgarian
18 Layout cs; // Czech
19 Layout de; // German
20 Layout da; // Danish
21 Layout el; // Greek
22 Layout en_GB; // English (GB)
23 Layout en_US; // English (US)
24 Layout es; // Spanish
25 Layout fi; // Finnish
26 Layout fr; // French
27 Layout hu; // Hungarian
28 Layout it; // Italian
29 Layout ja; // Japanese
30 Layout lv; // Latvian
31 Layout lt; // Lithuanian
32 Layout nl; // Dutch
33 Layout pt; // Portuguese
34 Layout ro; // Romanian
35 Layout ru; // Russian
36 Layout sl; // Slovene
37 Layout sk; // Slovak
38 Layout tr; // Turkish
39 Layout zh; // Chinese
40};
41
42class QSK_EXPORT QskVirtualKeyboard : public QskBox
43{
44 Q_OBJECT
45
46 Q_PROPERTY( Mode mode READ mode
47 WRITE setMode NOTIFY modeChanged FINAL )
48
49 using Inherited = QskBox;
50
51 public:
52 QSK_SUBCONTROLS( Panel, ButtonPanel, ButtonText )
53
54 enum Mode : qint8
55 {
56 CurrentMode = -1,
57
58 LowercaseMode,
59 UppercaseMode,
60 SpecialCharacterMode,
61
62 ModeCount
63 };
64 Q_ENUM( Mode )
65
66 enum KeyType : quint8
67 {
68 NormalType,
69 EnterType,
70 BackspaceType,
71 CapsSwitchType,
72 ModeSwitchType,
73 SpecialCharacterType
74 };
75
76 QskVirtualKeyboard( QQuickItem* parent = nullptr );
77 ~QskVirtualKeyboard() override;
78
79 void setMode( Mode );
80 Mode mode() const;
81
82 void updateLocale( const QLocale& );
83
84 bool hasKey( int keyCode ) const;
85
86 int rowCount() const;
87 void setRowCount( int );
88
89 int columnCount() const;
90 void setColumnCount( int );
91
92 QskVirtualKeyboardLayouts layouts() const;
93 void setLayouts( const QskVirtualKeyboardLayouts& );
94
95 Q_SIGNALS:
96 void modeChanged( QskVirtualKeyboard::Mode );
97 void keyboardLayoutChanged();
98 void keySelected( int keyCode );
99
100 protected:
101 virtual qreal keyStretch( int ) const;
102 virtual bool isKeyVisible( int ) const;
103 virtual QString textForKey( int ) const;
104 virtual KeyType typeForKey( int ) const;
105
106 void updateLayout() override;
107 QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
108
109 private:
110 void ensureButtons();
111 void buttonPressed();
112 void updateKeyCodes();
113 QskPushButton::Emphasis emphasisForType( KeyType );
114
115 qreal rowStretch( const QVector< int >& );
116
117 class PrivateData;
118 std::unique_ptr< PrivateData > m_data;
119};
120
121#endif