Refactor InputObject(EventFilter and VirtualKeyboard).

This commit is contained in:
sunwen
2022-06-14 14:03:19 +08:00
parent 589262781d
commit 020b40c55d
36 changed files with 783 additions and 598 deletions

View File

@@ -4,8 +4,6 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QDateTime>
#include <QLineEdit>
#include <QTextEdit>
#include <QToolButton>
#include <QSqlTableModel>
#include <QUuid>
@@ -13,16 +11,20 @@
#include "dialogs/SelectDialog.h"
#include "DateSelectDialog.h"
#include "components/ListBox.h"
#include "components/ULineEdit.h"
#include "components/UTextEdit.h"
int queryValue(QSqlTableModel* model, int colID, const QVariant& var)
{
for (int i = 0; i < model->rowCount(); ++i) {
for (int i = 0; i < model->rowCount(); ++i)
{
if (model->data(model->index(i, colID)) == var) return i;
}
return -1;
}
EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
EditPatientDialog::EditPatientDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f)
{
QVBoxLayout* layout = new QVBoxLayout(mFormWidget);
layout->setSpacing(10);
// add title
@@ -35,49 +37,50 @@ EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFo
//add old password
QLabel* lbl_id = new QLabel(this);
lbl_id->setText(tr("ID"));
le_id = new QLineEdit(this);
le_id = new ULineEdit(this);
layout->addWidget(lbl_id);
layout->addWidget(le_id);
QLabel* lbl_endline1 = new QLabel(this);
lbl_endline1->setObjectName("endline");
layout->addWidget(lbl_endline1);
QLabel* lbl_name= new QLabel(this);
QLabel* lbl_name = new QLabel(this);
lbl_name->setText(tr("Name"));
le_name = new QLineEdit(this);
le_name = new ULineEdit(this);
layout->addWidget(lbl_name);
layout->addWidget(le_name);
QLabel* lbl_endline2 = new QLabel(this);
lbl_endline2->setObjectName("endline");
layout->addWidget(lbl_endline2);
QLabel* lbl_sex= new QLabel(this);
QLabel* lbl_sex = new QLabel(this);
lbl_sex->setText(tr("Gender"));
layout->addWidget(lbl_sex);
btnSex = new ListBox(this);
btnSex->setText(tr("Female"));
btnSex->setProperty("idx",0);
btnSex->setProperty("idx", 0);
btnSex->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btnSex->setLayoutDirection(Qt::RightToLeft);
btnSex->setObjectName("editvalBtn");
btnSex->setIcon(QIcon(":/icons/arrow-down.png"));
btnSex->setIconSize({30, 30});
btnSex->setIconSize({ 30, 30 });
btnSex->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
connect(btnSex, &QToolButton::clicked,[=](){
connect(btnSex, &QToolButton::clicked, [=]() {
SelectDialog dialog(this);
QStringList items;
items<<tr("Female")<<tr("Male")<<tr("Other");
items << tr("Female") << tr("Male") << tr("Other");
dialog.setValues(items);
dialog.setSelectedValue(items[btnSex->property("idx").toInt()]);
dialog.setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Accepted){
if (dialog.exec() == QDialog::Accepted)
{
btnSex->setText(dialog.getSelectedValue());
btnSex->setProperty("idx",items.indexOf(dialog.getSelectedValue()));
btnSex->setProperty("idx", items.indexOf(dialog.getSelectedValue()));
}
});
});
layout->addWidget(btnSex);
QLabel *lbl_endline9 = new QLabel(this);
QLabel* lbl_endline9 = new QLabel(this);
lbl_endline9->setFixedHeight(2);
lbl_endline9->setObjectName("endline");
layout->addWidget(lbl_endline9);
@@ -92,17 +95,18 @@ EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFo
btnDate->setLayoutDirection(Qt::RightToLeft);
btnDate->setObjectName("editvalBtn");
btnDate->setIcon(QIcon(":/icons/arrow-down.png"));
btnDate->setIconSize({30, 30});
btnDate->setIconSize({ 30, 30 });
btnDate->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
btnDate->setText("1990-06-15");
connect(btnDate, &QToolButton::clicked,[=](){
connect(btnDate, &QToolButton::clicked, [=]() {
DateSelectDialog dialog(this);
dialog.setSelectedValue(btnDate->text());
dialog.setWindowModality(Qt::WindowModal);
if (dialog.exec() == QDialog::Accepted){
if (dialog.exec() == QDialog::Accepted)
{
btnDate->setText(dialog.getSelectedValue());
}
});
});
layout->addWidget(btnDate);
QLabel* lbl_endline5 = new QLabel(this);
lbl_endline5->setObjectName("endline");
@@ -110,7 +114,7 @@ EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFo
QLabel* lbl_comment = new QLabel(this);
lbl_comment->setText(tr("Comment"));
te_comment = new QTextEdit(this);
te_comment = new UTextEdit(this);
layout->addWidget(lbl_comment);
layout->addWidget(te_comment);
QLabel* lbl_endline6 = new QLabel(this);
@@ -122,15 +126,17 @@ EditPatientDialog::EditPatientDialog(QWidget *parent, Qt::WindowFlags f) : GUIFo
layout->addWidget(lbl_error);
}
EditPatientDialog::~EditPatientDialog() {
EditPatientDialog::~EditPatientDialog()
{
}
void EditPatientDialog::setPatientInformation(PatientInformation* information) {
void EditPatientDialog::setPatientInformation(PatientInformation* information)
{
if (information)
{
le_id->setText(information->ID);
btnSex->setText(information->Sex == tr("F")?tr("Female"):(information->Sex == tr("M")?tr("Male"):tr("Other")));
btnSex->setText(information->Sex == tr("F") ? tr("Female") : (information->Sex == tr("M") ? tr("Male") : tr("Other")));
le_name->setText(information->Name);
te_comment->setText(information->Comment);
btnDate->setText(information->BirthDate);
@@ -140,16 +146,18 @@ void EditPatientDialog::setPatientInformation(PatientInformation* information) {
}
}
void EditPatientDialog::clearPatientInformation() {
void EditPatientDialog::clearPatientInformation()
{
le_id->setText("");
// le_date->setText("");
// le_date->setText("");
le_name->setText("");
te_comment->setText("");
}
void EditPatientDialog::storePatientInformation() {
void EditPatientDialog::storePatientInformation()
{
store.PatientUID = currentPatientUID;
// store.AddDate = AddDate;
// store.AddDate = AddDate;
store.ID = le_id->text();
store.BirthDate = le_date->text();
store.Name = le_name->text();
@@ -157,15 +165,18 @@ void EditPatientDialog::storePatientInformation() {
store.Comment = te_comment->toPlainText();
}
bool EditPatientDialog::updateReferenceData() {
bool EditPatientDialog::updateReferenceData()
{
PatientInformation* inf = getPatientInformation();
if (le_id->text().isEmpty()){
if (le_id->text().isEmpty())
{
lbl_error->setText("ID can't be empty!");
lbl_error->setVisible(true);
return false;
}
inf->ID = le_id->text().trimmed();
if (le_name->text().isEmpty()){
if (le_name->text().isEmpty())
{
lbl_error->setText("Patient Name can't be empty!");
lbl_error->setVisible(true);
return false;
@@ -173,7 +184,8 @@ bool EditPatientDialog::updateReferenceData() {
inf->Name = le_name->text().trimmed();
int selectedRow = 0;
bool isAdd = currentPatientUID.isEmpty();
if (isAdd) {
if (isAdd)
{
int ref_rowid = queryValue(model, 1, inf->ID);
if (ref_rowid >= 0)
{
@@ -185,28 +197,30 @@ bool EditPatientDialog::updateReferenceData() {
inf->AddDate = QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss");
model->insertRow(0);
}
else{
else
{
inf->PatientUID = currentPatientUID;
selectedRow = queryValue(model, 1, inf->ID);
inf->AddDate = AddDate;
}
inf->Sex = btnSex->text()==tr("Female")?"F":(tr("Male")==btnSex->text()?"M":"O");
inf->Sex = btnSex->text() == tr("Female") ? "F" : (tr("Male") == btnSex->text() ? "M" : "O");
inf->BirthDate = btnDate->text();
inf->Comment = te_comment->toPlainText();
#define ADD_PATIENT_PROPERTY(val)\
#define ADD_PATIENT_PROPERTY(val)\
model->setData(model->index(selectedRow,PatientInformationEnum:: val),inf-> val);
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
if (model->submitAll())
{
return true;
}
else {
lbl_error->setText("Submit to database error!");
lbl_error->setVisible(true);
return false;
}
EDIT_PATIENT()
#undef ADD_PATIENT_PROPERTY
if (model->submitAll())
{
return true;
}
else
{
lbl_error->setText("Submit to database error!");
lbl_error->setVisible(true);
return false;
}
}

View File

@@ -8,25 +8,27 @@
#include "dialogs/GUIFormBaseDialog.h"
#include "forms/select/editpatientform.h"
class QLineEdit;
class QTextEdit;
class ULineEdit;
class UTextEdit;
class QLabel;
class QToolButton;
class QSqlTableModel;
class EditPatientDialog :public GUIFormBaseDialog{
class EditPatientDialog :public GUIFormBaseDialog {
Q_OBJECT
public:
explicit EditPatientDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit EditPatientDialog(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~EditPatientDialog();
void setModel(QSqlTableModel * m){
model=m;
void setModel(QSqlTableModel* m)
{
model = m;
}
PatientInformation * getPatientInformation(){
PatientInformation* getPatientInformation()
{
return &store;
}
void setPatientInformation(PatientInformation * information);
void setPatientInformation(PatientInformation* information);
void clearPatientInformation();
void storePatientInformation();
@@ -35,11 +37,11 @@ protected:
bool updateReferenceData() override;
private:
QLineEdit* le_id= nullptr;
QLineEdit* le_name = nullptr;
QLineEdit* le_sex = nullptr;
QLineEdit* le_date = nullptr;
QTextEdit* te_comment = nullptr;
ULineEdit* le_id = nullptr;
ULineEdit* le_name = nullptr;
ULineEdit* le_sex = nullptr;
ULineEdit* le_date = nullptr;
UTextEdit* te_comment = nullptr;
QLabel* lbl_error = nullptr;
PatientInformation store;
QString currentPatientUID;

22
src/UsctApplication.cpp Normal file
View File

@@ -0,0 +1,22 @@
#include "UsctApplication.h"
#include "utilities/TouchScreenSignalSender.h"
UsctApplication::UsctApplication(int& argc, char** argv)
: QApplication(argc, argv)
{
}
UsctApplication::~UsctApplication()
{
}
bool UsctApplication::notify(QObject* aReceiver, QEvent* aEvent)
{
if (aEvent->type() == QEvent::MouseButtonPress)
{
TouchScreenSignalSender::getInstance()->sendTouchScreenSignal();
}
return QApplication::notify(aReceiver, aEvent);
}

17
src/UsctApplication.h Normal file
View File

@@ -0,0 +1,17 @@
#ifndef USCTAPPLICATION_H
#define USCTAPPLICATION_H
#include <QApplication>
class UsctApplication : public QApplication
{
Q_OBJECT
public:
UsctApplication(int& argc, char** argv);
~UsctApplication();
private:
bool notify(QObject* aReceiver, QEvent* aEvent);
};
#endif // USCTAPPLICATION_H

View File

@@ -0,0 +1,17 @@
#include "ULineEdit.h"
#include <QEvent>
#include "keyboard/KeyboardManager.h"
ULineEdit::ULineEdit(QWidget* aParent)
: QLineEdit(aParent)
{
}
ULineEdit::~ULineEdit()
{
}
void ULineEdit::mouseReleaseEvent(QMouseEvent* /*aEvent*/)
{
KeyboardManager::getInstance()->showKeyboardPanel(this);
}

View File

@@ -0,0 +1,19 @@
#ifndef ULINEEDIT_H
#define ULINEEDIT_H
#include <QLineEdit>
class ULineEdit : public QLineEdit
{
Q_OBJECT
public:
explicit ULineEdit(QWidget* aParent);
~ULineEdit();
protected:
void mouseReleaseEvent(QMouseEvent* aEvent);
};
#endif // ULINEEDIT_H

View File

@@ -0,0 +1,17 @@
#include "UTextEdit.h"
#include <QEvent>
#include "keyboard/KeyboardManager.h"
UTextEdit::UTextEdit(QWidget* aParent)
: QTextEdit(aParent)
{
}
UTextEdit::~UTextEdit()
{
}
void UTextEdit::mouseReleaseEvent(QMouseEvent* /*aEvent*/)
{
KeyboardManager::getInstance()->showKeyboardPanel(this);
}

View File

@@ -0,0 +1,19 @@
#ifndef UTEXTEDIT_H
#define UTEXTEDIT_H
#include <QTextEdit>
class UTextEdit : public QTextEdit
{
Q_OBJECT
public:
explicit UTextEdit(QWidget* aParent);
~UTextEdit();
protected:
void mouseReleaseEvent(QMouseEvent* aEvent);
};
#endif // UTEXTEDIT_H

View File

@@ -9,27 +9,27 @@
#include <QDebug>
#include <QToolButton>
#include <QPushButton>
#include <QLineEdit>
#include "ChangePasswordFormDialog.h"
#include "event/EventCenter.h"
#include "log/UserOperationLog.h"
#include "db/SQLHelper.h"
#include "models/User.h"
#include "AlertDialog.h"
#include "components/ULineEdit.h"
AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt::WindowFlags f)
: GUIFormBaseDialog(parent, f)
, mUserNameChanged(false)
, mCommentChanged(false)
, mRoleChanged(false)
, mMode(mode)
, mLeUserCode(new QLineEdit(this))
, mLeUserName(new QLineEdit(this))
, mLeComment(new QLineEdit(this))
, mLePwd(nullptr)
, mBtnPwd(nullptr)
, mLblError(new QLabel(this))
, mRefModel(nullptr)
: GUIFormBaseDialog(parent, f)
, mUserNameChanged(false)
, mCommentChanged(false)
, mRoleChanged(false)
, mMode(mode)
, mLeUserCode(new ULineEdit(this))
, mLeUserName(new ULineEdit(this))
, mLeComment(new ULineEdit(this))
, mLePwd(nullptr)
, mBtnPwd(nullptr)
, mLblError(new QLabel(this))
, mRefModel(nullptr)
{
auto layout = new QVBoxLayout(mFormWidget);
layout->setSpacing(10);
@@ -42,75 +42,85 @@ AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt::
auto hlayout = new QHBoxLayout;
layout->addLayout(hlayout);
if (mMode == Self)addSelfModeUI(hlayout);
if (mMode != New) {
if (mMode != New)
{
addButtonPwd(hlayout);
addEndLine(layout);
connect(mBtnPwd, &QPushButton::clicked, this, mMode == Self ?
&AccountFormDialog::changeSelfPassword : &AccountFormDialog::resetUserPassword);
&AccountFormDialog::changeSelfPassword : &AccountFormDialog::resetUserPassword);
}
connect(mLeComment, &QLineEdit::textChanged, [=](const QString &text) {
connect(mLeComment, &QLineEdit::textChanged, [=](const QString& text) {
mCommentChanged = true;
});
connect(mLeUserName, &QLineEdit::textChanged, [=](const QString &text) {
});
connect(mLeUserName, &QLineEdit::textChanged, [=](const QString& text) {
mNewUserName = text;
mUserNameChanged = true;
});
});
}
void AccountFormDialog::addEndLine(QVBoxLayout *layout) {
void AccountFormDialog::addEndLine(QVBoxLayout* layout)
{
auto lblEndline = new QLabel(this);
lblEndline->setFixedHeight(2);
lblEndline->setObjectName("endline");
layout->addWidget(lblEndline);
}
void AccountFormDialog::resetUserPassword() {
void AccountFormDialog::resetUserPassword()
{
AlertDialog dialog(this);
dialog.setGeometry(geometry());
dialog.setButtonMode(OkAndCancel);
dialog.setWindowModality(Qt::WindowModal);
dialog.setAlertMessage(tr("Reset password to \"123456\" ?"));
if (dialog.exec() == Accepted) {
if (dialog.exec() == Accepted)
{
User user;
dialog.setButtonMode(OkOnly);
if (!User::getUser(mUserID, user)) {
if (!User::getUser(mUserID, user))
{
dialog.setAlertMessage(tr("Inner error, can't find reference user!"));
dialog.exec();
return;
}
if (!user.resetPassword()) {
if (!user.resetPassword())
{
dialog.setAlertMessage(tr("Submit change to database fail!"));
dialog.exec();
}
}
}
void AccountFormDialog::changeSelfPassword() {
void AccountFormDialog::changeSelfPassword()
{
ChangePasswordFormDialog dia(this);
dia.setGeometry(geometry());
dia.setWindowModality(Qt::WindowModal);
dia.exec();
}
void AccountFormDialog::addButtonPwd(QHBoxLayout *layout) {
void AccountFormDialog::addButtonPwd(QHBoxLayout* layout)
{
mBtnPwd = new QToolButton(this);
mBtnPwd->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mBtnPwd->setObjectName("editvalBtn");
mBtnPwd->setIcon(QIcon(":/icons/edit.png"));
mBtnPwd->setIconSize({30, 30});
mBtnPwd->setIconSize({ 30, 30 });
mBtnPwd->setText(mMode == Self ? tr("Change Password") : tr("Reset Password"));
mBtnPwd->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
layout->addWidget(mBtnPwd);
}
void AccountFormDialog::addWarnLabel(QVBoxLayout *layout) {
void AccountFormDialog::addWarnLabel(QVBoxLayout* layout)
{
mLblError->setObjectName("warn");
mLblError->setVisible(false);
layout->addWidget(mLblError);
}
void AccountFormDialog::addCommentLabel(QVBoxLayout *layout) {
void AccountFormDialog::addCommentLabel(QVBoxLayout* layout)
{
auto lblComment = new QLabel(this);
lblComment->setText(tr("Comment"));
layout->addWidget(lblComment);
@@ -118,7 +128,8 @@ void AccountFormDialog::addCommentLabel(QVBoxLayout *layout) {
addEndLine(layout);
}
void AccountFormDialog::initUserNameUI(QVBoxLayout *layout) {
void AccountFormDialog::initUserNameUI(QVBoxLayout* layout)
{
auto lblUserName = new QLabel(this);
lblUserName->setText(tr("Name"));
@@ -128,7 +139,8 @@ void AccountFormDialog::initUserNameUI(QVBoxLayout *layout) {
addEndLine(layout);
}
void AccountFormDialog::initUserCodeUI(QVBoxLayout *layout) {
void AccountFormDialog::initUserCodeUI(QVBoxLayout* layout)
{
auto lblUserCode = new QLabel(this);
lblUserCode->setText(tr("User ID"));
@@ -139,7 +151,8 @@ void AccountFormDialog::initUserCodeUI(QVBoxLayout *layout) {
addEndLine(layout);
}
void AccountFormDialog::addTitleLabel(QVBoxLayout *layout) {
void AccountFormDialog::addTitleLabel(QVBoxLayout* layout)
{
auto lblTitle = new QLabel(this);
lblTitle->setAlignment(Qt::AlignCenter);
lblTitle->setText(tr("Account"));
@@ -147,11 +160,12 @@ void AccountFormDialog::addTitleLabel(QVBoxLayout *layout) {
layout->addWidget(lblTitle);
}
void AccountFormDialog::addSelfModeUI(QHBoxLayout *hlayout) {
void AccountFormDialog::addSelfModeUI(QHBoxLayout* hlayout)
{
auto btnLogout = new QToolButton(this);
btnLogout->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btnLogout->setIcon(QIcon(":/icons/logout.png"));
btnLogout->setIconSize({30, 30});
btnLogout->setIconSize({ 30, 30 });
btnLogout->setText(tr("Logout"));
btnLogout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
btnLogout->setObjectName("editvalBtn");
@@ -160,10 +174,11 @@ void AccountFormDialog::addSelfModeUI(QHBoxLayout *hlayout) {
connect(btnLogout, &QAbstractButton::clicked, [=]() {
accept();
LOG_USER_OPERATION(Logout)
EventCenter::Default()->triggerEvent(RequestLogin, nullptr, nullptr);
});
EventCenter::Default()->triggerEvent(RequestLogin, nullptr, nullptr);
});
// load current user data
if (User::Current()) {
if (User::Current())
{
mLeUserCode->setText(User::Current()->getUserCode());
mLeUserName->setText(User::Current()->getUserName());
mUserID = User::Current()->getUserID();
@@ -171,11 +186,12 @@ void AccountFormDialog::addSelfModeUI(QHBoxLayout *hlayout) {
}
}
void AccountFormDialog::addNewModeUI(QVBoxLayout *layout) {
void AccountFormDialog::addNewModeUI(QVBoxLayout* layout)
{
auto lblPwd = new QLabel(this);
lblPwd->setText(tr("Password"));
layout->addWidget(lblPwd);
mLePwd = new QLineEdit(this);
mLePwd = new ULineEdit(this);
mLePwd->setPlaceholderText(tr("Input password"));
mLePwd->setEchoMode(QLineEdit::Password);
layout->addWidget(mLePwd);
@@ -183,66 +199,82 @@ void AccountFormDialog::addNewModeUI(QVBoxLayout *layout) {
addEndLine(layout);
}
bool AccountFormDialog::updateReferenceData() {
if (mMode == Self) {
if (!this->mUserNameChanged && !this->mCommentChanged) return true;
if (!this->mUserNameChanged) {
if (mNewUserName.isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
User::Current()->setUserName(mNewUserName);
}
if (!this->mCommentChanged) User::Current()->setUserName(mLeComment->text());
bool ret = User::Current()->submitChange();
if (ret) {
hideWarn();
LOG_USER_OPERATION(ChangeUserName)
}
else {
warn(tr("Submit change to database fail!"));
}
return ret;
}
else if (mMode == Admin) {
if (!this->mUserNameChanged && !this->mRoleChanged) return true;
User user;
if (!User::getUser(mUserID, user)) return true;
if (this->mUserNameChanged) {
if (mNewUserName.isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
user.setUserName(mNewUserName);
}
if (this->mRoleChanged) user.setRoleID(mRoleID);
if (!this->mCommentChanged) user.setComment(mLeComment->text());
bool ret = user.submitChange();
if (ret) {
LOG_USER_OPERATION(AdminChangeAcountInformation)
}
return ret;
}
else {
bool AccountFormDialog::updateReferenceData()
{
if (mMode == Self)
{
if (!this->mUserNameChanged && !this->mCommentChanged) return true;
if (!this->mUserNameChanged)
{
if (mNewUserName.isEmpty())
{
warn(tr("User Name can't be empty!"));
return false;
}
User::Current()->setUserName(mNewUserName);
}
if (!this->mCommentChanged) User::Current()->setUserName(mLeComment->text());
bool ret = User::Current()->submitChange();
if (ret)
{
hideWarn();
LOG_USER_OPERATION(ChangeUserName)
}
else
{
warn(tr("Submit change to database fail!"));
}
return ret;
}
else if (mMode == Admin)
{
if (!this->mUserNameChanged && !this->mRoleChanged) return true;
User user;
if (!User::getUser(mUserID, user)) return true;
if (this->mUserNameChanged)
{
if (mNewUserName.isEmpty())
{
warn(tr("User Name can't be empty!"));
return false;
}
user.setUserName(mNewUserName);
}
if (this->mRoleChanged) user.setRoleID(mRoleID);
if (!this->mCommentChanged) user.setComment(mLeComment->text());
bool ret = user.submitChange();
if (ret)
{
LOG_USER_OPERATION(AdminChangeAcountInformation)
}
return ret;
}
else
{
//add new
User user;
if (mLeUserCode->text().isEmpty()) {
if (mLeUserCode->text().isEmpty())
{
warn(tr("User ID can't be empty!"));
return false;
}
if (mLeUserName->text().isEmpty()) {
if (mLeUserName->text().isEmpty())
{
warn(tr("User Name can't be empty!"));
return false;
}
if (mLePwd->text().isEmpty()) {
if (mLePwd->text().isEmpty())
{
warn(tr("Password can't be empty!"));
return false;
}
if (!mRefModel) {
if (!mRefModel)
{
warn(tr("Inner error ,unset data model!"));
return false;
}
if (User::existsUser(mLeUserCode->text())) {
if (User::existsUser(mLeUserCode->text()))
{
warn(tr("User Id exists!"));
return false;
}
@@ -274,30 +306,36 @@ bool AccountFormDialog::updateReferenceData() {
#undef USER_READONLY_PROPERTY
#undef USER_PROPERTY
if (mRefModel->submit()) {
hideWarn();
return true;
} else {
warn(tr("Submit to data base fail!"));
return false;
}
if (mRefModel->submit())
{
hideWarn();
return true;
}
else
{
warn(tr("Submit to data base fail!"));
return false;
}
}
return true;
return true;
}
void AccountFormDialog::setAccountInformation(const QMap<QString, QVariant>& values) {
mLeUserCode->setText(values["UserCode"].toString());
mLeUserName->setText(values["UserName"].toString());
mLeComment->setText(values["Comment"].toString());
void AccountFormDialog::setAccountInformation(const QMap<QString, QVariant>& values)
{
mLeUserCode->setText(values["UserCode"].toString());
mLeUserName->setText(values["UserName"].toString());
mLeComment->setText(values["Comment"].toString());
mUserID = values["UserID"].toString();
mUserPwd = values["Password"].toString();
}
void AccountFormDialog::warn(const QString& msg) {
mLblError->setText(msg);
mLblError->setVisible(true);
void AccountFormDialog::warn(const QString& msg)
{
mLblError->setText(msg);
mLblError->setVisible(true);
}
void AccountFormDialog::hideWarn() {
mLblError->setVisible(false);
void AccountFormDialog::hideWarn()
{
mLblError->setVisible(false);
}

View File

@@ -5,23 +5,24 @@
#ifndef GUI_ACCOUNTFORMDIALOG_H
#define GUI_ACCOUNTFORMDIALOG_H
class QLabel;
class QLineEdit;
class ULineEdit;
class QToolButton;
class QSqlTableModel;
#include <QtWidgets/QVBoxLayout>
#include "GUIFormBaseDialog.h"
enum AccountEditMode{
enum AccountEditMode {
Self, Admin, New
};
class AccountFormDialog:public GUIFormBaseDialog{
class AccountFormDialog :public GUIFormBaseDialog {
Q_OBJECT
public:
explicit AccountFormDialog(QWidget *parent = nullptr,AccountEditMode mode = Self,Qt::WindowFlags f = Qt::WindowFlags());
explicit AccountFormDialog(QWidget* parent = nullptr, AccountEditMode mode = Self, Qt::WindowFlags f = Qt::WindowFlags());
~AccountFormDialog() override = default;
void setAccountInformation(const QMap<QString,QVariant>& values);
void setReferenceModel(QSqlTableModel* model){
void setAccountInformation(const QMap<QString, QVariant>& values);
void setReferenceModel(QSqlTableModel* model)
{
mRefModel = model;
}
protected:
@@ -29,15 +30,15 @@ protected:
void warn(const QString& msg);
void hideWarn();
private:
void addEndLine(QVBoxLayout *layout);
void addNewModeUI(QVBoxLayout *layout);
void addSelfModeUI(QHBoxLayout *layout);
void addTitleLabel(QVBoxLayout *layout);
void initUserCodeUI(QVBoxLayout *layout);
void initUserNameUI(QVBoxLayout *layout);
void addCommentLabel(QVBoxLayout *layout);
void addWarnLabel(QVBoxLayout *layout);
void addButtonPwd(QHBoxLayout *layout);
void addEndLine(QVBoxLayout* layout);
void addNewModeUI(QVBoxLayout* layout);
void addSelfModeUI(QHBoxLayout* layout);
void addTitleLabel(QVBoxLayout* layout);
void initUserCodeUI(QVBoxLayout* layout);
void initUserNameUI(QVBoxLayout* layout);
void addCommentLabel(QVBoxLayout* layout);
void addWarnLabel(QVBoxLayout* layout);
void addButtonPwd(QHBoxLayout* layout);
void changeSelfPassword();
void resetUserPassword();
QString mUserID;
@@ -48,10 +49,10 @@ private:
bool mCommentChanged;
bool mRoleChanged;
AccountEditMode mMode;
QLineEdit* mLeUserCode;
QLineEdit* mLeUserName;
QLineEdit* mLeComment;
QLineEdit* mLePwd;
ULineEdit* mLeUserCode;
ULineEdit* mLeUserName;
ULineEdit* mLeComment;
ULineEdit* mLePwd;
QToolButton* mBtnPwd;
QLabel* mLblError;

View File

@@ -4,22 +4,23 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "components/ULineEdit.h"
#include "models/User.h"
#include "log/UserOperationLog.h"
#include "ChangePasswordFormDialog.h"
ChangePasswordFormDialog::ChangePasswordFormDialog(QWidget* parent, Qt::WindowFlags f)
: GUIFormBaseDialog(parent, f)
, mLEPasswd(new QLineEdit(this))
, mLENewPasswd(new QLineEdit(this))
, mLEConfirmPasswd(new QLineEdit(this))
, mLblError(new QLabel(this))
: GUIFormBaseDialog(parent, f)
, mLEPasswd(new ULineEdit(this))
, mLENewPasswd(new ULineEdit(this))
, mLEConfirmPasswd(new ULineEdit(this))
, mLblError(new QLabel(this))
{
initLayout();
}
void ChangePasswordFormDialog::initLayout() {
void ChangePasswordFormDialog::initLayout()
{
auto layout = new QVBoxLayout(mFormWidget);
layout->setSpacing(10);
// add title
@@ -67,33 +68,36 @@ void ChangePasswordFormDialog::initLayout() {
}
bool ChangePasswordFormDialog::updateReferenceData() {
if (mLEPasswd->text().isEmpty())
{
mLblError->setText(tr("Please enter your old password!"));
return false;
}
if (mLENewPasswd->text().length() < 6) {
mLblError->setText(tr("New password should at least 6 characters!"));
return false;
}
QString encryptPwd = User::getEncryptedPassword(mLEPasswd->text());
if (encryptPwd != User::Current()->getPassword())
{
mLblError->setText(tr("Wrong password!"));
return false;
}
if (mLENewPasswd->text() != mLEConfirmPasswd->text())
{
mLblError->setText(tr("Your new password does not match!"));
return false;
}
User::Current()->setPassword(User::getEncryptedPassword(mLENewPasswd->text()));
if (!User::Current()->submitChange()) {
mLblError->setText(tr("Database update error!"));
User::Current()->restorePassword(encryptPwd);
return false;
}
LOG_USER_OPERATION(ChangePassword);
return true;
bool ChangePasswordFormDialog::updateReferenceData()
{
if (mLEPasswd->text().isEmpty())
{
mLblError->setText(tr("Please enter your old password!"));
return false;
}
if (mLENewPasswd->text().length() < 6)
{
mLblError->setText(tr("New password should at least 6 characters!"));
return false;
}
QString encryptPwd = User::getEncryptedPassword(mLEPasswd->text());
if (encryptPwd != User::Current()->getPassword())
{
mLblError->setText(tr("Wrong password!"));
return false;
}
if (mLENewPasswd->text() != mLEConfirmPasswd->text())
{
mLblError->setText(tr("Your new password does not match!"));
return false;
}
User::Current()->setPassword(User::getEncryptedPassword(mLENewPasswd->text()));
if (!User::Current()->submitChange())
{
mLblError->setText(tr("Database update error!"));
User::Current()->restorePassword(encryptPwd);
return false;
}
LOG_USER_OPERATION(ChangePassword);
return true;
}

View File

@@ -6,12 +6,12 @@
#define GUI_CHANGEPASSWORDFORMDIALOG_H
#include "GUIFormBaseDialog.h"
class QLineEdit;
class ULineEdit;
class QLabel;
class ChangePasswordFormDialog:public GUIFormBaseDialog{
class ChangePasswordFormDialog :public GUIFormBaseDialog {
Q_OBJECT
public:
explicit ChangePasswordFormDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
explicit ChangePasswordFormDialog(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~ChangePasswordFormDialog() override = default;
protected:
@@ -19,9 +19,9 @@ protected:
private:
void initLayout();
QLineEdit* mLEPasswd;
QLineEdit* mLENewPasswd;
QLineEdit* mLEConfirmPasswd;
ULineEdit* mLEPasswd;
ULineEdit* mLENewPasswd;
ULineEdit* mLEConfirmPasswd;
QLabel* mLblError;

View File

@@ -1,140 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EditPatientForm</class>
<widget class="QWidget" name="EditPatientForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="hideBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_ID">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_ID">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_Name">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Sex">
<property name="text">
<string>Gender</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="tbx_Sex">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_DOB">
<property name="text">
<string>Date Of Birth</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="tbx_Dob">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Comment">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item>
<widget class="QTextEdit" name="rtbx_Comment">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="editcmdWidget" native="true"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
<class>EditPatientForm</class>
<widget class="QWidget" name="EditPatientForm">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>466</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QToolButton" name="hideBtn">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_ID">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="ULineEdit" name="tbx_ID" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Name">
<property name="text">
<string>Name</string>
</property>
</widget>
</item>
<item>
<widget class="ULineEdit" name="tbx_Name" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Sex">
<property name="text">
<string>Gender</string>
</property>
</widget>
</item>
<item>
<widget class="ULineEdit" name="tbx_Sex" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_DOB">
<property name="text">
<string>Date Of Birth</string>
</property>
</widget>
</item>
<item>
<widget class="QDateEdit" name="tbx_Dob">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="buttonSymbols">
<enum>QAbstractSpinBox::NoButtons</enum>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_Comment">
<property name="text">
<string>Comment</string>
</property>
</widget>
</item>
<item>
<widget class="UTextEdit" name="rtbx_Comment">
<property name="enabled">
<bool>true</bool>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="editcmdWidget" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ULineEdit</class>
<extends>QLineEdit</extends>
<header>components/ULineEdit.h</header>
</customwidget>
<customwidget>
<class>UTextEdit</class>
<extends>QTextEdit</extends>
<header>components/UTextEdit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -6,14 +6,13 @@
#include <QHBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QEvent>
#include "event/EventCenter.h"
#include "json/jsonobject.h"
#include "src/dialogs/SelectDialog.h"
#include "src/utilities/locker.h"
#include "src/utilities/languageswitcher.h"
#include "components/ULineEdit.h"
GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
{
@@ -34,14 +33,14 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
QHBoxLayout* instHeaderLayout = new QHBoxLayout(instHeader);
QLabel* lbl_ins = new QLabel(tr("Institution Name"));
instHeaderLayout->addWidget(lbl_ins);
QLineEdit* instName = new QLineEdit(instHeader);
QLineEdit* instName = new ULineEdit(instHeader);
instName->setMaximumSize(QSize(300, 32768));
instHeaderLayout->addWidget(instName);
instHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Fixed));
QLabel* lbl_insaddr = new QLabel(tr("Institution Addr"));
instHeaderLayout->addWidget(lbl_insaddr);
QLineEdit* instAddr = new QLineEdit(instHeader);
QLineEdit* instAddr = new ULineEdit(instHeader);
instHeaderLayout->addWidget(instAddr);
instAddr->setMaximumSize(QSize(300, 32768));
instHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
@@ -53,7 +52,7 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
QLabel* lbl_lock = new QLabel(tr("Lock Screen"));
lockHeaderLayout->addWidget(lbl_lock);
QLineEdit* lockTime = new QLineEdit(lockHeader);
QLineEdit* lockTime = new ULineEdit(lockHeader);
lockTime->setMaximumSize(QSize(300, 32768));
lockHeaderLayout->addWidget(lockTime);

View File

@@ -3,7 +3,6 @@
#include <QPushButton>
#include <QDebug>
#include <QLineEdit>
#include <QToolButton>
#include <QGridLayout>

View File

@@ -5,38 +5,38 @@
class QPushButton;
class QVBoxLayout;
class SelectDialog;
class QLineEdit;
class ImageSwitch;
namespace Ui {
class systemSettingForm;
namespace Ui
{
class systemSettingForm;
}
class systemSettingForm : public QWidget
{
Q_OBJECT
Q_OBJECT
public:
explicit systemSettingForm(QWidget* parent = nullptr);
~systemSettingForm();
//protected:
// void changeEvent(QEvent* event);
explicit systemSettingForm(QWidget* parent = nullptr);
~systemSettingForm();
//protected:
// void changeEvent(QEvent* event);
private:
void updateStorageSize();
void updateStorageUsed();
void updateStorageSize();
void updateStorageUsed();
Ui::systemSettingForm* ui;
Ui::systemSettingForm* ui;
SelectDialog* sd_protocal = nullptr;
SelectDialog* sd_filter = nullptr;
SelectDialog* sd_protocal = nullptr;
SelectDialog* sd_filter = nullptr;
QThread* diskInfoCaller = nullptr;
QThread* diskInfoCaller = nullptr;
double m_disksize;
double m_diskuse;
bool flag_disksize = false;
bool flag_diskuse = false;
double m_disksize;
double m_diskuse;
bool flag_disksize = false;
bool flag_diskuse = false;
};
#endif // SYSTEMSETTINGFORM_H

View File

@@ -0,0 +1,23 @@
#include "KeyboardManager.h"
#include "KeyboardPanel.h"
KeyboardManager* KeyboardManager::getInstance()
{
static KeyboardManager instance;
return &instance;
}
KeyboardManager::KeyboardManager()
: mKeyboardPanel(new KeyboardPanel())
{
}
KeyboardManager::~KeyboardManager()
{
}
void KeyboardManager::showKeyboardPanel(QWidget* aInputWidget)
{
mKeyboardPanel->showPanel(aInputWidget);
}

View File

@@ -0,0 +1,27 @@
#ifndef KEYBOARDMANAGER_H
#define KEYBOARDMANAGER_H
#include <QObject>
#include <memory>
class KeyboardPanel;
typedef std::shared_ptr<KeyboardPanel> KeyboardPanelPointer;
class KeyboardManager : public QObject
{
Q_OBJECT
public:
static KeyboardManager* getInstance();
void showKeyboardPanel(QWidget* aInputWidget);
private:
explicit KeyboardManager();
~KeyboardManager();
private:
KeyboardPanelPointer mKeyboardPanel;
};
#endif // KEYBOARDMANAGER_H

View File

@@ -1,37 +1,35 @@
#include "InputObject.h"
#include "ui_InputObject.h"
#include "KeyboardPanel.h"
#include "ui_KeyboardPanel.h"
#include <QDebug>
#include <QEvent>
#include <QKeyEvent>
#include <QComboBox>
#include <QDateEdit>
#include <QtVirtualKeyboard>
#include <QKeyEvent>
#include <QLineEdit>
#include <QAbstractSpinBox>
InputObject::InputObject(QWidget* aParent)
KeyboardPanel::KeyboardPanel(QWidget* aParent)
: QWidget(aParent)
, mUI(new Ui::InputObject)
, mCurrentDateEdit(nullptr)
, mUI(new Ui::KeyboardPanel)
, mCurrentLineEdit(nullptr)
, mCurrentTextEdit(nullptr)
{
mUI->setupUi(this);
initializeStyle();
initUi();
setVisible(false);
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
}
InputObject::~InputObject()
KeyboardPanel::~KeyboardPanel()
{
delete mUI;
}
void InputObject::initUi()
void KeyboardPanel::initializeStyle()
{
//#3c3c3c
#ifdef CUTE_STYLE
@@ -66,108 +64,37 @@ void InputObject::initUi()
;
#endif
setStyleSheet(style);
}
mUI->dateEdit->setVisible(false);
mUI->dateEdit->setMaximumDate(QDate::currentDate());
mUI->dateEdit->setDisplayFormat("yyyy/MM/dd");
mUI->dateEdit->setStyleSheet(style);
void KeyboardPanel::initUi()
{
connect(QGuiApplication::inputMethod(), &QInputMethod::visibleChanged, [=]() {
if (QGuiApplication::inputMethod()->isVisible())
{
return;
}
HidePanel();
hidePanel();
hide();
});
}
bool InputObject::eventFilter(QObject* aObject, QEvent* aEvent)
void KeyboardPanel::showPanel(QWidget* aInputWidget)
{
if (aEvent->type() == QEvent::MouseButtonPress)
{
emit touchScreen();
}
if (aEvent->type() == QEvent::KeyPress)
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(aEvent);
if (keyEvent->key() == Qt::Key_Return && mCurrentDateEdit)
{
HidePanel();
hide();
}
}
//mouse button release means setfocus is useless
if (aEvent->type() == QEvent::MouseButtonRelease)
{
if (aObject->objectName() == QString("qt_spinbox_lineedit"))
{
QDateEdit* dateEdit = qobject_cast<QDateEdit*>(aObject->parent());
if (dateEdit == mUI->dateEdit)
{
return true;
}
if (dateEdit->isEnabled())
{
ShowPanel();
return true;
}
}
if (aObject->objectName() == QString("qt_scrollarea_viewport"))
{
QTextEdit* textEdit = qobject_cast<QTextEdit*>(aObject->parent());
if (!textEdit)
{
return false;
}
if (textEdit == mUI->textEdit)
{
return true;
}
if (textEdit->isEnabled())
{
ShowPanel();
return true;
}
}
if (aObject->inherits("QLineEdit"))
{
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(aObject);
//you have to tell whether it is coming from qdateedit!!!
if (mUI->lineEdit != lineEdit && lineEdit->isEnabled())
{
ShowPanel();
return true;
}
}
}
return QObject::eventFilter(aObject, aEvent);
}
void InputObject::ShowPanel()
{
if (!qApp->focusWidget())
if (!aInputWidget)
{
return;
}
if (qApp->focusWidget()->inherits("QLineEdit"))
if (aInputWidget->inherits("QLineEdit"))
{
mCurrentLineEdit = qobject_cast<QLineEdit*>(qApp->focusWidget());
mCurrentLineEdit = qobject_cast<QLineEdit*>(aInputWidget);
mUI->dateEdit->setVisible(false);
mUI->lineEdit->setVisible(true);
mUI->textEdit->setVisible(false);
}
if (qApp->focusWidget()->inherits("QDateEdit"))
else if (aInputWidget->inherits("QTextEdit"))
{
mCurrentDateEdit = qobject_cast<QDateEdit*>(qApp->focusWidget());
mUI->dateEdit->setVisible(true);
mUI->lineEdit->setVisible(false);
mUI->textEdit->setVisible(false);
}
if (qApp->focusWidget()->inherits("QTextEdit"))
{
mCurrentTextEdit = qobject_cast<QTextEdit*>(qApp->focusWidget());
mCurrentTextEdit = qobject_cast<QTextEdit*>(aInputWidget);
mUI->dateEdit->setVisible(false);
mUI->lineEdit->setVisible(false);
mUI->textEdit->setVisible(true);
@@ -179,7 +106,7 @@ void InputObject::ShowPanel()
activateWindow(); //it is quite important!!!
while (QApplication::activeWindow() != this)
{
qApp->processEvents();
QApplication::processEvents();
}
if (mCurrentLineEdit)
@@ -192,21 +119,7 @@ void InputObject::ShowPanel()
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(mUI->lineEdit, &event);
}
if (mCurrentDateEdit)
{
mUI->dateEdit->setDateTime(mCurrentDateEdit->dateTime());
mUI->dateEdit->setFocus();
while (QGuiApplication::focusObject() != mUI->dateEdit)
{
qApp->processEvents();
}
qDebug() << QGuiApplication::focusObject();
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(mUI->dateEdit, &event);
}
if (mCurrentTextEdit)
else if (mCurrentTextEdit)
{
mUI->textEdit->setPlainText(mCurrentTextEdit->toPlainText());
mUI->textEdit->setFocus();
@@ -219,7 +132,7 @@ void InputObject::ShowPanel()
}
}
void InputObject::HidePanel()
void KeyboardPanel::hidePanel()
{
if (mCurrentLineEdit)
{
@@ -228,13 +141,6 @@ void InputObject::HidePanel()
mUI->lineEdit->clear();
mCurrentLineEdit = nullptr;
}
else if (mCurrentDateEdit)
{
mCurrentDateEdit->setDateTime(mUI->dateEdit->dateTime());
mUI->dateEdit->clearFocus();
mUI->dateEdit->clear();
mCurrentDateEdit = nullptr;
}
else if (mCurrentTextEdit)
{
mCurrentTextEdit->setText(mUI->textEdit->toPlainText());

View File

@@ -0,0 +1,35 @@
#ifndef KEYBOARDPANEL_H
#define KEYBOARDPANEL_H
#include <QWidget>
class QLineEdit;
class QDateEdit;
class QTextEdit;
namespace Ui
{
class KeyboardPanel;
}
class KeyboardPanel : public QWidget
{
Q_OBJECT
public:
explicit KeyboardPanel(QWidget* aParent = nullptr);
~KeyboardPanel();
void showPanel(QWidget* aInputWidget);
void hidePanel();
private:
void initializeStyle();
void initUi();
private:
Ui::KeyboardPanel* mUI;
QLineEdit* mCurrentLineEdit;
QTextEdit* mCurrentTextEdit;
};
#endif // KEYBOARDPANEL_H

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>InputObject</class>
<widget class="QWidget" name="InputObject">
<class>KeyboardPanel</class>
<widget class="QWidget" name="KeyboardPanel">
<property name="geometry">
<rect>
<x>0</x>

View File

@@ -1,7 +1,6 @@
#include "windows/MainWindow.h"
#include <QApplication>
#include "UsctApplication.h"
#include "windows/LoginDialog.h"
#include "src/utilities/InputObject.h"
#include <QQmlApplicationEngine>
#include "db/SQLHelper.h"
#include <QTextCodec>
@@ -13,8 +12,10 @@
#include <QTranslator>
#include <src/device/DeviceManager.h>
#include "json/jsonobject.h"
#include "src/utilities/locker.h"
#include "src/utilities/languageswitcher.h"
#include "src/utilities/Locker.h"
#include "src/utilities/LanguageSwitcher.h"
#include "utilities/TouchScreenSignalSender.h"
QString loadFontFromFile(QString path)
{
static QString font;
@@ -41,7 +42,7 @@ int main(int argc, char* argv[])
//qputenv("QT_LOGGING_RULES", QByteArray("qt.virtualkeyboard=true"));
QApplication a(argc, argv);
UsctApplication a(argc, argv);
QString layouts_path = QString(QCoreApplication::applicationDirPath()).append("/layouts");
qputenv("QT_VIRTUALKEYBOARD_LAYOUT_PATH", QByteArray(layouts_path.toStdString().c_str()));
@@ -59,15 +60,13 @@ int main(int argc, char* argv[])
QFont font(fontName);
QApplication::setFont(font);
InputObject* obj = new InputObject();
a.installEventFilter(obj);
SQLHelper::Open();
MainWindow w;
UserOperationLog::Default()->init();
//暂时为了调试关闭锁屏
//Locker::Instance()->start();
//QObject::connect(obj, SIGNAL(touchScreen()), Locker::Instance(), SLOT(refreshTimer()));
//Locker::getInstance()->start();
//QObject::connect(TouchScreenSignalSender::getInstance(), SIGNAL(touchScreen()), Locker::getInstance(), SLOT(refreshTimer()));
QList<Qt::GestureType> gestures;
gestures << Qt::SwipeGesture;
gestures << Qt::PanGesture;

View File

@@ -70,13 +70,13 @@
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="1">
<widget class="QLineEdit" name="wl_IP"/>
<widget class="ULineEdit" name="wl_IP"/>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="wl_Port"/>
<widget class="ULineEdit" name="wl_Port"/>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="wl_AE"/>
<widget class="ULineEdit" name="wl_AE"/>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_3">
@@ -129,7 +129,7 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="wl_Name"/>
<widget class="ULineEdit" name="wl_Name"/>
</item>
<item row="6" column="2">
<widget class="QToolButton" name="toolButton_2">
@@ -157,10 +157,10 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1">
<widget class="QLineEdit" name="pacs_IP"/>
<widget class="ULineEdit" name="pacs_IP"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="pacs_AE"/>
<widget class="ULineEdit" name="pacs_AE"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Name_2">
@@ -190,7 +190,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="pacs_Port"/>
<widget class="ULineEdit" name="pacs_Port"/>
</item>
<item row="0" column="1">
<spacer name="verticalSpacer_2">
@@ -209,7 +209,7 @@
</spacer>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="pacs_Name"/>
<widget class="ULineEdit" name="pacs_Name"/>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_Port_2">
@@ -247,7 +247,7 @@
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="1">
<widget class="QLineEdit" name="recon_Name"/>
<widget class="ULineEdit" name="recon_Name"/>
</item>
<item row="1" column="1">
<spacer name="verticalSpacer">
@@ -280,7 +280,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="recon_IP"/>
<widget class="ULineEdit" name="recon_IP"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_Name_3">
@@ -296,7 +296,7 @@
</widget>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="recon_Port"/>
<widget class="ULineEdit" name="recon_Port"/>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_AE_3">
@@ -306,7 +306,7 @@
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="recon_AE"/>
<widget class="ULineEdit" name="recon_AE"/>
</item>
<item row="6" column="2">
<widget class="QToolButton" name="toolButton_3">
@@ -382,4 +382,11 @@
</hints>
</connection>
</connections>
<customwidgets>
<customwidget>
<class>ULineEdit</class>
<extends>QLineEdit</extends>
<header location="global">components/ULineEdit.h</header>
</customwidget>
</customwidgets>
</ui>

View File

@@ -5,7 +5,7 @@
#include <QFormLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "components/ULineEdit.h"
#ifndef WIN32
#include <src/device/networkmanager.h>
@@ -13,7 +13,7 @@
GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f)
: GUIFormBaseDialog(parent, f)
, mPsw(new QLineEdit(this))
, mPsw(new ULineEdit(this))
, mLabelError(new QLabel(this))
{
setWindowModality(Qt::WindowModal);

View File

@@ -7,7 +7,7 @@
#include "src/dialogs/GUIFormBaseDialog.h"
class QLineEdit;
class ULineEdit;
class QLabel;
class GetAdminPsw : public GUIFormBaseDialog
@@ -22,7 +22,7 @@ protected:
bool updateReferenceData();
private:
QLineEdit* mPsw = nullptr;
ULineEdit* mPsw = nullptr;
QLabel* mLabelError = nullptr;
};

View File

@@ -6,14 +6,14 @@
#include <QFormLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "components/ULineEdit.h"
#include "device/networkmanager.h"
GetIPDialog::GetIPDialog(QWidget* parent, Qt::WindowFlags f)
: GUIFormBaseDialog(parent, f)
, mIp(new QLineEdit(this))
, mMask(new QLineEdit(this))
, mIp(new ULineEdit(this))
, mMask(new ULineEdit(this))
, mLabelError(new QLabel(this))
{
setWindowModality(Qt::WindowModal);

View File

@@ -7,7 +7,7 @@
#include "src/dialogs/GUIFormBaseDialog.h"
class QLineEdit;
class ULineEdit;
class QLabel;
class GetIPDialog :public GUIFormBaseDialog
@@ -24,8 +24,8 @@ protected:
bool updateReferenceData();
private:
QLineEdit* mIp = nullptr;
QLineEdit* mMask = nullptr;
ULineEdit* mIp = nullptr;
ULineEdit* mMask = nullptr;
QLabel* mLabelError = nullptr;
};

View File

@@ -6,15 +6,15 @@
#include <QFormLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "components/ULineEdit.h"
#include "device/networkmanager.h"
GetRouteDialog::GetRouteDialog(QWidget* parent, Qt::WindowFlags f)
: GUIFormBaseDialog(parent, f)
, mDestination(new QLineEdit(this))
, mNetmask(new QLineEdit(this))
, mGateway(new QLineEdit(this))
, mDestination(new ULineEdit(this))
, mNetmask(new ULineEdit(this))
, mGateway(new ULineEdit(this))
, mLabelError(new QLabel(this))
{
setWindowModality(Qt::WindowModal);

View File

@@ -7,7 +7,7 @@
#include "src/dialogs/GUIFormBaseDialog.h"
class QLineEdit;
class ULineEdit;
class QLabel;
class GetRouteDialog :public GUIFormBaseDialog
@@ -24,9 +24,9 @@ protected:
bool updateReferenceData();
private:
QLineEdit* mDestination = nullptr;
QLineEdit* mNetmask = nullptr;
QLineEdit* mGateway = nullptr;
ULineEdit* mDestination = nullptr;
ULineEdit* mNetmask = nullptr;
ULineEdit* mGateway = nullptr;
QLabel* mLabelError = nullptr;
};

View File

@@ -37,7 +37,7 @@
background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #ABABAB, stop: 1.0 #CDCDCD);
}
QLineEdit#led_inface{font-size:15px;border: 0px;}
ULineEdit#led_inface{font-size:15px;border: 0px;}
</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
@@ -103,7 +103,7 @@
</spacer>
</item>
<item row="5" column="0">
<widget class="QLineEdit" name="addr_ip"/>
<widget class="ULineEdit" name="addr_ip"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
@@ -152,7 +152,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="led_inface">
<widget class="ULineEdit" name="led_inface">
<property name="enabled">
<bool>false</bool>
</property>
@@ -187,7 +187,7 @@
</widget>
</item>
<item row="5" column="1">
<widget class="QLineEdit" name="addr_mask"/>
<widget class="ULineEdit" name="addr_mask"/>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer_2">
@@ -301,7 +301,7 @@
<widget class="QWidget" name="widget_4" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="2">
<widget class="QLineEdit" name="led_gw">
<widget class="ULineEdit" name="led_gw">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -383,7 +383,7 @@
<number>9</number>
</property>
<item>
<widget class="SlideTableView" name="tbl_route">
<widget class="SlideTableView" name="tbl_route">
<property name="gridStyle">
<enum>Qt::DashLine</enum>
</property>
@@ -453,13 +453,13 @@
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="daq_AE"/>
<widget class="ULineEdit" name="daq_AE"/>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="daq_Name"/>
<widget class="ULineEdit" name="daq_Name"/>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="daq_Port"/>
<widget class="ULineEdit" name="daq_Port"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_Port">
@@ -482,7 +482,7 @@
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_AE">
<widget class="QLabel" name="lbl_AE">
<property name="text">
<string>AE</string>
</property>
@@ -496,7 +496,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="daq_IP">
<widget class="ULineEdit" name="daq_IP">
<property name="enabled">
<bool>false</bool>
</property>
@@ -563,6 +563,11 @@
<extends>QTableView</extends>
<header location="global">components/SlideTableView.h</header>
</customwidget>
<customwidget>
<class>ULineEdit</class>
<extends>QLineEdit</extends>
<header location="global">components/ULineEdit.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>

View File

@@ -1,37 +0,0 @@
#ifndef INPUTOBJECT_H
#define INPUTOBJECT_H
#include <QWidget>
class QLineEdit;
class QDateEdit;
class QTextEdit;
namespace Ui
{
class InputObject;
}
class InputObject : public QWidget
{
Q_OBJECT
public:
explicit InputObject(QWidget* aParent = nullptr);
~InputObject();
bool eventFilter(QObject* aObject, QEvent* aEvent);
signals:
void touchScreen();
private:
Ui::InputObject* mUI;
void initUi();
void ShowPanel();
void HidePanel();
QDateEdit* mCurrentDateEdit = nullptr;
QLineEdit* mCurrentLineEdit = nullptr;
QTextEdit* mCurrentTextEdit = nullptr;
};
#endif // INPUTOBJECT_H

View File

@@ -0,0 +1,20 @@
#include "TouchScreenSignalSender.h"
TouchScreenSignalSender* TouchScreenSignalSender::getInstance()
{
static TouchScreenSignalSender instance;
return &instance;
}
TouchScreenSignalSender::TouchScreenSignalSender()
{
}
TouchScreenSignalSender::~TouchScreenSignalSender()
{
}
void TouchScreenSignalSender::sendTouchScreenSignal()
{
emit touchScreen();
}

View File

@@ -0,0 +1,22 @@
#ifndef TOUCHSCREENSIGNALSENDER_H
#define TOUCHSCREENSIGNALSENDER_H
#include <QObject>
class TouchScreenSignalSender : public QObject
{
Q_OBJECT
public:
static TouchScreenSignalSender* getInstance();
void sendTouchScreenSignal();
signals:
void touchScreen();
private:
explicit TouchScreenSignalSender();
~TouchScreenSignalSender();
};
#endif // TOUCHSCREENSIGNALSENDER_H

View File

@@ -1,7 +1,6 @@
#include "LoginDialog.h"
#include <QVBoxLayout>
#include <QLineEdit>
#include <QToolButton>
#include <QFrame>
#include <QInputMethodEvent>
@@ -11,11 +10,11 @@
#include "guimacros.h"
#include "event/EventCenter.h"
#include "db/SQLHelper.h"
#include "utilities/InputObject.h"
#include "models/User.h"
#include "log/UserOperationLog.h"
#include "json/jsonobject.h"
#include "dialogs/guimessagedialog.h"
#include "components/ULineEdit.h"
LoginDialog::LoginDialog(QWidget* aParent)
: QDialog(aParent)
@@ -23,8 +22,8 @@ LoginDialog::LoginDialog(QWidget* aParent)
, mDialogTitle(new QLabel(this))
, mDialogFrame(new QFrame(this))
, mDialogContentsLayout(new QVBoxLayout(mDialogFrame))
, mAccountEdit(new QLineEdit(mDialogFrame))
, mPasswordEdit(new QLineEdit(mDialogFrame))
, mAccountEdit(new ULineEdit(mDialogFrame))
, mPasswordEdit(new ULineEdit(mDialogFrame))
, mLoginButton(nullptr)
, mErrorMessage(new QLabel(this))
{

View File

@@ -6,7 +6,7 @@
#include <QDialog>
class QVBoxLayout;
class QLineEdit;
class ULineEdit;
class QToolButton;
class QFrame;
class QLabel;
@@ -41,8 +41,8 @@ private:
QLabel* mDialogTitle;
QFrame* mDialogFrame;
QVBoxLayout* mDialogContentsLayout;
QLineEdit* mAccountEdit;
QLineEdit* mPasswordEdit;
ULineEdit* mAccountEdit;
ULineEdit* mPasswordEdit;
QToolButton* mLoginButton;
QLabel* mErrorMessage;
};

View File

@@ -3,7 +3,6 @@
#include <qtabwidget.h>
#include <QSizePolicy>
#include <QHBoxLayout>
#include <QTextEdit>
#include <QScrollBar>
#include <QDateTime>
#include <QGestureEvent>
@@ -24,6 +23,7 @@
#include "LoginDialog.h"
#include "models/User.h"
#include "appvals/AppGlobalValues.h"
#include "components/UTextEdit.h"
MainWindow::MainWindow(QWidget* aParent)
: QMainWindow(aParent)
@@ -256,8 +256,7 @@ void MainWindow::QMessageOutput(QtMsgType aType, const QMessageLogContext& aCont
MainWindow::~MainWindow()
{
mThread->quit();
mThread->wait();
mThread->terminate();
mThread->deleteLater();
delete mUI;
}
@@ -322,7 +321,7 @@ void MainWindow::debugConsoleOn()
mDebugConsoleWidget->setAllowedAreas(Qt::RightDockWidgetArea);
this->addDockWidget(static_cast<Qt::DockWidgetArea>(2), mDebugConsoleWidget);
mDebugMessageConsole = new QTextEdit(this);
mDebugMessageConsole = new UTextEdit(this);
mDebugMessageConsole->setFocusPolicy(Qt::NoFocus);
mDebugConsoleWidget->setWidget(mDebugMessageConsole);