diff --git a/src/EditPatientDialog.cpp b/src/EditPatientDialog.cpp index 4fb709b..30a1c30 100644 --- a/src/EditPatientDialog.cpp +++ b/src/EditPatientDialog.cpp @@ -4,8 +4,6 @@ #include #include #include -#include -#include #include #include #include @@ -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<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; + } } diff --git a/src/EditPatientDialog.h b/src/EditPatientDialog.h index d045df8..248e0b6 100644 --- a/src/EditPatientDialog.h +++ b/src/EditPatientDialog.h @@ -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; diff --git a/src/UsctApplication.cpp b/src/UsctApplication.cpp new file mode 100644 index 0000000..d412efd --- /dev/null +++ b/src/UsctApplication.cpp @@ -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); +} diff --git a/src/UsctApplication.h b/src/UsctApplication.h new file mode 100644 index 0000000..1a2caf2 --- /dev/null +++ b/src/UsctApplication.h @@ -0,0 +1,17 @@ +#ifndef USCTAPPLICATION_H +#define USCTAPPLICATION_H + +#include + +class UsctApplication : public QApplication +{ + Q_OBJECT +public: + UsctApplication(int& argc, char** argv); + ~UsctApplication(); + +private: + bool notify(QObject* aReceiver, QEvent* aEvent); +}; + +#endif // USCTAPPLICATION_H diff --git a/src/components/ULineEdit.cpp b/src/components/ULineEdit.cpp new file mode 100644 index 0000000..2bf799b --- /dev/null +++ b/src/components/ULineEdit.cpp @@ -0,0 +1,17 @@ +#include "ULineEdit.h" +#include +#include "keyboard/KeyboardManager.h" + +ULineEdit::ULineEdit(QWidget* aParent) + : QLineEdit(aParent) +{ +} + +ULineEdit::~ULineEdit() +{ +} + +void ULineEdit::mouseReleaseEvent(QMouseEvent* /*aEvent*/) +{ + KeyboardManager::getInstance()->showKeyboardPanel(this); +} diff --git a/src/components/ULineEdit.h b/src/components/ULineEdit.h new file mode 100644 index 0000000..0d2e207 --- /dev/null +++ b/src/components/ULineEdit.h @@ -0,0 +1,19 @@ +#ifndef ULINEEDIT_H +#define ULINEEDIT_H + +#include + +class ULineEdit : public QLineEdit +{ + Q_OBJECT + +public: + explicit ULineEdit(QWidget* aParent); + ~ULineEdit(); + +protected: + void mouseReleaseEvent(QMouseEvent* aEvent); + +}; + +#endif // ULINEEDIT_H diff --git a/src/components/UTextEdit.cpp b/src/components/UTextEdit.cpp new file mode 100644 index 0000000..ec8e889 --- /dev/null +++ b/src/components/UTextEdit.cpp @@ -0,0 +1,17 @@ +#include "UTextEdit.h" +#include +#include "keyboard/KeyboardManager.h" + +UTextEdit::UTextEdit(QWidget* aParent) + : QTextEdit(aParent) +{ +} + +UTextEdit::~UTextEdit() +{ +} + +void UTextEdit::mouseReleaseEvent(QMouseEvent* /*aEvent*/) +{ + KeyboardManager::getInstance()->showKeyboardPanel(this); +} diff --git a/src/components/UTextEdit.h b/src/components/UTextEdit.h new file mode 100644 index 0000000..fa4b221 --- /dev/null +++ b/src/components/UTextEdit.h @@ -0,0 +1,19 @@ +#ifndef UTEXTEDIT_H +#define UTEXTEDIT_H + +#include + +class UTextEdit : public QTextEdit +{ + Q_OBJECT + +public: + explicit UTextEdit(QWidget* aParent); + ~UTextEdit(); + +protected: + void mouseReleaseEvent(QMouseEvent* aEvent); + +}; + +#endif // UTEXTEDIT_H diff --git a/src/dialogs/AccountFormDialog.cpp b/src/dialogs/AccountFormDialog.cpp index 76c0c8c..6019e3d 100644 --- a/src/dialogs/AccountFormDialog.cpp +++ b/src/dialogs/AccountFormDialog.cpp @@ -9,27 +9,27 @@ #include #include #include -#include #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& values) { - mLeUserCode->setText(values["UserCode"].toString()); - mLeUserName->setText(values["UserName"].toString()); - mLeComment->setText(values["Comment"].toString()); +void AccountFormDialog::setAccountInformation(const QMap& 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); } diff --git a/src/dialogs/AccountFormDialog.h b/src/dialogs/AccountFormDialog.h index fdcd0f6..713fa72 100644 --- a/src/dialogs/AccountFormDialog.h +++ b/src/dialogs/AccountFormDialog.h @@ -5,23 +5,24 @@ #ifndef GUI_ACCOUNTFORMDIALOG_H #define GUI_ACCOUNTFORMDIALOG_H class QLabel; -class QLineEdit; +class ULineEdit; class QToolButton; class QSqlTableModel; #include #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& values); - void setReferenceModel(QSqlTableModel* model){ + void setAccountInformation(const QMap& 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; diff --git a/src/dialogs/ChangePasswordFormDialog.cpp b/src/dialogs/ChangePasswordFormDialog.cpp index d33efb8..345bb3f 100644 --- a/src/dialogs/ChangePasswordFormDialog.cpp +++ b/src/dialogs/ChangePasswordFormDialog.cpp @@ -4,22 +4,23 @@ #include #include -#include +#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; } diff --git a/src/dialogs/ChangePasswordFormDialog.h b/src/dialogs/ChangePasswordFormDialog.h index a385ccd..6b2e300 100644 --- a/src/dialogs/ChangePasswordFormDialog.h +++ b/src/dialogs/ChangePasswordFormDialog.h @@ -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; diff --git a/src/forms/select/editpatientform.ui b/src/forms/select/editpatientform.ui index 467d2b8..a0e2db4 100644 --- a/src/forms/select/editpatientform.ui +++ b/src/forms/select/editpatientform.ui @@ -1,140 +1,152 @@ - EditPatientForm - - - - 0 - 0 - 400 - 466 - - - - Form - - - - - - ... - - - - - - - ID - - - - - - - true - - - true - - - - - - - Name - - - - - - - true - - - true - - - - - - - Gender - - - - - - - true - - - true - - - - - - - Date Of Birth - - - - - - - true - - - true - - - QAbstractSpinBox::NoButtons - - - - - - - - 1 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - Comment - - - - - - - true - - - true - - - - - - - - - - + EditPatientForm + + + + 0 + 0 + 400 + 466 + + + + Form + + + + + + ... + + + + + + + ID + + + + + + + true + + + true + + + + + + + Name + + + + + + + true + + + true + + + + + + + Gender + + + + + + + true + + + true + + + + + + + Date Of Birth + + + + + + + true + + + true + + + QAbstractSpinBox::NoButtons + + + + + + + + 1 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + Comment + + + + + + + true + + + true + + + + + + + + + + + ULineEdit + QLineEdit +
components/ULineEdit.h
+
+ + UTextEdit + QTextEdit +
components/UTextEdit.h
+
+
+ +
diff --git a/src/forms/settings/generalform.cpp b/src/forms/settings/generalform.cpp index 5ee43b0..2041c41 100644 --- a/src/forms/settings/generalform.cpp +++ b/src/forms/settings/generalform.cpp @@ -6,14 +6,13 @@ #include #include #include -#include #include #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); diff --git a/src/forms/settings/systemsettingform.cpp b/src/forms/settings/systemsettingform.cpp index 0f88a75..8b85e5c 100644 --- a/src/forms/settings/systemsettingform.cpp +++ b/src/forms/settings/systemsettingform.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include diff --git a/src/forms/settings/systemsettingform.h b/src/forms/settings/systemsettingform.h index beb4053..2aa824f 100644 --- a/src/forms/settings/systemsettingform.h +++ b/src/forms/settings/systemsettingform.h @@ -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 diff --git a/src/keyboard/KeyboardManager.cpp b/src/keyboard/KeyboardManager.cpp new file mode 100644 index 0000000..29e3d4c --- /dev/null +++ b/src/keyboard/KeyboardManager.cpp @@ -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); +} diff --git a/src/keyboard/KeyboardManager.h b/src/keyboard/KeyboardManager.h new file mode 100644 index 0000000..c8e5da6 --- /dev/null +++ b/src/keyboard/KeyboardManager.h @@ -0,0 +1,27 @@ +#ifndef KEYBOARDMANAGER_H +#define KEYBOARDMANAGER_H + +#include +#include + +class KeyboardPanel; +typedef std::shared_ptr 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 \ No newline at end of file diff --git a/src/utilities/InputObject.cpp b/src/keyboard/KeyboardPanel.cpp similarity index 50% rename from src/utilities/InputObject.cpp rename to src/keyboard/KeyboardPanel.cpp index 8c777ab..3d093d2 100644 --- a/src/utilities/InputObject.cpp +++ b/src/keyboard/KeyboardPanel.cpp @@ -1,37 +1,35 @@ -#include "InputObject.h" -#include "ui_InputObject.h" +#include "KeyboardPanel.h" +#include "ui_KeyboardPanel.h" -#include #include #include #include #include -#include #include #include #include -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(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(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(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(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(qApp->focusWidget()); + mCurrentLineEdit = qobject_cast(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(qApp->focusWidget()); - mUI->dateEdit->setVisible(true); - mUI->lineEdit->setVisible(false); - mUI->textEdit->setVisible(false); - } - - if (qApp->focusWidget()->inherits("QTextEdit")) - { - mCurrentTextEdit = qobject_cast(qApp->focusWidget()); + mCurrentTextEdit = qobject_cast(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()); diff --git a/src/keyboard/KeyboardPanel.h b/src/keyboard/KeyboardPanel.h new file mode 100644 index 0000000..80ac0b3 --- /dev/null +++ b/src/keyboard/KeyboardPanel.h @@ -0,0 +1,35 @@ +#ifndef KEYBOARDPANEL_H +#define KEYBOARDPANEL_H + +#include + +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 diff --git a/src/utilities/InputObject.ui b/src/keyboard/KeyboardPanel.ui similarity index 98% rename from src/utilities/InputObject.ui rename to src/keyboard/KeyboardPanel.ui index 5063f68..62feaef 100644 --- a/src/utilities/InputObject.ui +++ b/src/keyboard/KeyboardPanel.ui @@ -1,7 +1,7 @@ - InputObject - + KeyboardPanel + 0 diff --git a/src/main.cpp b/src/main.cpp index 38cc07b..8996c00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,6 @@ #include "windows/MainWindow.h" -#include +#include "UsctApplication.h" #include "windows/LoginDialog.h" -#include "src/utilities/InputObject.h" #include #include "db/SQLHelper.h" #include @@ -13,8 +12,10 @@ #include #include #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 gestures; gestures << Qt::SwipeGesture; gestures << Qt::PanGesture; diff --git a/src/network/DicomCfgDialog.ui b/src/network/DicomCfgDialog.ui index 95155aa..5f6970d 100644 --- a/src/network/DicomCfgDialog.ui +++ b/src/network/DicomCfgDialog.ui @@ -70,13 +70,13 @@ - + - + - + @@ -129,7 +129,7 @@ - + @@ -157,10 +157,10 @@ - + - + @@ -190,7 +190,7 @@ - + @@ -209,7 +209,7 @@ - + @@ -247,7 +247,7 @@ - + @@ -280,7 +280,7 @@ - + @@ -296,7 +296,7 @@ - + @@ -306,7 +306,7 @@ - + @@ -382,4 +382,11 @@ + + + ULineEdit + QLineEdit +
components/ULineEdit.h
+
+
diff --git a/src/network/GetAdminPsw.cpp b/src/network/GetAdminPsw.cpp index 12acfaf..b046a1e 100644 --- a/src/network/GetAdminPsw.cpp +++ b/src/network/GetAdminPsw.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include "components/ULineEdit.h" #ifndef WIN32 #include @@ -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); diff --git a/src/network/GetAdminPsw.h b/src/network/GetAdminPsw.h index cabe6f7..5f2310c 100644 --- a/src/network/GetAdminPsw.h +++ b/src/network/GetAdminPsw.h @@ -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; }; diff --git a/src/network/GetIPDialog.cpp b/src/network/GetIPDialog.cpp index 925f8a3..d467d26 100644 --- a/src/network/GetIPDialog.cpp +++ b/src/network/GetIPDialog.cpp @@ -6,14 +6,14 @@ #include #include -#include +#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); diff --git a/src/network/GetIPDialog.h b/src/network/GetIPDialog.h index 5750ee2..39acda5 100644 --- a/src/network/GetIPDialog.h +++ b/src/network/GetIPDialog.h @@ -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; }; diff --git a/src/network/GetRouteDialog.cpp b/src/network/GetRouteDialog.cpp index 80663ae..8071494 100644 --- a/src/network/GetRouteDialog.cpp +++ b/src/network/GetRouteDialog.cpp @@ -6,15 +6,15 @@ #include #include -#include +#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); diff --git a/src/network/GetRouteDialog.h b/src/network/GetRouteDialog.h index 39168c7..20618e0 100644 --- a/src/network/GetRouteDialog.h +++ b/src/network/GetRouteDialog.h @@ -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; }; diff --git a/src/network/NetworkCfgDialog.ui b/src/network/NetworkCfgDialog.ui index 1136e65..ec3e418 100644 --- a/src/network/NetworkCfgDialog.ui +++ b/src/network/NetworkCfgDialog.ui @@ -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;} @@ -103,7 +103,7 @@ - + @@ -152,7 +152,7 @@ - + false @@ -187,7 +187,7 @@ - + @@ -301,7 +301,7 @@ - + 0 @@ -383,7 +383,7 @@ 9 - + Qt::DashLine @@ -453,13 +453,13 @@ - + - + - + @@ -482,7 +482,7 @@ - + AE @@ -496,7 +496,7 @@ - + false @@ -563,6 +563,11 @@ QTableView
components/SlideTableView.h
+ + ULineEdit + QLineEdit +
components/ULineEdit.h
+
diff --git a/src/utilities/InputObject.h b/src/utilities/InputObject.h deleted file mode 100644 index a2096dc..0000000 --- a/src/utilities/InputObject.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef INPUTOBJECT_H -#define INPUTOBJECT_H - -#include - -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 diff --git a/src/utilities/TouchScreenSignalSender.cpp b/src/utilities/TouchScreenSignalSender.cpp new file mode 100644 index 0000000..0c0a291 --- /dev/null +++ b/src/utilities/TouchScreenSignalSender.cpp @@ -0,0 +1,20 @@ +#include "TouchScreenSignalSender.h" + +TouchScreenSignalSender* TouchScreenSignalSender::getInstance() +{ + static TouchScreenSignalSender instance; + return &instance; +} + +TouchScreenSignalSender::TouchScreenSignalSender() +{ +} + +TouchScreenSignalSender::~TouchScreenSignalSender() +{ +} + +void TouchScreenSignalSender::sendTouchScreenSignal() +{ + emit touchScreen(); +} diff --git a/src/utilities/TouchScreenSignalSender.h b/src/utilities/TouchScreenSignalSender.h new file mode 100644 index 0000000..aa35a13 --- /dev/null +++ b/src/utilities/TouchScreenSignalSender.h @@ -0,0 +1,22 @@ +#ifndef TOUCHSCREENSIGNALSENDER_H +#define TOUCHSCREENSIGNALSENDER_H + +#include + +class TouchScreenSignalSender : public QObject +{ + Q_OBJECT +public: + static TouchScreenSignalSender* getInstance(); + void sendTouchScreenSignal(); + +signals: + void touchScreen(); + + +private: + explicit TouchScreenSignalSender(); + ~TouchScreenSignalSender(); +}; + +#endif // TOUCHSCREENSIGNALSENDER_H diff --git a/src/windows/LoginDialog.cpp b/src/windows/LoginDialog.cpp index 780b36c..3e7c6ba 100644 --- a/src/windows/LoginDialog.cpp +++ b/src/windows/LoginDialog.cpp @@ -1,7 +1,6 @@ #include "LoginDialog.h" #include -#include #include #include #include @@ -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)) { diff --git a/src/windows/LoginDialog.h b/src/windows/LoginDialog.h index 809ee6e..fa49d2e 100644 --- a/src/windows/LoginDialog.h +++ b/src/windows/LoginDialog.h @@ -6,7 +6,7 @@ #include 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; }; diff --git a/src/windows/MainWindow.cpp b/src/windows/MainWindow.cpp index e6ec3cd..7de9fff 100644 --- a/src/windows/MainWindow.cpp +++ b/src/windows/MainWindow.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -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(2), mDebugConsoleWidget); - mDebugMessageConsole = new QTextEdit(this); + mDebugMessageConsole = new UTextEdit(this); mDebugMessageConsole->setFocusPolicy(Qt::NoFocus); mDebugConsoleWidget->setWidget(mDebugMessageConsole);