代码拉取完成,页面将自动刷新
/***************************************************************************
**
** <SYSZUXpinyin 1.0 , a chinese input method based on Qt for Embedded linux>
** Copyright (C) <2010> <Gemfield> <gemfield@civilnet.cn>
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License version 3 as published
** by the Free Software Foundation.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**
** If you have questions regarding the use of this file, please contact
** Gemfield at gemfield@civilnet.cn or post your questions at
** http://civilnet.cn/syszux/bbs
**
****************************************************************************/
#include "syszuxim.h"
#include "syszuxpinyin.h"
SyszuxIM::SyszuxIM()
{
syszuxpinyin = new SyszuxPinyin(this);
le = new QLineEdit; //added by me
sb = new QSpinBox;
dsb = new QDoubleSpinBox;
tee = new QTextEdit;
cb = new QComboBox;
tie = new QTimeEdit;
de = new QDateEdit;
dte = new QDateTimeEdit;
current_focus_widget=new QWidget;
current_focus_widget = QApplication::focusWidget();
syszuxpinyin->resize(800,480);
}
SyszuxIM::~SyszuxIM()
{
syszuxpinyin->deleteLater();
}
void SyszuxIM::confirmString(QString gemfield)
{
if(type == LINEEDIT)
{
le->setText(gemfield);
le->clearFocus();
}
else if(type == SPINBOX)
{
sb->setValue(gemfield.toInt());
sb->clearFocus();
}
else if(type == DOUBLESPINBOX)
{
dsb->setValue(gemfield.toFloat());
dsb->clearFocus();
}
else if(type == TEXTEDIT)
{
tee->setText(gemfield);
tee->clearFocus();
}
else if(type == COMBOBOX)
{
if(gemfield.isEmpty())
{
sendCommitString(gemfield);
cb->clearFocus();
}
}
else
{
sendCommitString(gemfield);
}
}
void SyszuxIM::onReturnConcel()
{
if(type == LINEEDIT)
{
le->clearFocus();
}
else if(type == SPINBOX)
{
sb->clearFocus();
}
else if(type == DOUBLESPINBOX)
{
dsb->clearFocus();
}
else if(type == TEXTEDIT)
{
tee->clearFocus();
}
else if(type == COMBOBOX)
{
cb->clearFocus();
}
}
void SyszuxIM::updateHandler(int type)
{
switch(type)
{
case QWSInputMethod::FocusIn:
//syszuxpinyin->show();
focusin();
break;
case QWSInputMethod::FocusOut:
syszuxpinyin->hide();
break;
default:
break;
}
}
void SyszuxIM::focusin()
{
QString str;
current_focus_widget = QApplication::focusWidget();
if(qobject_cast<QLineEdit*>(current_focus_widget))
{
type = LINEEDIT;
le= qobject_cast<QLineEdit*>(current_focus_widget);
str = le->text();
}
else if(qobject_cast<QSpinBox*>(current_focus_widget))
{
type = SPINBOX;
sb = qobject_cast<QSpinBox*>(current_focus_widget);
str = tr("%1").arg(sb->value());
}
else if(qobject_cast<QDoubleSpinBox*>(current_focus_widget))
{
type = DOUBLESPINBOX;
dsb = qobject_cast<QDoubleSpinBox*>(current_focus_widget);
str = tr("%1").arg(dsb->value());
}
else if(qobject_cast<QTextEdit*>(current_focus_widget))
{
type = TEXTEDIT;
tee = qobject_cast<QTextEdit*>(current_focus_widget);
str = tee->toPlainText();
}
else if(qobject_cast<QComboBox*>(current_focus_widget))
{
type = COMBOBOX;
cb = qobject_cast<QComboBox*>(current_focus_widget);
str = cb->currentText();
str = "";
}
else
str = "";
syszuxpinyin->show();
syszuxpinyin->lineEdit_window->setText(str);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。