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
55 {
56 CurrentMode = -1,
57 LowercaseMode,
58 UppercaseMode,
59 SpecialCharacterMode,
60 ModeCount
61 };
62 Q_ENUM( Mode )
63
64 enum KeyType
65 {
66 NormalType,
67 EnterType,
68 BackspaceType,
69 CapsSwitchType,
70 ModeSwitchType,
71 SpecialCharacterType
72 };
73
74 QskVirtualKeyboard( QQuickItem* parent = nullptr );
75 ~QskVirtualKeyboard() override;
76
77 void setMode( Mode );
78 Mode mode() const;
79
80 void updateLocale( const QLocale& );
81
82 bool hasKey( int keyCode ) const;
83
84 int rowCount() const;
85 void setRowCount( int );
86
87 int columnCount() const;
88 void setColumnCount( int );
89
90 QskVirtualKeyboardLayouts layouts() const;
91 void setLayouts( const QskVirtualKeyboardLayouts& );
92
93 Q_SIGNALS:
94 void modeChanged( QskVirtualKeyboard::Mode );
95 void keyboardLayoutChanged();
96 void keySelected( int keyCode );
97
98 protected:
99 virtual qreal keyStretch( int ) const;
100 virtual bool isKeyVisible( int ) const;
101 virtual QString textForKey( int ) const;
102 virtual KeyType typeForKey( int ) const;
103
104 void updateLayout() override;
105 QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
106
107 private:
108 void ensureButtons();
109 void buttonPressed();
110 void updateKeyCodes();
111 QskPushButton::Emphasis emphasisForType( KeyType );
112
113 qreal rowStretch( const QVector< int >& );
114
115 class PrivateData;
116 std::unique_ptr< PrivateData > m_data;
117};
118
119#endif