#include <QDebug>
#include "inputmethod.h"
#include "ui_inputmethod.h"
#include "quidelegate.h"
static char *szInputText[] = {"0", "1", "2", "3", "4", "5","6","7", "8", "9", //纯数字输入法
"0", "1", "2", "3", "4", "5","6","7", "8", "9", //数字输入法
" ", "@", "abc", "def","ghi","jkl","mno","pqrs","tuv","wxyz", //小写字母输入
" ", "@", "ABC", "DEF","GHI", "JKL", "MNO", "PQRS", "TUV", "WXYZ", //大写字母输入
"~","@", ":", "/", "-","_", "*", "%", "^", "#"}; //符号输入
void InputMethod::createWindow()
{
QVBoxLayout *Vlayout1 = new QVBoxLayout;
QVBoxLayout *Vlayout2 = new QVBoxLayout;
QVBoxLayout *Vlayout3 = new QVBoxLayout;
QVBoxLayout *Vlayout4 = new QVBoxLayout;
QHBoxLayout *HButtonLayout = new QHBoxLayout;
QVBoxLayout *VMainLayout = new QVBoxLayout;
Vlayout1->addWidget(ui->m_PushButton1);
Vlayout1->setSpacing(8);
Vlayout1->addWidget(ui->m_PushButton4);
Vlayout1->setSpacing(8);
Vlayout1->addWidget(ui->m_PushButton7);
Vlayout1->setSpacing(8);
Vlayout1->addWidget(ui->m_PushButtonDian);
Vlayout1->setSpacing(8);
Vlayout2->addWidget(ui->m_PushButton2);
Vlayout2->setSpacing(8);
Vlayout2->addWidget(ui->m_PushButton5);
Vlayout2->setSpacing(8);
Vlayout2->addWidget(ui->m_PushButton8);
Vlayout2->setSpacing(8);
Vlayout2->addWidget(ui->m_PushButton0);
Vlayout2->setSpacing(8);
Vlayout3->addWidget(ui->m_PushButton3);
Vlayout3->setSpacing(8);
Vlayout3->addWidget(ui->m_PushButton6);
Vlayout3->setSpacing(8);
Vlayout3->addWidget(ui->m_PushButton9);
Vlayout3->setSpacing(8);
Vlayout3->addWidget(ui->m_PushButtonDel);
Vlayout3->setSpacing(8);
Vlayout4->addWidget(ui->m_PushButtonChange);
Vlayout4->setSpacing(8);
Vlayout4->addWidget(ui->m_PushButtonA);
Vlayout4->setSpacing(8);
Vlayout4->addWidget(ui->m_PushButtonOK);
Vlayout4->setSpacing(8);
HButtonLayout->addLayout(Vlayout1);
HButtonLayout->setSpacing(8);
HButtonLayout->addLayout(Vlayout2);
HButtonLayout->setSpacing(8);
HButtonLayout->addLayout(Vlayout3);
HButtonLayout->setSpacing(8);
HButtonLayout->addLayout(Vlayout4);
HButtonLayout->setSpacing(8);
// HTextLayout->addWidget(ui->m_TextEdit);
VMainLayout->addWidget(ui->m_InputTitle, 0, Qt::AlignLeading|Qt::AlignVCenter);
VMainLayout->setSpacing(0);
VMainLayout->setMargin(0);
VMainLayout->addLayout(HButtonLayout);
// ui->m_TextEdit->setMaximumHeight(50);
// ui->m_TextEdit->hide();
VMainLayout->setContentsMargins(8,0,8,4);
this->setLayout(VMainLayout);
mp_ButGroup = new QButtonGroup(this);
mp_ButGroup->setObjectName(QString::fromAscii("ButtonGroup"));
mp_ButGroup->addButton(ui->m_PushButton0, 0);
mp_ButGroup->addButton(ui->m_PushButton1, 1);
mp_ButGroup->addButton(ui->m_PushButton2, 2);
mp_ButGroup->addButton(ui->m_PushButton3, 3);
mp_ButGroup->addButton(ui->m_PushButton4, 4);
mp_ButGroup->addButton(ui->m_PushButton5, 5);
mp_ButGroup->addButton(ui->m_PushButton6, 6);
mp_ButGroup->addButton(ui->m_PushButton7, 7);
mp_ButGroup->addButton(ui->m_PushButton8, 8);
mp_ButGroup->addButton(ui->m_PushButton9, 9);
mp_ButGroup->addButton(ui->m_PushButtonDian, 10);
mp_ButGroup->addButton(ui->m_PushButtonDel, 11);
mp_ButGroup->addButton(ui->m_PushButtonChange, 12);
mp_ButGroup->addButton(ui->m_PushButtonA, 13);
mp_ButGroup->addButton(ui->m_PushButtonOK, 14);
}
InputMethod::InputMethod(E_INPUT_TYPE nInput, QWidget *parent) :
QWidget(parent),
ui(new Ui::InputMethod)
{
setWindowFlags(Qt::FramelessWindowHint);
ui->setupUi(this);
s_TimeId = 0;
s_nKeyCount = 0;
s_nKeyType = -1;
s_nMinLimit = LIMITINPUT_DISABLE;
s_nMaxLimit = LIMITINPUT_DISABLE;
m_Timer = new QTimer(this);
s_InputText.clear();
createWindow();
if(nInput == INPUT_ONLYNUM)
{
setInputOnlyNum();
Init_InputValue(INPUT_ONLYNUM);
}
else
{
setInputAll();
if(nInput == INPUT_EN)
{
Init_InputEN();
}
else if(nInput == INPUT_ENA)
Init_InputENA();
else if(nInput == INPUT_SYMBOL)
Init_InputSymbol();
else
Init_InputValue(INPUT_NUM);
}
setImSupport(nInput);
connect(mp_ButGroup, SIGNAL(buttonClicked(int)), this, SLOT(on_mp_ButGroup_Clicked(int)));
connect(m_Timer, SIGNAL(timeout()), this, SLOT(on_mp_TimeOut_Clicket()));
connect(ui->m_hideLabel, SIGNAL(clicked()), this, SLOT(on_click_hidebutton()));
}
InputMethod::~InputMethod()
{
delete ui;
}
void InputMethod::inputText(QString text)
{
s_InputText.append(text);
emit textChanged();
}
void InputMethod::clearEndOne()
{
s_InputText.remove((s_InputText.size() -1), 1);
emit textChanged();
}
void InputMethod::on_click_hidebutton()
{
this->hide();
emit hideinput();
}
void InputMethod::setInputOnlyNum()
{
QFont font("Arial", 52);
ui->m_PushButton0->setMinimumSize(QSize(150, 70));
ui->m_PushButton0->setMaximumSize(QSize(150, 70));
ui->m_PushButton0->setFont(font);
ui->m_PushButton1->setMinimumSize(QSize(150, 70));
ui->m_PushButton1->setMaximumSize(QSize(150, 70));
ui->m_PushButton1->setFont(font);
ui->m_PushButton2->setMinimumSize(QSize(150, 70));
ui->m_PushButton2->setMaximumSize(QSize(150, 70));
ui->m_PushButton2->setFont(font);
ui->m_PushButton3->setMinimumSize(QSize(150, 70));
ui->m_PushButton3->setMaximumSize(QSize(150, 70));
ui->m_PushButton3->setFont(font);
ui->m_PushButton4->setMinimumSize(QSize(150, 70));
ui->m_PushButton4->setMaximumSize(QSize(150, 70));
ui->m_PushButton4->setFont(font);
ui->m_PushButton5->setMinimumSize(QSize(150, 70));
ui->m_PushButton5->setMaximumSize(QSize(150, 70));
ui->m_PushButton5->setFont(font);
ui->m_PushButton6->setMinimumSize(QSize(150, 70));
ui->m_PushButton6->setMaximumSize(QSize(150, 70));
ui->m_PushButton6->setFont(font);
ui->m_PushButton7->setMinimumSize(QSize(150, 70));
ui->m_PushButton7->setMaximumSize(QSize(150, 70));
ui->m_PushButton7->setFont(font);
ui->m_PushButton8->setMinimumSize(QSize(150, 70));
ui->m_PushButton8->setMaximumSize(QSize(150, 70));
ui->m_PushButton8->setFont(font);
ui->m_PushButton9->setMinimumSize(QSize(150, 70));
ui->m_PushButton9->setMaximumSize(QSize(150, 70));
ui->m_PushButton9->setFont(font);
ui->m_PushButtonDel->setMinimumSize(QSize(150, 70));
ui->m_PushButtonDel->setMaximumSize(QSize(150, 70));
ui->m_PushButtonDel->setFont(font);
ui->m_PushButtonDian->setMinimumSize(QSize(150, 70));
ui->m_PushButtonDian->setMaximumSize(QSize(150, 70));
ui->m_PushButtonDian->setFont(font);
ui->m_PushButtonChange->setMinimumSize(QSize(110, 70));
ui->m_PushButtonChange->setMaximumSize(QSize(110, 70));
ui->m_PushButtonA->setMinimumSize(QSize(110, 70));
ui->m_PushButtonA->setMaximumSize(QSize(110, 70));
ui->m_PushButtonOK->setMinimumSize(QSize(110, 148));
ui->m_PushButtonOK->setMaximumSize(QSize(110, 148));
ui->m_PushButtonChange->hide();
ui->m_PushButtonA->hide();
ui->m_PushButtonOK->hide();
}
void InputMethod::setInputAll()
{
QFont font("Arial", 32);
ui->m_PushButton0->setMinimumSize(QSize(110, 70));
ui->m_PushButton0->setMaximumSize(QSize(110, 70));
ui->m_PushButton0->setFont(font);
ui->m_PushButton1->setMinimumSize(QSize(110, 70));
ui->m_PushButton1->setMaxi
yyj890828
- 粉丝: 0
- 资源: 1
最新资源
- YOLO-yolo资源
- 适用于 Java 项目的 Squash 客户端库 .zip
- 适用于 Java 的 Chef 食谱.zip
- Simulink仿真快速入门与实践基础教程
- js-leetcode题解之179-largest-number.js
- js-leetcode题解之174-dungeon-game.js
- Matlab工具箱使用与实践基础教程
- js-leetcode题解之173-binary-search-tree-iterator.js
- js-leetcode题解之172-factorial-trailing-zeroes.js
- js-leetcode题解之171-excel-sheet-column-number.js
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈