86 lines
1.8 KiB
C++
86 lines
1.8 KiB
C++
#ifndef KEYBOARD_H
|
|
#define KEYBOARD_H
|
|
|
|
#include <QWidget>
|
|
#include <QPushButton>
|
|
#include <QDialog>
|
|
#include <QLabel>
|
|
|
|
//chinese support
|
|
#include <QFile>
|
|
#include <QMultiMap>
|
|
#include <QLineEdit>
|
|
#include <QMutex>
|
|
|
|
class keyboard : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
typedef enum
|
|
{
|
|
enKeyboardNotGen,
|
|
enKeyboardCreating,
|
|
enKeyboardCreated
|
|
}enKeyboardStatus;
|
|
|
|
static const int KEYS_QUANTITY_MAX = 60;
|
|
static const int SPACE = 5;
|
|
static const int ROW_NUM = 6;
|
|
|
|
static keyboard* GetInstance(QWidget *parent);
|
|
static void preLoad();
|
|
static void close();
|
|
|
|
~keyboard();
|
|
void popup(const int posToBottom = 0);
|
|
|
|
signals:
|
|
void signalWordChoose(QString word);
|
|
|
|
public slots:
|
|
void slotBtnClicked();
|
|
void slotBtnPressed();
|
|
void slotBtnReleased();
|
|
void slotPageTurnBtnClicked();
|
|
void slotCandidateBtnClicked();
|
|
void slotClose();
|
|
void slotTimer();
|
|
|
|
private:
|
|
static keyboard* m_instance;
|
|
QObject* m_receiver;
|
|
static enKeyboardStatus m_status;
|
|
|
|
QPushButton* m_btn[KEYS_QUANTITY_MAX];
|
|
//chinese support
|
|
QVector<QPushButton*> m_btnsCnCdd;
|
|
QLineEdit* m_editCn;
|
|
QPushButton* m_btnCnPrePage;
|
|
QPushButton* m_btnCnNextPage;
|
|
|
|
static QFile* m_pinyinFile;
|
|
static QRegExp* m_regExp;
|
|
static QMultiMap<QString, QString>* m_pinyinMap;
|
|
|
|
bool isInputMethodCn;
|
|
int m_iCddPageIndex;
|
|
QList<QString> m_pinyinList;
|
|
|
|
QLabel* m_labelTip;
|
|
QTimer* m_timer;
|
|
QPushButton* m_curPressedKey;
|
|
|
|
explicit keyboard(QWidget *parent = nullptr);
|
|
void setInputMethodCn(bool setCn);
|
|
void matching(const QString& userInput);
|
|
void changePage(int index);
|
|
void setReceiver(QObject*);
|
|
QObject* receiver() const;
|
|
|
|
void shiftkeyboard(int caps);
|
|
void paintEvent(QPaintEvent *event);
|
|
void keyPress(const QPushButton* btn);
|
|
};
|
|
|
|
#endif // KEYBOARD_H
|