Merge remote-tracking branch 'origin/master'

This commit is contained in:
Krad
2021-12-23 13:19:14 +08:00
31 changed files with 637 additions and 5154 deletions

2
.gitignore vendored
View File

@@ -9,3 +9,5 @@
/out/
/.vs/
/CMakeSettings.json
/src/translations/*.ts
*.ts

View File

@@ -35,6 +35,23 @@ file(GLOB project_uis ./src/*.ui)
qt5_wrap_ui(ui_FILES ${project_uis})
file(GLOB project_res ./src/*.qrc)
#ADD_SUBDIRECTORY(./src/translations)
#set(TS_FILES
# ./src/translations/en_US.ts
# ./src/translations/zh_CN.ts)
#find_package(Qt5 COMPONENTS ${REQUIRED_LIBS} LinguistTools REQUIRED)
#qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
#add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${project_c} ${ui_FILES} ${QM_FILES} )
#file(GLOB TS_FILES ./src/translations/*.ts)
SET_DIRECTORY_PROPERTIES(PROPERTIES CLEAN_NO_CUSTOM TRUE)
#file(GLOB TS_FILES ./src/translations/*.ts)
set(TS_FILES
./src/translations/en_US.ts
./src/translations/zh_CN.ts)
find_package(Qt5 COMPONENTS ${REQUIRED_LIBS} LinguistTools REQUIRED)
qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
set(TS_FILES
src/translations/en_US.ts
src/translations/zh_CN.ts)
@@ -60,6 +77,7 @@ foreach(_file ${TS_FILES})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${POWERSHELL_PATH} " cp -Force" ${_rfile} ${backup})
endforeach()
add_executable(${PROJECT_NAME} ${project_headers} ${project_cpps} ${project_cxx} ${project_res} ${project_cc} ${project_c} ${ui_FILES} ${QM_FILES} )
if(UNIX AND USE_SHIMLIB)
link_directories(/usr/local/lib64)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Gui Qt5::OpenGL Qt5::Sql Qt5::VirtualKeyboard Qt5::Network pthread usct_shim dmapi log4c cunit ctomat hdf5 matio m)

View File

@@ -10,181 +10,181 @@
#include <QToolButton>
#include <QPushButton>
#include <QLineEdit>
#include <src/event/EventCenter.h>
#include <src/log/UserOperationLog.h>
#include "event/EventCenter.h"
#include "log/UserOperationLog.h"
#include "db/SQLHelper.h"
#include "models/User.h"
#include "components/SlidePickerBox.h"
#include "SelectDialog.h"
#include "AlertDialog.h"
AccountFormDialog::AccountFormDialog(QWidget *parent,AccountEditMode mode, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
m_mode = mode;
QVBoxLayout* layout = new QVBoxLayout(formWidget);
layout->setSpacing(10);
// add title
QLabel* lbl_title = new QLabel(this);
lbl_title->setAlignment(Qt::AlignCenter);
lbl_title->setText(tr("Account"));
lbl_title->setObjectName("title");
layout->addWidget(lbl_title);
AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
m_mode = mode;
QVBoxLayout* layout = new QVBoxLayout(formWidget);
layout->setSpacing(10);
// add title
QLabel* lbl_title = new QLabel(this);
lbl_title->setAlignment(Qt::AlignCenter);
lbl_title->setText(tr("Account"));
lbl_title->setObjectName("title");
layout->addWidget(lbl_title);
//add usercode
QLabel* lbl_UserCode = new QLabel(this);
lbl_UserCode->setText(tr("User ID"));
le_UserCode = new QLineEdit(this);
le_UserCode->setPlaceholderText(tr("Input User ID"));
if(m_mode != New)le_UserCode->setEnabled(false);
layout->addWidget(lbl_UserCode);
layout->addWidget(le_UserCode);
QLabel* lbl_endline1 = new QLabel(this);
lbl_endline1->setObjectName("endline");
layout->addWidget(lbl_endline1);
//add usercode
QLabel* lbl_UserCode = new QLabel(this);
lbl_UserCode->setText(tr("User ID"));
le_UserCode = new QLineEdit(this);
le_UserCode->setPlaceholderText(tr("Input User ID"));
if (m_mode != New)le_UserCode->setEnabled(false);
layout->addWidget(lbl_UserCode);
layout->addWidget(le_UserCode);
QLabel* lbl_endline1 = new QLabel(this);
lbl_endline1->setObjectName("endline");
layout->addWidget(lbl_endline1);
//add username
QLabel* lbl_UserName = new QLabel(this);
lbl_UserName->setText(tr("Name"));
le_UserName = new QLineEdit(this);
le_UserName->setPlaceholderText(tr("Input User name"));
layout->addWidget(lbl_UserName);
layout->addWidget(le_UserName);
QLabel* lbl_endline2 = new QLabel(this);
lbl_endline2->setObjectName("endline");
layout->addWidget(lbl_endline2);
//add username
QLabel* lbl_UserName = new QLabel(this);
lbl_UserName->setText(tr("Name"));
le_UserName = new QLineEdit(this);
le_UserName->setPlaceholderText(tr("Input User name"));
layout->addWidget(lbl_UserName);
layout->addWidget(le_UserName);
QLabel* lbl_endline2 = new QLabel(this);
lbl_endline2->setObjectName("endline");
layout->addWidget(lbl_endline2);
//add password
QLabel* lbl_Pwd = new QLabel(this);
lbl_Pwd->setText(tr("Password"));
layout->addWidget(lbl_Pwd);
//add password
QLabel* lbl_Pwd = new QLabel(this);
lbl_Pwd->setText(tr("Password"));
layout->addWidget(lbl_Pwd);
// add new mode
if (m_mode == New)
{
le_Pwd = new QLineEdit(this);
le_Pwd->setPlaceholderText(tr("Input password"));
le_Pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(le_Pwd);
} else{//edit mode
btn_Pwd = new QPushButton(this);
btn_Pwd->setText(tr(m_mode==Self?"Change Password":"Reset Password"));
layout->addWidget(btn_Pwd);
}
QLabel* lbl_endline3 = new QLabel(this);
lbl_endline3->setObjectName("endline");
layout->addWidget(lbl_endline3);
// add new mode
if (m_mode == New)
{
le_Pwd = new QLineEdit(this);
le_Pwd->setPlaceholderText(tr("Input password"));
le_Pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(le_Pwd);
}
else {//edit mode
btn_Pwd = new QPushButton(this);
btn_Pwd->setText(tr(m_mode == Self ? "Change Password" : "Reset Password"));
layout->addWidget(btn_Pwd);
}
QLabel* lbl_endline3 = new QLabel(this);
lbl_endline3->setObjectName("endline");
layout->addWidget(lbl_endline3);
if (m_mode == Self)
{
//add logout
QLabel* lbl_Logout = new QLabel(this);
lbl_Logout->setText(tr("Logout"));
QPushButton* btn_Logout= new QPushButton(this);
btn_Logout->setText(tr("Logout"));
layout->addWidget(lbl_Logout);
layout->addWidget(btn_Logout);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
// load current user data
if (User::Current())
{
le_UserCode->setText(User::Current()->getUserCode());
le_UserName->setText(User::Current()->getUserName());
m_UserID = User::Current()->getUserID();
m_UserPwd = User::Current()->getPassword();
}
connect(btn_Pwd, &QPushButton::clicked,[t=this](){
ChangePasswordFormDialog dia(t->parentWidget());
dia.setWindowModality(Qt::WindowModal);
dia.exec();
});
connect(btn_Logout, &QAbstractButton::clicked, [=](){
this->accept();
LOG_USER_OPERATION(Logout);
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
});
}
else
{
//add change role
QLabel* lbl_Role = new QLabel(this);
lbl_Role->setText(tr("Change Role"));
btn_Role= new QPushButton(this);
layout->addWidget(lbl_Role);
layout->addWidget(btn_Role);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
//set default value
if (m_mode == New) {
btn_Role->setText("doctor");
m_RoleID = User::getRoleID("doctor");
}
else{
connect(btn_Pwd,&QAbstractButton::clicked,[=](){
AlertDialog dialog(this);
dialog.setButtonMode(OkAndCancel);
dialog.setWindowModality(Qt::WindowModal);
dialog.setAlertMessage(tr("Reset password to \"123456\" ?"));
if (dialog.exec() == Accepted)
{
User user;
dialog.setButtonMode(OkOnly);
if (!User::getUser(m_UserID, user)) {
dialog.setAlertMessage(tr("Inner error, can't find reference user!"));
dialog.exec();
return;
}
if (!user.resetPassword())
{
dialog.setAlertMessage(tr("Submit change to database fail!"));
dialog.exec();
}
}
});
}
connect(btn_Role,&QAbstractButton::clicked,[=](){
SelectDialog selectDialog(this);
selectDialog.setAvailableDates(User::getAllRoleName());
selectDialog.setSelectedValue(btn_Role->text());
selectDialog.setWindowModality(Qt::WindowModal);
// submit change
if (selectDialog.exec() == Accepted)
{
if (selectDialog.getSelectedValue() != btn_Role->text())
{
QString newRoleID = User::getRoleID(selectDialog.getSelectedValue());
btn_Role->setText(selectDialog.getSelectedValue());
m_RoleID = newRoleID;
qDebug()<<"new Role ID:"<<newRoleID;
this->roleChanged = true;
}
}
});
}
if (m_mode == Self)
{
//add logout
QLabel* lbl_Logout = new QLabel(this);
lbl_Logout->setText(tr("Logout"));
QPushButton* btn_Logout = new QPushButton(this);
btn_Logout->setText(tr("Logout"));
layout->addWidget(lbl_Logout);
layout->addWidget(btn_Logout);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
// load current user data
if (User::Current())
{
le_UserCode->setText(User::Current()->getUserCode());
le_UserName->setText(User::Current()->getUserName());
m_UserID = User::Current()->getUserID();
m_UserPwd = User::Current()->getPassword();
}
connect(btn_Pwd, &QPushButton::clicked, [t = this]() {
ChangePasswordFormDialog dia(t->parentWidget());
dia.setWindowModality(Qt::WindowModal);
dia.exec();
});
connect(btn_Logout, &QAbstractButton::clicked, [=]() {
this->accept();
LOG_USER_OPERATION(Logout);
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
});
}
else
{
//add change role
QLabel* lbl_Role = new QLabel(this);
lbl_Role->setText(tr("Change Role"));
btn_Role = new QPushButton(this);
layout->addWidget(lbl_Role);
layout->addWidget(btn_Role);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
//set default value
if (m_mode == New) {
btn_Role->setText(tr("doctor"));
m_RoleID = User::getRoleID("doctor");
}
else {
connect(btn_Pwd, &QAbstractButton::clicked, [=]() {
AlertDialog dialog(this);
dialog.setButtonMode(OkAndCancel);
dialog.setWindowModality(Qt::WindowModal);
dialog.setAlertMessage(tr("Reset password to \"123456\" ?"));
if (dialog.exec() == Accepted)
{
User user;
dialog.setButtonMode(OkOnly);
if (!User::getUser(m_UserID, user)) {
dialog.setAlertMessage(tr("Inner error, can't find reference user!"));
dialog.exec();
return;
}
if (!user.resetPassword())
{
dialog.setAlertMessage(tr("Submit change to database fail!"));
dialog.exec();
}
}
});
}
connect(btn_Role, &QAbstractButton::clicked, [=]() {
SelectDialog selectDialog(this);
selectDialog.setAvailableDates(User::getAllRoleName());
selectDialog.setSelectedValue(btn_Role->text());
selectDialog.setWindowModality(Qt::WindowModal);
// submit change
if (selectDialog.exec() == Accepted)
{
if (selectDialog.getSelectedValue() != btn_Role->text())
{
QString newRoleID = User::getRoleID(selectDialog.getSelectedValue());
btn_Role->setText(selectDialog.getSelectedValue());
m_RoleID = newRoleID;
qDebug() << "new Role ID:" << newRoleID;
this->roleChanged = true;
}
}
});
}
//add Comment
QLabel* lbl_Comment = new QLabel(this);
lbl_Comment->setText(tr("Comment"));
le_Comment = new QLineEdit(this);
layout->addWidget(lbl_Comment);
layout->addWidget(le_Comment);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setVisible(false);
layout->addWidget(lbl_error);
connect(le_Comment, &QLineEdit::textChanged, [=](const QString& text){
commentChanged = true;
});
connect(le_UserName, &QLineEdit::textChanged, [=](const QString& text){
m_NewUserName = text;
userNameChanged = true;
});
//add Comment
QLabel* lbl_Comment = new QLabel(this);
lbl_Comment->setText(tr("Comment"));
le_Comment = new QLineEdit(this);
layout->addWidget(lbl_Comment);
layout->addWidget(le_Comment);
QLabel* lbl_endline0 = new QLabel(this);
lbl_endline0->setObjectName("endline");
layout->addWidget(lbl_endline0);
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setVisible(false);
layout->addWidget(lbl_error);
connect(le_Comment, &QLineEdit::textChanged, [=](const QString& text) {
commentChanged = true;
});
connect(le_UserName, &QLineEdit::textChanged, [=](const QString& text) {
m_NewUserName = text;
userNameChanged = true;
});
}
AccountFormDialog::~AccountFormDialog() {
@@ -192,122 +192,125 @@ AccountFormDialog::~AccountFormDialog() {
}
bool AccountFormDialog::updateReferenceData() {
if (m_mode == Self) {
if (!this->userNameChanged && !this->commentChanged) return true;
if (!this->userNameChanged) {
if (m_NewUserName.isEmpty()){
warn(tr("User Name can't be empty!"));
return false;
}
User::Current()->setUserName(m_NewUserName);
}
if (!this->commentChanged) User::Current()->setUserName(le_Comment->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 (m_mode == Admin){
if (!this->userNameChanged && !this->roleChanged) return true;
User user;
if (!User::getUser(m_UserID, user)) return true;
if (this->userNameChanged){
if (m_NewUserName.isEmpty()){
warn(tr("User Name can't be empty!"));
return false;
}
user.setUserName(m_NewUserName);
}
if (this->roleChanged) user.setRoleID(m_RoleID);
if (!this->commentChanged) user.setComment(le_Comment->text());
bool ret = user.submitChange();
if (ret) {
LOG_USER_OPERATION(AdminChangeAcountInformation);
}
return ret;
} else {
//add new
User user;
if (le_UserCode->text().isEmpty()) {
warn(tr("User ID can't be empty!"));
return false;
}
if (le_UserName->text().isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
if (le_Pwd->text().isEmpty()) {
warn(tr("Password can't be empty!"));
return false;
}
if (!refmodel){
warn(tr("Inner error ,unset data model!"));
return false;
}
if (User::existsUser(le_UserCode->text())){
warn(tr("User Id exists!"));
return false;
}
hideWarn();
user.setUserName(le_UserName->text());
user.setPassword(User::getEncryptedPassword(le_Pwd->text()));
user.setRoleID(m_RoleID);
user.setComment(le_Comment->text());
// User::insertUser(le_UserCode->text(),user);
if (m_mode == Self) {
if (!this->userNameChanged && !this->commentChanged) return true;
if (!this->userNameChanged) {
if (m_NewUserName.isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
User::Current()->setUserName(m_NewUserName);
}
if (!this->commentChanged) User::Current()->setUserName(le_Comment->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 (m_mode == Admin) {
if (!this->userNameChanged && !this->roleChanged) return true;
User user;
if (!User::getUser(m_UserID, user)) return true;
if (this->userNameChanged) {
if (m_NewUserName.isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
user.setUserName(m_NewUserName);
}
if (this->roleChanged) user.setRoleID(m_RoleID);
if (!this->commentChanged) user.setComment(le_Comment->text());
bool ret = user.submitChange();
if (ret) {
LOG_USER_OPERATION(AdminChangeAcountInformation);
}
return ret;
}
else {
//add new
User user;
if (le_UserCode->text().isEmpty()) {
warn(tr("User ID can't be empty!"));
return false;
}
if (le_UserName->text().isEmpty()) {
warn(tr("User Name can't be empty!"));
return false;
}
if (le_Pwd->text().isEmpty()) {
warn(tr("Password can't be empty!"));
return false;
}
if (!refmodel) {
warn(tr("Inner error ,unset data model!"));
return false;
}
if (User::existsUser(le_UserCode->text())) {
warn(tr("User Id exists!"));
return false;
}
hideWarn();
user.setUserName(le_UserName->text());
user.setPassword(User::getEncryptedPassword(le_Pwd->text()));
user.setRoleID(m_RoleID);
user.setComment(le_Comment->text());
// User::insertUser(le_UserCode->text(),user);
refmodel->insertRow(0);
refmodel->setData(refmodel->index(0, 0), QUuid::createUuid().toString());
refmodel->setData(refmodel->index(0, 1), le_UserCode->text());
#define USER_READONLY_PROPERTY(name) name,
#define USER_PROPERTY(name)\
refmodel->insertRow(0);
refmodel->setData(refmodel->index(0, 0), QUuid::createUuid().toString());
refmodel->setData(refmodel->index(0, 1), le_UserCode->text());
#define USER_READONLY_PROPERTY(name) name,
#define USER_PROPERTY(name)\
USER_READONLY_PROPERTY(name)
enum user_index {
USER_PROPERTIES_MACRO()
};
#undef USER_READONLY_PROPERTY
#undef USER_PROPERTY
enum user_index {
USER_PROPERTIES_MACRO()
};
#undef USER_READONLY_PROPERTY
#undef USER_PROPERTY
#define USER_READONLY_PROPERTY(name)
#define USER_PROPERTY(name)\
#define USER_READONLY_PROPERTY(name)
#define USER_PROPERTY(name)\
USER_READONLY_PROPERTY(name)\
refmodel->setData(refmodel->index(0, name),user.get##name());
USER_PROPERTIES_MACRO()
#undef USER_READONLY_PROPERTY
#undef USER_PROPERTY
USER_PROPERTIES_MACRO()
#undef USER_READONLY_PROPERTY
#undef USER_PROPERTY
if (refmodel->submit()) {
hideWarn();
return true;
} else {
warn(tr("Submit to data base fail!"));
return false;
}
}
return true;
if (refmodel->submit()) {
hideWarn();
return true;
}
else {
warn(tr("Submit to data base fail!"));
return false;
}
}
return true;
}
void AccountFormDialog::setAccountInformation(const QMap<QString, QVariant> & values) {
le_UserCode->setText(values["UserCode"].toString());
le_UserName->setText(values["UserName"].toString());
le_Comment->setText(values["Comment"].toString());
m_UserID = values["UserID"].toString();
m_UserPwd = values["Password"].toString();
if (btn_Role){
m_RoleID = values["RoleID"].toString();
btn_Role->setText(User::getRoleName(m_RoleID));
}
void AccountFormDialog::setAccountInformation(const QMap<QString, QVariant>& values) {
le_UserCode->setText(values["UserCode"].toString());
le_UserName->setText(values["UserName"].toString());
le_Comment->setText(values["Comment"].toString());
m_UserID = values["UserID"].toString();
m_UserPwd = values["Password"].toString();
if (btn_Role) {
m_RoleID = values["RoleID"].toString();
btn_Role->setText(User::getRoleName(m_RoleID));
}
}
void AccountFormDialog::warn(QString msg) {
lbl_error->setText(msg);
lbl_error->setVisible(true);
lbl_error->setText(msg);
lbl_error->setVisible(true);
}
void AccountFormDialog::hideWarn() {
this->lbl_error->setVisible(false);
this->lbl_error->setVisible(false);
}

View File

@@ -7,7 +7,7 @@
#include <QHBoxLayout>
#include <QToolButton>
#include <QHeaderView>
#include <src/components/AccountRoleComboDelegate.h>
#include "components/AccountRoleComboDelegate.h"
#include "guimacros.h"
#include "AlertDialog.h"
#include "db/SQLHelper.h"

View File

@@ -5,8 +5,8 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include <src/models/User.h>
#include <src/log/UserOperationLog.h>
#include "models/User.h"
#include "log/UserOperationLog.h"
#include "ChangePasswordFormDialog.h"
ChangePasswordFormDialog::ChangePasswordFormDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {

View File

@@ -6,35 +6,35 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QPushButton>
GUIFormBaseDialog::GUIFormBaseDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) {
this->setObjectName("formDialog");
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
// this->setFixedSize(500,600);
this->setFixedWidth(500);
this->formWidget = new QWidget(this);
this->formWidget->setObjectName("formWidget");
GUIFormBaseDialog::GUIFormBaseDialog(QWidget* parent, Qt::WindowFlags f) : QDialog(parent, f) {
this->setObjectName("formDialog");
this->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
// this->setFixedSize(500,600);
this->setFixedWidth(500);
this->formWidget = new QWidget(this);
this->formWidget->setObjectName("formWidget");
QVBoxLayout* vLayout = new QVBoxLayout(this);
// vLayout->setContentsMargins(680,100,680,100);
vLayout->addWidget(formWidget);
QVBoxLayout* vLayout = new QVBoxLayout(this);
// vLayout->setContentsMargins(680,100,680,100);
vLayout->addWidget(formWidget);
QWidget* btnWidget= new QWidget(this);
vLayout->addWidget(btnWidget);
QHBoxLayout* hLayout = new QHBoxLayout(btnWidget);
btnOk= new QPushButton(btnWidget);
btnOk->setText("OK");
btnCancel = new QPushButton(btnWidget);
btnCancel->setText("Cancel");
hLayout->addWidget(btnOk);
hLayout->addWidget(btnCancel);
btnOk->setObjectName("btnOK");
connect(btnOk, &QPushButton::clicked, [t=this](){
if(t->updateReferenceData())
t->accept();
});
connect(btnCancel, &QPushButton::clicked, [t=this](){
t->reject();
});
QWidget* btnWidget = new QWidget(this);
vLayout->addWidget(btnWidget);
QHBoxLayout* hLayout = new QHBoxLayout(btnWidget);
btnOk = new QPushButton(btnWidget);
btnOk->setText(tr("OK"));
btnCancel = new QPushButton(btnWidget);
btnCancel->setText(tr("Cancel"));
hLayout->addWidget(btnOk);
hLayout->addWidget(btnCancel);
btnOk->setObjectName(tr("btnOK"));
connect(btnOk, &QPushButton::clicked, [t = this]() {
if (t->updateReferenceData())
t->accept();
});
connect(btnCancel, &QPushButton::clicked, [t = this]() {
t->reject();
});
}
GUIFormBaseDialog::~GUIFormBaseDialog() {
@@ -42,24 +42,24 @@ GUIFormBaseDialog::~GUIFormBaseDialog() {
}
void GUIFormBaseDialog::setButtonMode(DialogButtonMode mode) {
switch (mode) {
case OkOnly:
{
btnOk->setVisible(true);
btnCancel->setVisible(false);
return;
}
case OkAndCancel:
{
btnOk->setVisible(true);
btnCancel->setVisible(true);
return;
}
case None:
default:
{
btnOk->setVisible(false);
btnCancel->setVisible(false);
}
}
switch (mode) {
case OkOnly:
{
btnOk->setVisible(true);
btnCancel->setVisible(false);
return;
}
case OkAndCancel:
{
btnOk->setVisible(true);
btnCancel->setVisible(true);
return;
}
case None:
default:
{
btnOk->setVisible(false);
btnCancel->setVisible(false);
}
}
}

View File

@@ -14,7 +14,7 @@
#include <QImage>
#include <QPainter>
#include <qdebug.h>
#include <src/log/UserOperationLog.h>
#include "log/UserOperationLog.h"
#include <QLabel>
#ifdef WIN32

View File

@@ -248,6 +248,8 @@ SelectFormWidget::SelectFormWidget(QWidget* parent) :
btnAdd->setEnabled(true);
});
}

View File

@@ -5,7 +5,7 @@
#include "TopBarWidget.h"
#include <QLabel>
#include <QHBoxLayout>
#include <src/components/RollingMessageWidget.h>
#include "components/RollingMessageWidget.h"
#include <QDateTime>
#include "event/EventCenter.h"
#include "errorhandle/GUIErrorLW.h"

View File

@@ -9,7 +9,7 @@
#include <QDate>
#include <QDateTime>
#include <qdebug.h>
#include <src/appvals/AppGlobalValues.h>
#include "appvals/AppGlobalValues.h"
#define TRIGGER_EVENT EventCenter::Default()->triggerEvent

View File

@@ -2,7 +2,7 @@
// Created by Krad on 2021/12/17.
//
#include <src/event/EventCenter.h>
#include "event/EventCenter.h"
#include "GUIErrorLW.h"
#include <QChar>

View File

@@ -1,5 +1,6 @@
#include "generalform.h"
#include <QApplication>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
@@ -7,7 +8,7 @@
#include <QLabel>
#include <QLineEdit>
#include <QEvent>
#include <src/event/EventCenter.h>
#include "event/EventCenter.h"
#include "json/jsonobject.h"
#include "SelectDialog.h"
@@ -21,7 +22,9 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
layout->addWidget(lanHeader);
QHBoxLayout* lanHeaderLayout = new QHBoxLayout(lanHeader);
lanHeaderLayout->addWidget(new QLabel(tr("Language")));
QLabel* lbl_lan = new QLabel(tr("Language"));
lanHeaderLayout->addWidget(lbl_lan);
QPushButton* btnLan = new QPushButton(lanHeader);
lanHeaderLayout->addWidget(btnLan);
lanHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
@@ -29,12 +32,15 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
QWidget* instHeader = new QWidget(this);
layout->addWidget(instHeader);
QHBoxLayout* instHeaderLayout = new QHBoxLayout(instHeader);
instHeaderLayout->addWidget(new QLabel(tr("Institution Name")));
QLabel* lbl_ins = new QLabel(tr("Institution Name"));
instHeaderLayout->addWidget(lbl_ins);
QLineEdit* instName = new QLineEdit(instHeader);
instName->setMaximumSize(QSize(300, 32768));
instHeaderLayout->addWidget(instName);
instHeaderLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Fixed));
instHeaderLayout->addWidget(new QLabel(tr("Institution Addr")));
QLabel* lbl_insaddr = new QLabel(tr("Institution Addr"));
instHeaderLayout->addWidget(lbl_insaddr);
QLineEdit* instAddr = new QLineEdit(instHeader);
instHeaderLayout->addWidget(instAddr);
instAddr->setMaximumSize(QSize(300, 32768));
@@ -43,7 +49,10 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
QWidget* lockHeader = new QWidget(this);
layout->addWidget(lockHeader);
QHBoxLayout* lockHeaderLayout = new QHBoxLayout(lockHeader);
lockHeaderLayout->addWidget(new QLabel(tr("Lock Screen Timeout")));
QLabel* lbl_lock = new QLabel(tr("Lock Screen Timeout"));
lockHeaderLayout->addWidget(lbl_lock);
QLineEdit* lockTime = new QLineEdit(lockHeader);
lockTime->setMaximumSize(QSize(300, 32768));
lockHeaderLayout->addWidget(lockTime);
@@ -90,19 +99,15 @@ GeneralForm::GeneralForm(QWidget* parent) : QWidget(parent)
//take effect
JsonObject::Instance()->setDefaultLanguage(lan);
LanguageSwitcher::Instance()->setDefaultLanguage(lan);
btnLan->setText(JsonObject::Instance()->defaultLanguage());
EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr,nullptr);
}
});
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
lbl_lan->setText(tr("Language"));
lbl_ins->setText(tr("Institution Addr"));
lbl_insaddr->setText(tr("Institution Addr"));
lbl_lock->setText(tr("Lock Screen Timeout"));
});
}
void GeneralForm::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
{
qDebug() << "change language";
}
QWidget::changeEvent(event);
}

View File

@@ -6,18 +6,13 @@ class QPushButton;
class QVBoxLayout;
class SelectDialog;
class GeneralForm : public QWidget
{
Q_OBJECT
public:
explicit GeneralForm(QWidget* parent = nullptr);
signals:
public slots:
protected:
void changeEvent(QEvent* event);
private:
QVBoxLayout* layout = nullptr;
SelectDialog* dialog = nullptr;

View File

@@ -10,7 +10,7 @@
btn##name->setIcon(QIcon(img));\
btn##name->setIconSize(QSize(size,size));\
btn##name->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);\
btn##name->setText(tr(#name));\
btn##name->setText(QObject::tr(#name));\
layout->addWidget(btn##name);
#define ADD_TOOL_BTN_TO_LAYOUT(name,img,layout)\

View File

@@ -40,10 +40,10 @@ void JsonObject::setJsonString(const char* catergory, const char* stringName, co
char* JsonObject::getJsonString(const char* catergory, const char* stringName)
{
if (!loadcfg())
return "";
return nullptr;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return "";
if (!first) return nullptr;
cJSON* second = cJSON_GetObjectItem(first, stringName);
return second->valuestring;
@@ -52,13 +52,13 @@ char* JsonObject::getJsonString(const char* catergory, const char* stringName)
char* JsonObject::getArrayNode(const char* catergory, const char* stringName, int index, const char* id)
{
if (!loadcfg())
return "";
return nullptr;
cJSON* first = cJSON_GetObjectItem((cJSON*)json_root, catergory);
if (!first) return "";
if (!first) return nullptr;
cJSON* second = cJSON_GetObjectItem(first, stringName);
if (!second) return "";
if (!second) return nullptr;
cJSON* third = cJSON_GetArrayItem(second, index);

View File

@@ -1,5 +1,6 @@
#include "languageswitcher.h"
#include <QTranslator>
#include "event/EventCenter.h"
LanguageSwitcher* LanguageSwitcher::lsw = Q_NULLPTR;
@@ -31,5 +32,6 @@ void LanguageSwitcher::setDefaultLanguage(QString str)
//qDebug() << "installTranslator";
//QApplication::installTranslator(translator);
}
EventCenter::Default()->triggerEvent(ReloadLanguage, nullptr, nullptr);
}

View File

@@ -2,7 +2,7 @@
#include <QTimer>
#include "appvals/AppGlobalValues.h"
#include <src/event/EventCenter.h>
#include "event/EventCenter.h"
#include "json/jsonobject.h"
Locker* Locker::locker = Q_NULLPTR;

View File

@@ -14,19 +14,19 @@
#include "log/UserOperationLog.h"
LoginWindow::LoginWindow(QWidget* parent)
: QDialog(parent)
, m_pLoginButton(nullptr)
, m_pVMainLayout(nullptr)
, m_pUserCodeFrame(nullptr)
, m_pUserCodeLayout(nullptr)
, m_pUserCodeEdit(nullptr)
, m_pPassWordEdit(nullptr)
: QDialog(parent)
, m_pLoginButton(nullptr)
, m_pVMainLayout(nullptr)
, m_pUserCodeFrame(nullptr)
, m_pUserCodeLayout(nullptr)
, m_pUserCodeEdit(nullptr)
, m_pPassWordEdit(nullptr)
{
initUi();
init();
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
//Dialog::Instance()->InitForm();
m_pUserCodeEdit->setText("usct");
initUi();
init();
setWindowFlags(windowFlags() | Qt::Window | Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
//Dialog::Instance()->InitForm();
m_pUserCodeEdit->setText(tr("usct"));
}
LoginWindow::~LoginWindow()
@@ -37,75 +37,76 @@ LoginWindow::~LoginWindow()
void LoginWindow::initUi()
{
QString style = "*{background-color:#3c3c3c; color:white;margin:0;font-size:16px;}"
"QLabel#title{font-Size:98px;color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);}"
"QLabel#warn{color:#930000;background:transparent;font-size:20px;}"
"QFrame#login_frame_username{min-width:700px;max-width:700px;max-height:500px;min-height:500px;"
"border:1px solid #0078d8;border-radius:20px;"
"background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0.0 darkgray, stop: 0.5 gray, stop: 1.0 darkgray);"
"}"
"QLineEdit{min-height:100px;max-height:100px; border:1px solid silver;border-radius:10px;font-size:26px;}"
"QLineEdit:enabled{background-color: #515151}"
"QComboBox{text-align:center;min-height:100px;max-height:100px; "
"border:1px solid silver;border-radius:10px;padding:3px}"
"QComboBox:enabled{background-color: #515151}"
"QComboBox::drop-down{width:80px;border-radius:10px}"
"QComboBox QAbstractItemView{min-width:120px;}"
"QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;}"
"QToolButton{min-height:100px;max-height:100px;border:1px solid #505050;"
"border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}"
"QToolButton:hover{background:#505050;}";
setStyleSheet(style);
QString style = "*{background-color:#3c3c3c; color:white;margin:0;font-size:16px;}"
"QLabel#title{font-Size:98px;color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);}"
"QLabel#warn{color:#930000;background:transparent;font-size:20px;}"
"QFrame#login_frame_username{min-width:700px;max-width:700px;max-height:500px;min-height:500px;"
"border:1px solid #0078d8;border-radius:20px;"
"background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,\n"
" stop: 0.0 darkgray, stop: 0.5 gray, stop: 1.0 darkgray);"
"}"
"QLineEdit{min-height:100px;max-height:100px; border:1px solid silver;border-radius:10px;font-size:26px;}"
"QLineEdit:enabled{background-color: #515151}"
"QComboBox{text-align:center;min-height:100px;max-height:100px; "
"border:1px solid silver;border-radius:10px;padding:3px}"
"QComboBox:enabled{background-color: #515151}"
"QComboBox::drop-down{width:80px;border-radius:10px}"
"QComboBox QAbstractItemView{min-width:120px;}"
"QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;}"
"QToolButton{min-height:100px;max-height:100px;border:1px solid #505050;"
"border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}"
"QToolButton:hover{background:#505050;}";
setStyleSheet(style);
m_pVMainLayout = new QVBoxLayout(this);
m_pVMainLayout->setContentsMargins(0, 0, 0, 0);
m_pVMainLayout->setSpacing(0);
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
m_pVMainLayout = new QVBoxLayout(this);
m_pVMainLayout->setContentsMargins(0, 0, 0, 0);
m_pVMainLayout->setSpacing(0);
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
QLabel* title = new QLabel(this);
title->setObjectName("title");
title->setText("U S C T");
m_pVMainLayout->addWidget(title, 0, Qt::AlignCenter);
m_pUserCodeFrame = new QFrame(this);
m_pUserCodeFrame->setObjectName("login_frame_username");
m_pUserCodeLayout = new QVBoxLayout(m_pUserCodeFrame);
m_pUserCodeLayout->setSpacing(30);
m_pUserCodeLayout->setContentsMargins(20, 60, 20, 20);
warn = new QLabel(this);
warn->setObjectName("warn");
warn->setText("Login failed, username or password error!");
warn->setVisible(false);
m_pUserCodeLayout->addWidget(warn, 0, Qt::AlignCenter);
m_pUserCodeEdit = new QLineEdit(m_pUserCodeFrame);
m_pUserCodeEdit->setObjectName("combobox_UserName");
QLabel* title = new QLabel(this);
title->setObjectName("title");
title->setText(tr("U S C T"));
m_pVMainLayout->addWidget(title, 0, Qt::AlignCenter);
m_pUserCodeFrame = new QFrame(this);
m_pUserCodeFrame->setObjectName("login_frame_username");
m_pUserCodeLayout = new QVBoxLayout(m_pUserCodeFrame);
m_pUserCodeLayout->setSpacing(30);
m_pUserCodeLayout->setContentsMargins(20, 60, 20, 20);
warn = new QLabel(this);
warn->setObjectName("warn");
warn->setText("Login failed, username or password error!");
warn->setVisible(false);
m_pUserCodeLayout->addWidget(warn, 0, Qt::AlignCenter);
m_pUserCodeEdit = new QLineEdit(m_pUserCodeFrame);
m_pUserCodeEdit->setObjectName("combobox_UserName");
//m_pUserCodeEdit->setLineEdit(new QLineEdit(m_pUserCodeFrame));
//m_pUserCodeEdit->setLineEdit(new QLineEdit(m_pUserCodeFrame));
m_pUserCodeEdit->setPlaceholderText(tr("Username"));
m_pUserCodeLayout->addWidget(m_pUserCodeEdit);
m_pVMainLayout->addWidget(m_pUserCodeFrame, 0, Qt::AlignCenter);
m_pUserCodeEdit->setPlaceholderText(tr("Username"));
m_pUserCodeLayout->addWidget(m_pUserCodeEdit);
m_pVMainLayout->addWidget(m_pUserCodeFrame, 0, Qt::AlignCenter);
m_pPassWordEdit = new QLineEdit(this);
m_pPassWordEdit->setObjectName("edt_Password");
m_pPassWordEdit->setEchoMode(QLineEdit::Password);
m_pPassWordEdit->setPlaceholderText(tr("Password"));
m_pUserCodeLayout->addWidget(m_pPassWordEdit);
m_pPassWordEdit = new QLineEdit(this);
m_pPassWordEdit->setObjectName("edt_Password");
m_pPassWordEdit->setEchoMode(QLineEdit::Password);
m_pPassWordEdit->setPlaceholderText(tr("Password"));
m_pUserCodeLayout->addWidget(m_pPassWordEdit);
ADD_TOOL_BTN_TO_LAYOUT(login, ":/icons/login.png", m_pUserCodeLayout);
m_pUserCodeLayout->removeWidget(btnlogin);
m_pUserCodeLayout->addWidget(btnlogin, 0, Qt::AlignCenter);
m_pLoginButton = btnlogin;
// m_pUserCodeLayout->addWidget(m_pLoginButton, 0, Qt::AlignCenter);
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
ADD_TOOL_BTN_TO_LAYOUT(login, ":/icons/login.png", m_pUserCodeLayout);
initUserList();
m_pUserCodeLayout->removeWidget(btnlogin);
m_pUserCodeLayout->addWidget(btnlogin, 0, Qt::AlignCenter);
m_pLoginButton = btnlogin;
// m_pUserCodeLayout->addWidget(m_pLoginButton, 0, Qt::AlignCenter);
m_pVMainLayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding));
initUserList();
}
void LoginWindow::init()
{
connect(m_pLoginButton, SIGNAL(clicked()), this, SLOT(doLogin()));
connect(m_pLoginButton, SIGNAL(clicked()), this, SLOT(doLogin()));
}
void LoginWindow::initUserList()
@@ -114,31 +115,31 @@ void LoginWindow::initUserList()
void LoginWindow::clearInputData()
{
m_pUserCodeEdit->clear();
m_pPassWordEdit->clear();
//m_pUserCodeEdit->setFocus();
m_pUserCodeEdit->clear();
m_pPassWordEdit->clear();
//m_pUserCodeEdit->setFocus();
}
void LoginWindow::doLogin()
{
QString strUserCode = m_pUserCodeEdit->text();
QString strPassWord = m_pPassWordEdit->text();
QString strUserCode = m_pUserCodeEdit->text();
QString strPassWord = m_pPassWordEdit->text();
QString encryptedPassword = strPassWord;
strPassWord = "123456";
QString encryptedPassword = strPassWord;
strPassWord = "123456";
QString encryptPwd = User::getEncryptedPassword(strPassWord);
QString encryptPwd = User::getEncryptedPassword(strPassWord);
QString sql = QString("select UserCode from Account where UserCode='%1' and Password='%2'")
.arg(strUserCode).arg(encryptPwd);
if(User::QueryUser(strUserCode,encryptPwd))
{
accept();
.arg(strUserCode).arg(encryptPwd);
if (User::QueryUser(strUserCode, encryptPwd))
{
accept();
LOG_USER_OPERATION(Login);
}
else {
warn->setVisible(true);
}
}
else {
warn->setVisible(true);
}
}

View File

@@ -3,7 +3,7 @@
#include "loginwindow.h"
#include "InputObject.h"
#include <QQmlApplicationEngine>
#include <src/db/SQLHelper.h>
#include "db/SQLHelper.h"
#include <QTextCodec>
#include <QFontDatabase>
#include <QDebug>
@@ -47,10 +47,16 @@ int main(int argc, char* argv[])
QTextCodec* codec = QTextCodec::codecForName("utf8");
QTextCodec::setCodecForLocale(codec);
//multi-language suppport
QTranslator translator;
LanguageSwitcher::Instance()->setTranslator(&translator);
LanguageSwitcher::Instance()->setDefaultLanguage(JsonObject::Instance()->defaultLanguage());
a.installTranslator(&translator);
//QString fontName = loadFontFromFile(":/fonts/MicrosoftYahei.ttf");
QString fontName = loadFontFromFile(":/fonts/DroidSansFallback.ttf");
QFont font(fontName);
QApplication::setFont(font);
@@ -65,11 +71,7 @@ int main(int argc, char* argv[])
//QObject::connect(obj, SIGNAL(touchScreen()), Locker::Instance(), SLOT(refreshTimer()));
//multi-language suppport
QTranslator translator;
LanguageSwitcher::Instance()->setTranslator(&translator);
LanguageSwitcher::Instance()->setDefaultLanguage(JsonObject::Instance()->defaultLanguage());
a.installTranslator(&translator);
QStringList app_args = a.arguments();

View File

@@ -3,7 +3,7 @@
#include <qtabwidget.h>
#include <QSizePolicy>
#include <QHBoxLayout>
#include <src/event/EventCenter.h>
#include "event/EventCenter.h"
#include "tabformwidget.h"
#include "SelectFormWidget.h"
#include "ScanFormWidget.h"
@@ -82,14 +82,14 @@ MainWindow::MainWindow(QWidget* parent) :
"QComboBox QAbstractItemView::item {min-height:60px;max-height:60px; border:1px solid white;}"
//"QScrollBar:vertical {min-width: 50px;}"
"QLabel{color:white; font-weight:bold; font-size:16px;}\n"
"QLabel#sliderPickerLabel{color:silver;padding:0;background:#505050;font-weight:normal;font-size:50px;}\n"
"QLabel#sliderPickerLabel{color:silver;padding:0;background:#505050;font-weight:normal;font-size:50px;}\n"
"QWidget#topbarWidget{min-height:36px;max-height:36px;}\n"
"QWidget#contentWidget{border-top:1px solid #515151;}\n"
"QWidget#commandWidget{min-height:123px;max-height:123px;border-top:1px solid #515151; border-bottom:1px solid #323232;}\n"
"QLabel#logo{min-width:30px;max-width:30px}\n"
"QLabel#company{min-width:150px;max-width:150px; }\n"
"QLabel#systemMsgBar{min-width:500px;}"
"QLabel#warn{color:#CCCC00;background:transparent;font-size:20px;}"
"QLabel#warn{color:#CCCC00;background:transparent;font-size:20px;}"
"QWidget QWidget#statusBarWidget{min-width:300px;}\n"
"QWidget QToolButton{border:none;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}\n"
"QToolButton#btn_main{border:2px solid #0078d8;border-radius:10%;font-size:26px; font-weight:Bold;padding:5px;}\n"
@@ -103,32 +103,32 @@ MainWindow::MainWindow(QWidget* parent) :
"QDialog QWidget#innerWidget{ background:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
"stop: 0.0 darkgray, stop: 0.5 lightgray, stop: 1.0 darkgray);"
"border-radius:20px;border:5px solid #0078d8; }"
"QDialog#MessageDialog QWidget QWidget{ background:transparent;color:#3078d8}"
"QDialog#MessageDialog QWidget QWidget QLabel{ font-size:30px}"
"QDialog#MessageDialog QWidget QWidget{ background:transparent;color:#3078d8}"
"QDialog#MessageDialog QWidget QWidget QLabel{ font-size:30px}"
"#spacer_1, #spacer_2{min-width:2px;max-width:2px;margin-top:6px;margin-bottom:6px;border-right:1px solid #0078d8;}"
//FormDialog
"QPushButton{border:1px solid silver ;padding-left:50px;padding-right:50px; border-radius:5px; min-height:28px; max-height:28px; background:#4c5052}"
"QPushButton#btnOK{background:#365880; font-weight:bold}"
"QDialog#formDialog{border:3px solid silver; border-radius:8px}"
"QWidget#slider_one{border:1px solid silver; border-radius:8px}"
"QWidget#formWidget QLabel#endline{border-bottom:1px solid silver}"
"QWidget#formWidget QLabel#title{font-size:30px; border-bottom:1px solid #3078d8 }"
"QListView{border:none;margin:5px; font-weight:bold}"
"QListView::item{background:#4c5052;min-height:30px; border:1px solid silver; border-radius:5px}"
"QListView::item:selected{background:#365880; font-weight:bold;color:white}"
"QHeaderView::section{background-color:#595959;"
"min-height:50px;max-height:50px;"
"font-weight:Bold; font-size:16px; border:1px solid #323232;}"
"QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);}"
"QHeaderView::section:vertical{min-height:36px;max-height:36px;}"
"QWidget#edit_patient{min-width:300px;max-width:300px;}"
"QTableView{border:none}"
"QTableView{alternate-background-color: #595959;selection-color:white;selection-background-color:#0078d8}"
"QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;}"
"QToolButton#sexBtn:disabled{color:silver}"
"QWidget#sexpanelwidget{border:1px solid silver;}"
"QWidget#sexpanelwidget:enabled{background-color: #515151;}"
"QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;}"
"QPushButton{border:1px solid silver ;padding-left:50px;padding-right:50px; border-radius:5px; min-height:28px; max-height:28px; background:#4c5052}"
"QPushButton#btnOK{background:#365880; font-weight:bold}"
"QDialog#formDialog{border:3px solid silver; border-radius:8px}"
"QWidget#slider_one{border:1px solid silver; border-radius:8px}"
"QWidget#formWidget QLabel#endline{border-bottom:1px solid silver}"
"QWidget#formWidget QLabel#title{font-size:30px; border-bottom:1px solid #3078d8 }"
"QListView{border:none;margin:5px; font-weight:bold}"
"QListView::item{background:#4c5052;min-height:30px; border:1px solid silver; border-radius:5px}"
"QListView::item:selected{background:#365880; font-weight:bold;color:white}"
"QHeaderView::section{background-color:#595959;"
"min-height:50px;max-height:50px;"
"font-weight:Bold; font-size:16px; border:1px solid #323232;}"
"QHeaderView::section:horizontal{border-bottom: 1px solid rgb(0,170,255);}"
"QHeaderView::section:vertical{min-height:36px;max-height:36px;}"
"QWidget#edit_patient{min-width:300px;max-width:300px;}"
"QTableView{border:none}"
"QTableView{alternate-background-color: #595959;selection-color:white;selection-background-color:#0078d8}"
"QToolButton#sexBtn{min-width:120px;max-width:120px;font-size:20px;padding:2px;}"
"QToolButton#sexBtn:disabled{color:silver}"
"QWidget#sexpanelwidget{border:1px solid silver;}"
"QWidget#sexpanelwidget:enabled{background-color: #515151;}"
"QToolButton#sexBtn:checked{border:2px solid darkorange;padding:0px;}"
;
this->setStyleSheet(style);
ui->setupUi(this);
@@ -139,47 +139,48 @@ MainWindow::MainWindow(QWidget* parent) :
tab->setCurrentIndex(1);
});
SelectFormWidget* select_form = new SelectFormWidget(this);
tab->addTab(select_form, "Select");
tab->addTab(select_form, tr("Select"));
ScanFormWidget* scan_form = new ScanFormWidget(this);
tab->addTab(scan_form, "Scan");
tab->addTab(scan_form, tr("Scan"));
TabFormWidget* verify_form = new TabFormWidget(this);
tab->addTab(verify_form, "Verify");
tab->addTab(verify_form, tr("Verify"));
tab->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setMargin(0);
layout->setSpacing(0);
QWidget * top = new TopBarWidget(this);
top->setObjectName("topbarWidget");
layout->setSpacing(0);
QWidget* top = new TopBarWidget(this);
top->setObjectName("topbarWidget");
layout->addWidget(top);
layout->addWidget(tab);
ui->centralWidget->setLayout(layout);
this->setWindowFlags(Qt::Window);
connect(EventCenter::Default(), &EventCenter::DeviceErrorRaise, [=](QObject* parent, QObject* msg) {
//默认旧模式
if (!msgDialog) {
msgDialog = new GUIMessageDialog(this);
msgDialog->setStyleSheet(style);
}
if (msg) {
QString *str = (QString *) msg;
msgDialog->showMessage(*str);
} else {
msgDialog->showMessage("Something went error!");
}
msgDialog->stopLoading();
msgDialog->showExitButton();
if (msgDialog->isHidden()){
msgDialog->setWindowModality(Qt::NonModal);
msgDialog->exec();
}
});
//默认旧模式
if (!msgDialog) {
msgDialog = new GUIMessageDialog(this);
msgDialog->setStyleSheet(style);
}
if (msg) {
QString* str = (QString*)msg;
msgDialog->showMessage(*str);
}
else {
msgDialog->showMessage("Something went error!");
}
msgDialog->stopLoading();
msgDialog->showExitButton();
if (msgDialog->isHidden()) {
msgDialog->setWindowModality(Qt::NonModal);
msgDialog->exec();
}
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationStart, [=](QObject*, QObject* msg) {
if (msgDialog){
msgDialog->hide();
delete msgDialog;
}
msgDialog = new GUIMessageDialog(this);
if (msgDialog) {
msgDialog->hide();
delete msgDialog;
}
msgDialog = new GUIMessageDialog(this);
if (msg)
{
QString* str = (QString*)msg;
@@ -191,11 +192,11 @@ MainWindow::MainWindow(QWidget* parent) :
msgDialog->hideExitButton();
msgDialog->startLoading();
AppGlobalValues::setInProcessing(true);
// msgDialog->showFullScreen();
if (msgDialog->isHidden()){
msgDialog->show();
}
});
// msgDialog->showFullScreen();
if (msgDialog->isHidden()) {
msgDialog->show();
}
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationProgress, [=](QObject*, QObject* msg) {
if (!msgDialog) msgDialog = new GUIMessageDialog(this);
if (msg)
@@ -206,58 +207,70 @@ MainWindow::MainWindow(QWidget* parent) :
else {
msgDialog->hideMessage();
}
// msgDialog->showFullScreen();
if (msgDialog->isHidden())msgDialog->show();
// msgDialog->showFullScreen();
if (msgDialog->isHidden())msgDialog->show();
});
connect(EventCenter::Default(), &EventCenter::InvokeOperationEnd, [=]() {
if (!msgDialog) return;
if (!msgDialog->isHidden())msgDialog->accept();
delete msgDialog;
msgDialog = nullptr;
AppGlobalValues::setInProcessing(false);
});
connect(EventCenter::Default(), &EventCenter::RequestLogin, [=](QObject*, QObject* msg) {
this->requestLogin();
});
connect(EventCenter::Default(), &EventCenter::LoginRoleChanged, [=](QObject*, QObject*) {
if (User::Current()->isAdmin() )
{
if (admin_tab_index == -1)
{
AdminSettingForm * form = new AdminSettingForm(this);
admin_tab_index = tab->addTab(form,"Admin");
}
} else{
if (admin_tab_index != -1){
tab->removeTab(admin_tab_index);
admin_tab_index = -1;
}
}
qApp->processEvents();
});
if (!msgDialog->isHidden())msgDialog->accept();
delete msgDialog;
msgDialog = nullptr;
AppGlobalValues::setInProcessing(false);
});
connect(EventCenter::Default(), &EventCenter::RequestLogin, [=](QObject*, QObject* msg) {
this->requestLogin();
});
connect(EventCenter::Default(), &EventCenter::LoginRoleChanged, [=](QObject*, QObject*) {
if (User::Current()->isAdmin())
{
if (admin_tab_index == -1)
{
AdminSettingForm* form = new AdminSettingForm(this);
admin_tab_index = tab->addTab(form, tr("Admin"));
}
}
else {
if (admin_tab_index != -1) {
tab->removeTab(admin_tab_index);
admin_tab_index = -1;
}
}
qApp->processEvents();
});
GUIErrorHandle::Default()->init();
DeviceManager::Default()->initDevice();
GUIErrorHandle::Default()->init();
DeviceManager::Default()->initDevice();
QThread* t = QThread::create([](){
QThread::sleep(10);
int f = 0x00100001;
for (int i = 0; i < 8; ++i) {
QThread::sleep(10);
f= f << (i*4);
printf("invoke %d\r\n", f);
char* v = (char*)&f;
QString msg;
msg.append("w ");
msg.append(v[0]);
msg.append(v[1]);
msg.append(v[2]);
msg.append(v[3]);
EventCenter::Default()->triggerEvent(GUIErrorRaise,nullptr,(QObject*)&msg);
}
});
t->start();
QThread* t = QThread::create([]() {
QThread::sleep(10);
int f = 0x00100001;
for (int i = 0; i < 8; ++i) {
QThread::sleep(10);
f = f << (i * 4);
printf("invoke %d\r\n", f);
char* v = (char*)&f;
QString msg;
msg.append("w ");
msg.append(v[0]);
msg.append(v[1]);
msg.append(v[2]);
msg.append(v[3]);
EventCenter::Default()->triggerEvent(GUIErrorRaise, nullptr, (QObject*)&msg);
}
});
t->start();
centerWidgetHide();
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
tab->setTabText(0, tr("Select"));
tab->setTabText(1, tr("Scan"));
tab->setTabText(2, tr("Verify"));
tab->setTabText(3, tr("Admin"));
});
}
MainWindow::~MainWindow()
@@ -276,7 +289,7 @@ void MainWindow::changeEvent(QEvent* event)
}
void MainWindow::centerWidgetHide() {
ui->centralWidget->setVisible(false);
ui->centralWidget->setVisible(false);
}
void MainWindow::centerWidgetShow() {
@@ -291,19 +304,19 @@ QTextEdit* MainWindow::getEdit()
}
void MainWindow::requestLogin() {
LoginWindow l(this);
l.setWindowModality(Qt::WindowModal);
l.showFullScreen();
this->centerWidgetHide();
while(l.result() != QDialog::Accepted)
{
l.exec();
}
this->centerWidgetShow();
LoginWindow l(this);
l.setWindowModality(Qt::WindowModal);
l.showFullScreen();
this->centerWidgetHide();
while (l.result() != QDialog::Accepted)
{
l.exec();
}
this->centerWidgetShow();
}
void MainWindow::debugConsoleOn() {
QTextEdit* text_edit = new QTextEdit(this);
QTextEdit* text_edit = new QTextEdit(this);
ui->centralWidget->layout()->addWidget(text_edit);
const QString edit_style =
"QScrollBar:vertical{border: 0px solid grey; background:#2d2d2d; width: 15px; margin: 0px 0 0px 0; }"

View File

@@ -18,7 +18,7 @@ GetAdminPsw::GetAdminPsw(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog
form->addRow(value1, _psw);
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setObjectName(QString::fromUtf8("warn"));
form->addRow("", lbl_error);
}

View File

@@ -12,15 +12,16 @@ GetIPDialog::GetIPDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog
setWindowModality(Qt::WindowModal);
QFormLayout* form = new QFormLayout(formWidget);
QString value1 = QString("IP Address");
QLabel* value1 = new QLabel(tr("IP Address"));
_ip = new QLineEdit(this);
form->addRow(value1, _ip);
QString value2 = QString("Netmask");
QLabel* value2 = new QLabel(tr("Netmask"));
_mask = new QLineEdit(this);
form->addRow(value2, _mask);
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
lbl_error->setObjectName(QString::fromUtf8("warn"));
form->addRow("", lbl_error);
}

View File

@@ -12,13 +12,13 @@ GetRouteDialog::GetRouteDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBase
setWindowModality(Qt::WindowModal);
QFormLayout* form = new QFormLayout(formWidget);
QString value1 = QString("Destination");
QString value1 = QString(tr("Destination"));
_des = new QLineEdit(this);
form->addRow(value1, _des);
QString value2 = QString("Netmask");
QString value2 = QString(tr("Netmask"));
_mask = new QLineEdit(this);
form->addRow(value2, _mask);
QString value3 = QString("Gateway");
QString value3 = QString(tr("Gateway"));
_gw = new QLineEdit(this);
form->addRow(value3, _gw);

View File

@@ -30,12 +30,15 @@ networkCfgDialog::networkCfgDialog(QWidget* parent) :
model_route = new NetCfgTableModel(this);
QStringList header_addr;
header_addr << "IP Address" << "Netmask";
header_addr << tr("IP Address") << tr("Netmask");
model_addr->setHeader(header_addr);
QStringList route_addr;
route_addr << "Destination" << "Gateway" << "Netmask";
route_addr << tr("Destination") << tr("Gateway") << tr("Netmask");
model_route->setHeader(route_addr);
ui->btn_group->button(QDialogButtonBox::Apply)->setText(tr("Apply"));
ui->btn_group->button(QDialogButtonBox::Cancel)->setText(tr("Cancel"));
loadData();
ui->tbl_addr->setModel(model_addr);
@@ -62,6 +65,7 @@ networkCfgDialog::networkCfgDialog(QWidget* parent) :
ui->tbl_route->setColumnWidth(2, 230);
ui->tbl_route->horizontalHeader()->setFixedHeight(38);
connect(ui->btn_addr_add, &QPushButton::clicked, [=]()
{
//GetIPDialog* dialog = new GetIPDialog(this);

View File

@@ -14,6 +14,8 @@
#include "components/imageswitch.h"
#include "network/networkcfgdialog.h"
#include "network/getadminpsw.h"
#include "event/EventCenter.h"
systemSettingForm::systemSettingForm(QWidget* parent) :
QWidget(parent),
ui(new Ui::systemSettingForm)
@@ -100,6 +102,10 @@ systemSettingForm::systemSettingForm(QWidget* parent) :
ui->btnFlt->setText(JsonObject::Instance()->defaultFilter());
}
});
connect(EventCenter::Default(), &EventCenter::ReloadLanguage, [=]() {
ui->retranslateUi(this);
});
}
systemSettingForm::~systemSettingForm()
@@ -185,3 +191,11 @@ void systemSettingForm::saveServersInfo()
//qIfConfig(lhost);
}
void systemSettingForm::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
{
ui->retranslateUi(this);
}
}

View File

@@ -20,6 +20,9 @@ public:
explicit systemSettingForm(QWidget *parent = nullptr);
~systemSettingForm();
protected:
void changeEvent(QEvent* event);
private:
Ui::systemSettingForm *ui;
SelectDialog* sd_protocal = nullptr;

View File

@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>527</width>
<width>619</width>
<height>612</height>
</rect>
</property>

View File

@@ -1,7 +1,7 @@
#include "tabformwidget.h"
#include "ui_tabformwidget.h"
#include <QDateTime>
#include <src/components/RollingMessageWidget.h>
#include "components/RollingMessageWidget.h"
#include "event/EventCenter.h"
#if defined(_MSC_VER) && (_MSC_VER >= 1600)

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff