2017-07-21 16:21:34 +00:00
|
|
|
/******************************************************************************
|
2024-01-17 13:31:45 +00:00
|
|
|
* QSkinny - Copyright (C) The authors
|
2023-04-06 07:23:37 +00:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2017-07-21 16:21:34 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-03-28 16:01:25 +00:00
|
|
|
#ifndef QSK_VIRTUAL_KEYBOARD_H
|
|
|
|
#define QSK_VIRTUAL_KEYBOARD_H
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-03-28 13:31:44 +00:00
|
|
|
#include "QskBox.h"
|
2023-03-06 07:49:53 +00:00
|
|
|
#include "QskPushButton.h"
|
|
|
|
|
|
|
|
class QSK_EXPORT QskVirtualKeyboardLayouts
|
|
|
|
{
|
2023-03-09 17:05:09 +00:00
|
|
|
public:
|
2023-03-06 07:49:53 +00:00
|
|
|
using Layout = QVector< QVector< QVector< int > > >;
|
|
|
|
|
|
|
|
Layout bg; // Bulgarian
|
|
|
|
Layout cs; // Czech
|
|
|
|
Layout de; // German
|
|
|
|
Layout da; // Danish
|
|
|
|
Layout el; // Greek
|
|
|
|
Layout en_GB; // English (GB)
|
|
|
|
Layout en_US; // English (US)
|
|
|
|
Layout es; // Spanish
|
|
|
|
Layout fi; // Finnish
|
|
|
|
Layout fr; // French
|
|
|
|
Layout hu; // Hungarian
|
|
|
|
Layout it; // Italian
|
|
|
|
Layout ja; // Japanese
|
|
|
|
Layout lv; // Latvian
|
|
|
|
Layout lt; // Lithuanian
|
|
|
|
Layout nl; // Dutch
|
|
|
|
Layout pt; // Portuguese
|
|
|
|
Layout ro; // Romanian
|
|
|
|
Layout ru; // Russian
|
|
|
|
Layout sl; // Slovene
|
|
|
|
Layout sk; // Slovak
|
|
|
|
Layout tr; // Turkish
|
|
|
|
Layout zh; // Chinese
|
|
|
|
};
|
2018-03-14 16:30:37 +00:00
|
|
|
|
2018-03-28 16:01:25 +00:00
|
|
|
class QSK_EXPORT QskVirtualKeyboard : public QskBox
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
2023-04-11 12:56:39 +00:00
|
|
|
Q_PROPERTY( Mode mode READ mode
|
|
|
|
WRITE setMode NOTIFY modeChanged FINAL )
|
|
|
|
|
2018-03-28 13:31:44 +00:00
|
|
|
using Inherited = QskBox;
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
public:
|
2018-04-06 15:30:24 +00:00
|
|
|
QSK_SUBCONTROLS( Panel, ButtonPanel, ButtonText )
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2024-12-09 15:03:55 +00:00
|
|
|
enum Mode : qint8
|
2017-07-21 16:21:34 +00:00
|
|
|
{
|
|
|
|
CurrentMode = -1,
|
2024-12-09 15:03:55 +00:00
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
LowercaseMode,
|
|
|
|
UppercaseMode,
|
|
|
|
SpecialCharacterMode,
|
2024-12-09 15:03:55 +00:00
|
|
|
|
2017-07-21 16:21:34 +00:00
|
|
|
ModeCount
|
|
|
|
};
|
|
|
|
Q_ENUM( Mode )
|
|
|
|
|
2024-12-09 15:03:55 +00:00
|
|
|
enum KeyType : quint8
|
2023-03-06 07:49:53 +00:00
|
|
|
{
|
|
|
|
NormalType,
|
|
|
|
EnterType,
|
|
|
|
BackspaceType,
|
|
|
|
CapsSwitchType,
|
|
|
|
ModeSwitchType,
|
|
|
|
SpecialCharacterType
|
|
|
|
};
|
|
|
|
|
2018-03-28 16:01:25 +00:00
|
|
|
QskVirtualKeyboard( QQuickItem* parent = nullptr );
|
2018-07-31 15:32:25 +00:00
|
|
|
~QskVirtualKeyboard() override;
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-04-06 15:30:24 +00:00
|
|
|
void setMode( Mode );
|
2017-07-21 16:21:34 +00:00
|
|
|
Mode mode() const;
|
|
|
|
|
2018-05-09 06:20:59 +00:00
|
|
|
void updateLocale( const QLocale& );
|
|
|
|
|
2018-06-03 09:01:22 +00:00
|
|
|
bool hasKey( int keyCode ) const;
|
|
|
|
|
2023-03-06 07:49:53 +00:00
|
|
|
int rowCount() const;
|
|
|
|
void setRowCount( int );
|
|
|
|
|
|
|
|
int columnCount() const;
|
|
|
|
void setColumnCount( int );
|
|
|
|
|
|
|
|
QskVirtualKeyboardLayouts layouts() const;
|
|
|
|
void setLayouts( const QskVirtualKeyboardLayouts& );
|
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
Q_SIGNALS:
|
2023-03-06 07:49:53 +00:00
|
|
|
void modeChanged( QskVirtualKeyboard::Mode );
|
|
|
|
void keyboardLayoutChanged();
|
2018-04-13 14:32:48 +00:00
|
|
|
void keySelected( int keyCode );
|
2018-03-28 16:01:25 +00:00
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
protected:
|
2023-03-06 07:49:53 +00:00
|
|
|
virtual qreal keyStretch( int ) const;
|
|
|
|
virtual bool isKeyVisible( int ) const;
|
|
|
|
virtual QString textForKey( int ) const;
|
|
|
|
virtual KeyType typeForKey( int ) const;
|
|
|
|
|
2018-07-31 15:32:25 +00:00
|
|
|
void updateLayout() override;
|
2019-09-10 15:01:47 +00:00
|
|
|
QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
2017-07-21 16:21:34 +00:00
|
|
|
|
2018-08-03 06:15:28 +00:00
|
|
|
private:
|
2023-03-06 07:49:53 +00:00
|
|
|
void ensureButtons();
|
2018-04-06 15:30:24 +00:00
|
|
|
void buttonPressed();
|
2023-06-01 06:58:04 +00:00
|
|
|
void buttonClicked();
|
|
|
|
|
2023-03-06 07:49:53 +00:00
|
|
|
void updateKeyCodes();
|
|
|
|
QskPushButton::Emphasis emphasisForType( KeyType );
|
|
|
|
|
|
|
|
qreal rowStretch( const QVector< int >& );
|
2017-07-21 16:21:34 +00:00
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|