162 lines
4.7 KiB
C++
162 lines
4.7 KiB
C++
#ifndef INPUTMETHOD_H
|
|
#define INPUTMETHOD_H
|
|
|
|
#include <QWidget>
|
|
#include <QHash>
|
|
#include <QMap>
|
|
#include <QList>
|
|
#include <QLabel>
|
|
#include <QTextEdit>
|
|
#include <ClickLabel.h>
|
|
#include <QStringList>
|
|
#include <QTimer>
|
|
#include "InsertSpaceNumDialog.h"
|
|
#include "myinclude.h"
|
|
class MyInputMethod;
|
|
|
|
|
|
namespace Ui {
|
|
class InputMethod;
|
|
}
|
|
|
|
#define HANZI_SELECT_NUM 5 //显示汉字的个数,由UI文件决定
|
|
#define INPUT_METHOD_TYPE_ENGLISH 0
|
|
#define INPUT_METHOD_TYPE_CHINESE 1
|
|
#define INPUT_METHOD_TYPE_VIETNAM 2
|
|
#define INPUT_METHOD_TYPE_RUSSIAN 3 // Russian
|
|
#define INPUT_METHOD_TYPE_JAPANESE 4 //Japanese
|
|
#define INPUT_METHOD_TYPE_KOREAN 5 // Korean
|
|
#define INPUT_METHOD_TYPE_SPANISH 6 // Korean
|
|
#define INPUT_METHOD_TYPE_THAI 7 // Thai
|
|
#define INPUT_METHOD_TYPE_Farsi 8
|
|
#define INPUT_FILE_CHINESE "WINPY_utf8.txt"
|
|
#define INPUT_FILE_ENGLISH "WINPY_utf8.txt"
|
|
#define INPUT_FILE_VIETNAM "YN_utf8.txt"
|
|
#define INPUT_FILE_RUSSIAN "WINPY_utf8.txt"
|
|
#define INPUT_FILE_JAPANESE "WINPY_utf8.txt"
|
|
#define INPUT_FILE_KOREAN "WINPY_utf8.txt"
|
|
|
|
#define MIN(a,b) (((a) < (b))?(a):(b))
|
|
#define MAX(a,b) (((a) > (b))?(a):(b))
|
|
|
|
class InputMethod : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit InputMethod(MyInputMethod *myInputMethod,QWidget *parent = 0);
|
|
static bool initInputMethod(QString &filename); /*用文件初始化输入法的字库*/
|
|
static void showPinyinHash(void);
|
|
~InputMethod();
|
|
void switchKeyBoardBengalDisply(bool);
|
|
void switchKeyBoardBengalLowerLetters();
|
|
void switchKeyBoardBengalCapitalLetters();
|
|
void switchKeyBoardBengalDigit();
|
|
#ifdef EnableArabic
|
|
void setArabicDisplay(bool);
|
|
void showArabicPage1Key();
|
|
void showArabicPage2Key();
|
|
void showEnglishKey();
|
|
void showArabicPage3Key();
|
|
void setSwitchArabicFlag(bool flag);
|
|
#endif
|
|
public slots:
|
|
void onpushButtonCapspressed();
|
|
void onDigitalPunctuationClicked();
|
|
void onCharClicked();
|
|
void onShiftClicked();
|
|
void onInputMethodClicked();
|
|
void onBackspaceClicked();
|
|
void onHanziLabelClicked();
|
|
void onKeyLastClicked();
|
|
void onKeyNextClicked();
|
|
void onEnterClicked();
|
|
|
|
void userInputed(QString str); //用户输入一个字符
|
|
void onHiden();
|
|
void on_Key_Backspace_released();
|
|
private slots:
|
|
|
|
|
|
void onKeyLeftpressed();
|
|
|
|
void onKeyDownpressed();
|
|
|
|
void onKeyUppressed();
|
|
|
|
void onKeyRightpressed();
|
|
|
|
void onKeyHomepressed();
|
|
|
|
void onKeyEndpressed();
|
|
|
|
void onKeydeletepressed();
|
|
|
|
void onKeySpecialCharpressed();
|
|
void onKeyCtrlpressed();
|
|
void onKeyReleased();
|
|
void onKeyPressed();
|
|
|
|
void spaceKeyPressed();
|
|
void spaceKeyRelease();
|
|
void spaceKeyLongPressed();
|
|
void backKeyLongPressed();
|
|
void onInsertSpaceNumDialogAccepted();
|
|
|
|
void on_pushBottonHide_pressed();
|
|
|
|
void on_Key_Backspace_pressed();
|
|
|
|
//void on_Key_Backspace_released();
|
|
|
|
private:
|
|
|
|
MyInputMethod *myInputMethod;
|
|
QMap<QString,QString> keyMap;
|
|
|
|
Ui::InputMethod *ui;
|
|
|
|
static QHash<QString,QList<QString> *> *pinyinHash; //用来存放哈拼音的哈希表,所有都共用一份
|
|
static QList <QString> pinyinHashKeys;
|
|
static QStringList pinyinHashQStringList;
|
|
|
|
QList <QString> *currPinyinList;
|
|
|
|
QStringList currPinyins; //自动侯选的拼音
|
|
|
|
ClickLabel *hanziDisplayLabels[HANZI_SELECT_NUM];
|
|
int currentInputMethodType;
|
|
int matchStartIndex;
|
|
int matchEndIndex;
|
|
int bNotFound;
|
|
bool shiftFlag; //是否按过shift键
|
|
bool CapsFlag;
|
|
bool userPinyinInputAppending; //是否用户已经在拼音输入法下完成输入
|
|
QString currPinyinStr; //记录当前用户已经输入的字符
|
|
int pinyinPage; /*当一个拼音有很多汉字时,分多页存放,记录当前的页数*/
|
|
int back_count_timeout; //回退键超时处理
|
|
bool bengalFlag;
|
|
bool CtrlFlag;
|
|
#ifdef EnableArabic
|
|
bool arabicFlag;
|
|
bool englishOrArabicFlag;
|
|
#endif
|
|
void switchKeyboardDisplay(void); //当按shift,输入法时,切换键盘显示
|
|
void displayHanziToLabel(); //显示汉字到label
|
|
void fillPinyinLabel(bool bActFromCharInput);
|
|
void asciiTyped(int ascii);
|
|
void digitalTyped(int ascii);
|
|
void buttonConnect(QPushButton *sender,
|
|
const QObject *receiver, const char *member);
|
|
void setHanziLabelVisible(bool enable);
|
|
QLabel labelInputTip; //输入提示
|
|
QTimer spaceTimer;
|
|
QTimer backtimer;
|
|
InsertSpaceNumDialog insertSpaceNumDialog;
|
|
bool hanZiLabelVisibleEnable;
|
|
bool ctrlAppending;//Ctrl+C ..之类的
|
|
QString specialKeyMap(QString ch);
|
|
};
|
|
|
|
#endif // INPUTMETHOD_H
|