From d8de0d5878fad3f447a79bc91f2bf386169510a3 Mon Sep 17 00:00:00 2001 From: Krad Date: Thu, 21 Oct 2021 10:03:02 +0800 Subject: [PATCH] Some change with input object --- src/InputObject.cpp | 60 ++++++++++++++++-------------------- src/InputObject.h | 3 ++ src/device/DeviceManager.cpp | 1 + 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/InputObject.cpp b/src/InputObject.cpp index 6a44df1..754bef1 100644 --- a/src/InputObject.cpp +++ b/src/InputObject.cpp @@ -33,15 +33,14 @@ InputObject::~InputObject() void InputObject::initUi() { //#3c3c3c - // - +#ifdef CUTE_STYLE QString style = "QWidget#WiBack{background-image: url(:/icons/bg.jpeg);}" "QWidget#WiBo{background-color: black;}" "QLineEdit,QDateEdit{background-color: rgba(0,0,0,0.5);\ min-height:100px;max-height:100px; min-width:500px;max-width:500px;\ border: 2px solid #ef9cba; border-radius:20px;\ - font-family:Arial; color:white;margin:0;font-size:36px;}" + font-family:Microsoft YaHei; color:white;margin:0;font-size:36px;}" "QTextEdit{background-color: rgba(0,0,0,0.5);\ min-height:300px;max-height:300px; min-width:700px;max-width:700px;\ border: 2px solid #ef9cba; border-radius:20px;\ @@ -49,6 +48,22 @@ void InputObject::initUi() "QDateEdit::up-button{image: url(:/up.png);height:15px;}" "QDateEdit::down-button{image:url(:/down.png);height:15px;}" ; +#else + QString style = + "QWidget#WiBack{background-color: #383533;}" + "QWidget#WiBo{background-color: black;}" + "QLineEdit,QDateEdit,QTextEdit{\ + background:qlineargradient(x1:0,y1:0,x2:1,y2:1,stop: 0.0 silver, stop: 1.0 grey);\ + border: 1px solid #1e1b18; border-radius:20px;\ + font-family:Microsoft YaHei; color:black;margin:0;font-size:36px;}" + + "QLineEdit,QDateEdit{min-height:100px; max-height:100px; min-width:500px; max-width:500px;}" + "QTextEdit{min-height:300px;max-height:300px; min-width:700px;max-width:700px;}" + + "QDateEdit::up-button{image: url(:/up.png);height:15px;}" + "QDateEdit::down-button{image:url(:/down.png);height:15px;}" + ; +#endif setStyleSheet(style); ui->dateEdit->setVisible(false); @@ -58,7 +73,7 @@ void InputObject::initUi() //this->setWindowOpacity(0.8); connect(QGuiApplication::inputMethod(), &QInputMethod::visibleChanged, [=]() { - if (QGuiApplication::inputMethod()->isVisible())return; + if (QGuiApplication::inputMethod()->isVisible()) return; //qDebug() << "HidePanel"; //qDebug() << "focusWidget" << qApp->focusWidget(); this->HidePanel(); @@ -143,45 +158,22 @@ void InputObject::ShowPanel() { ui->textEdit->setVisible(true); } - //else - //{ - // return; - //} - //QDesktopWidget w; - //int deskWidth = w.availableGeometry().width(); - //int deskHeight = w.availableGeometry().height(); - //int vkbHeight = QGuiApplication::inputMethod()->keyboardRectangle().height(); - this->showFullScreen(); this->setVisible(true); this->activateWindow(); //it is quite important!!! - - if (curLine) { ui->lineEdit->setText(curLine->text()); ui->lineEdit->setEchoMode(curLine->echoMode()); ui->lineEdit->setInputMethodHints(Qt::InputMethodHint::ImhNoAutoUppercase); - //qDebug() << "begin"; ui->lineEdit->setFocus(); - //QFocusEvent event0(QEvent::FocusIn); - //QCoreApplication::sendEvent(ui->lineEdit, &event0); - while (QGuiApplication::focusObject() != ui->lineEdit) - { - qApp->processEvents(); - } + while (QGuiApplication::focusObject() != ui->lineEdit) + { + qApp->processEvents(); + } - //qDebug() << QGuiApplication::focusObject(); QEvent event(QEvent::RequestSoftwareInputPanel); - QCoreApplication::sendEvent(ui->lineEdit, &event); - - // QMouseEvent pressed(QEvent::MouseButtonPress, QPointF(10,10),Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - // QApplication::sendEvent(ui->lineEdit, &pressed); - // qDebug()<<"release"; - // QMouseEvent release(QEvent::MouseButtonRelease, QPointF(10,10),Qt::LeftButton, Qt::LeftButton,Qt::NoModifier); - // QApplication::sendEvent(ui->lineEdit, &release); - // qDebug() <lineEdit, &event); } if (curDateEdit) @@ -195,7 +187,7 @@ void InputObject::ShowPanel() { } qDebug() << QGuiApplication::focusObject(); QEvent event(QEvent::RequestSoftwareInputPanel); - QCoreApplication::sendEvent(ui->dateEdit, &event); + QApplication::sendEvent(ui->dateEdit, &event); } if (curText) @@ -208,7 +200,7 @@ void InputObject::ShowPanel() { } //qDebug() << QGuiApplication::focusObject(); QEvent event(QEvent::RequestSoftwareInputPanel); - QCoreApplication::sendEvent(ui->textEdit, &event); + QApplication::sendEvent(ui->textEdit, &event); } } diff --git a/src/InputObject.h b/src/InputObject.h index 59a9917..ab2676f 100644 --- a/src/InputObject.h +++ b/src/InputObject.h @@ -5,6 +5,9 @@ class QLineEdit; class QDateEdit; class QTextEdit; + +//#define CUTE_STYLE + namespace Ui { class InputObject; } diff --git a/src/device/DeviceManager.cpp b/src/device/DeviceManager.cpp index 1378592..0054a31 100644 --- a/src/device/DeviceManager.cpp +++ b/src/device/DeviceManager.cpp @@ -101,6 +101,7 @@ void DeviceManager::timerEvent(QTimerEvent *event) { //preview scan else{ const char * data = GetPreviewData(); + if (!data) return; QByteArray bytes =QByteArray::fromRawData(data,140*140); TRIGGER_EVENT(GUIEvents::ResponsePreviewData, nullptr, (QObject*)(&bytes)); delete [] data;