File arrangement

This commit is contained in:
Krad
2022-02-14 11:40:40 +08:00
parent 5dafb1e816
commit 73cd96333d
61 changed files with 32 additions and 32 deletions

View File

@@ -0,0 +1,295 @@
//
// Created by Krad on 2021/11/10.
//
#include "AccountFormDialog.h"
#include "ChangePasswordFormDialog.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QUuid>
#include <QDebug>
#include <QToolButton>
#include <QPushButton>
#include <QLineEdit>
#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);
//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 new mode
if (m_mode == New) {
//add password
QLabel *lbl_Pwd = new QLabel(this);
lbl_Pwd->setText(tr("Password"));
layout->addWidget(lbl_Pwd);
le_Pwd = new QLineEdit(this);
le_Pwd->setPlaceholderText(tr("Input password"));
le_Pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(le_Pwd);
m_RoleID = User::getRoleID("doctor");
QLabel *lbl_endline3 = new QLabel(this);
lbl_endline3->setObjectName("endline");
layout->addWidget(lbl_endline3);
}
//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);
QHBoxLayout* hlayout = new QHBoxLayout;
layout->addLayout(hlayout);
//add logout
// QLabel *lbl_Logout = new QLabel(this);
// lbl_Logout->setText(tr("Logout"));
if (m_mode == Self)
{
QToolButton *btn_Logout = new QToolButton(this);
btn_Logout->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn_Logout->setIcon(QIcon(":/icons/logout.png"));
btn_Logout->setIconSize({30, 30});
btn_Logout->setText(tr("Logout"));
btn_Logout->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed);
btn_Logout->setObjectName("editvalBtn");
hlayout->addWidget(btn_Logout);
connect(btn_Logout, &QAbstractButton::clicked, [=]() {
this->accept();
LOG_USER_OPERATION(Logout);
EventCenter::Default()->triggerEvent(GUIEvents::RequestLogin, nullptr, nullptr);
});
}
// load current user data
if (m_mode == Self && User::Current()) {
le_UserCode->setText(User::Current()->getUserCode());
le_UserName->setText(User::Current()->getUserName());
m_UserID = User::Current()->getUserID();
m_UserPwd = User::Current()->getPassword();
}
if (m_mode != New) {
btn_Pwd = new QToolButton(this);
btn_Pwd->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
btn_Pwd->setObjectName("editvalBtn");
btn_Pwd->setIcon(QIcon(":/icons/edit.png"));
btn_Pwd->setIconSize({30, 30});
btn_Pwd->setText(m_mode == Self ? tr("Change Password") : tr("Reset Password"));
btn_Pwd->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
hlayout->addWidget(btn_Pwd);
QLabel *lbl_endline9 = new QLabel(this);
lbl_endline9->setFixedHeight(2);
lbl_endline9->setObjectName("endline");
layout->addWidget(lbl_endline9);
if (m_mode == Self) {
connect(btn_Pwd, &QPushButton::clicked, [=]() {
ChangePasswordFormDialog dia(this);
dia.setGeometry(this->geometry());
dia.setWindowModality(Qt::WindowModal);
dia.exec();
});
} else {
connect(btn_Pwd, &QAbstractButton::clicked, [=]() {
AlertDialog dialog(this);
dialog.setGeometry(this->geometry());
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(le_Comment, &QLineEdit::textChanged, [=](const QString &text) {
commentChanged = true;
});
connect(le_UserName, &QLineEdit::textChanged, [=](const QString &text) {
m_NewUserName = text;
userNameChanged = true;
});
}
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);
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
#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
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();
}
void AccountFormDialog::warn(QString msg) {
lbl_error->setText(msg);
lbl_error->setVisible(true);
}
void AccountFormDialog::hideWarn() {
this->lbl_error->setVisible(false);
}

View File

@@ -0,0 +1,49 @@
//
// Created by Krad on 2021/11/10.
//
#ifndef GUI_ACCOUNTFORMDIALOG_H
#define GUI_ACCOUNTFORMDIALOG_H
class QLabel;
class QLineEdit;
class QToolButton;
class QSqlTableModel;
#include "GUIFormBaseDialog.h"
enum AccountEditMode{
Self, Admin, New
};
class AccountFormDialog:public GUIFormBaseDialog{
Q_OBJECT
public:
explicit AccountFormDialog(QWidget *parent = nullptr,AccountEditMode mode = Self,Qt::WindowFlags f = Qt::WindowFlags());
~AccountFormDialog();
void setAccountInformation(const QMap<QString,QVariant>& values);
void setReferenceModel(QSqlTableModel* model){
refmodel = model;
}
protected:
bool updateReferenceData() override;
void warn(QString msg);
void hideWarn();
private:
QString m_UserID;
QString m_UserPwd;
QString m_RoleID;
QString m_NewUserName;
bool userNameChanged = false;
bool commentChanged = false;
bool roleChanged = false;
AccountEditMode m_mode = Self;
QLineEdit* le_UserCode = nullptr;
QLineEdit* le_UserName = nullptr;
QLineEdit* le_Comment = nullptr;
QLineEdit* le_Pwd = nullptr;
QToolButton* btn_Pwd = nullptr;
QLabel* lbl_error = nullptr;
QSqlTableModel* refmodel = nullptr;
};
#endif //GUI_ACCOUNTFORMDIALOG_H

View File

@@ -0,0 +1,34 @@
//
// Created by Krad on 2021/12/8.
//
#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QLabel>
#include "AlertDialog.h"
AlertDialog::AlertDialog(QWidget *parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
this->setFixedHeight(180);
this->setFixedWidth(400);
QVBoxLayout* layout = new QVBoxLayout(formWidget);
layout->setSpacing(10);
// add title
lbl_title = new QLabel(this);
lbl_title->setAlignment(Qt::AlignCenter);
lbl_title->setText(tr("Warning"));
lbl_title->setObjectName("title");
layout->addWidget(lbl_title);
lbl_msg = new QLabel(this);
layout->addWidget(lbl_msg);
}
AlertDialog::~AlertDialog() {
}
void AlertDialog::setAlertMessage(const QString &msg) {
this->lbl_msg->setText(msg);
}
void AlertDialog::setTitle(const QString &msg) {
lbl_title->setText(msg);
}

25
src/dialogs/AlertDialog.h Normal file
View File

@@ -0,0 +1,25 @@
//
// Created by Krad on 2021/12/8.
//
#ifndef GUI_ALERTDIALOG_H
#define GUI_ALERTDIALOG_H
class QLabel;
#include "GUIFormBaseDialog.h"
class AlertDialog :public GUIFormBaseDialog{
Q_OBJECT
public:
explicit AlertDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~AlertDialog();
void setAlertMessage(const QString& msg);
void setTitle(const QString& msg);
protected:
bool updateReferenceData() override{return true;}
private:
QLabel* lbl_msg;
QLabel* lbl_title;
};
#endif //GUI_ALERTDIALOG_H

View File

@@ -0,0 +1,93 @@
//
// Created by Krad on 2021/11/11.
//
#include <QVBoxLayout>
#include <QLabel>
#include <QtWidgets/QLineEdit>
#include "models/User.h"
#include "log/UserOperationLog.h"
#include "ChangePasswordFormDialog.h"
ChangePasswordFormDialog::ChangePasswordFormDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
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("Change Password"));
lbl_title->setObjectName("title");
layout->addWidget(lbl_title);
//add old password
QLabel* lbl_Old = new QLabel(this);
lbl_Old->setText(tr("Current Password"));
pwd = new QLineEdit(this);
pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(lbl_Old);
layout->addWidget(pwd);
QLabel* lbl_endline1 = new QLabel(this);
lbl_endline1->setObjectName("endline");
layout->addWidget(lbl_endline1);
//add new password
QLabel* lbl_New = new QLabel(this);
lbl_New->setText(tr("New Password"));
new_pwd = new QLineEdit(this);
new_pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(lbl_New);
layout->addWidget(new_pwd);
QLabel* lbl_endline2 = new QLabel(this);
lbl_endline2->setObjectName("endline");
layout->addWidget(lbl_endline2);
//add confirm password
QLabel* lbl_Confirm = new QLabel(this);
lbl_Confirm->setText(tr("Confirm Password"));
confirm_pwd = new QLineEdit(this);
confirm_pwd->setEchoMode(QLineEdit::Password);
layout->addWidget(lbl_Confirm);
layout->addWidget(confirm_pwd);
QLabel* lbl_endline3 = new QLabel(this);
lbl_endline3->setObjectName("endline");
layout->addWidget(lbl_endline3);
lbl_error = new QLabel(this);
lbl_error->setObjectName("warn");
layout->addWidget(lbl_error);
}
ChangePasswordFormDialog::~ChangePasswordFormDialog() {
}
bool ChangePasswordFormDialog::updateReferenceData() {
if (pwd->text().isEmpty())
{
lbl_error->setText(tr("Please enter your old password!"));
return false;
}
if (new_pwd->text().length() < 6) {
lbl_error->setText(tr("New password should at least 6 characters!"));
return false;
}
QString encryptPwd = User::getEncryptedPassword(pwd->text());
if (encryptPwd != User::Current()->getPassword())
{
lbl_error->setText(tr("Wrong password!"));
return false;
}
if (new_pwd->text() != confirm_pwd->text())
{
lbl_error->setText(tr("Your new password does not match!"));
return false;
}
User::Current()->setPassword(User::getEncryptedPassword(new_pwd->text()));
if (!User::Current()->submitChange()) {
lbl_error->setText(tr("Database update error!"));
User::Current()->restorePassword(encryptPwd);
return false;
}
LOG_USER_OPERATION(ChangePassword);
return true;
}

View File

@@ -0,0 +1,28 @@
//
// Created by Krad on 2021/11/11.
//
#ifndef GUI_CHANGEPASSWORDFORMDIALOG_H
#define GUI_CHANGEPASSWORDFORMDIALOG_H
#include "GUIFormBaseDialog.h"
class QLineEdit;
class QLabel;
class ChangePasswordFormDialog:public GUIFormBaseDialog{
Q_OBJECT
public:
explicit ChangePasswordFormDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~ChangePasswordFormDialog();
protected:
bool updateReferenceData() override;
private:
QLineEdit* pwd = nullptr;
QLineEdit* new_pwd = nullptr;
QLineEdit* confirm_pwd = nullptr;
QLabel* lbl_error = nullptr;
};
#endif //GUI_CHANGEPASSWORDFORMDIALOG_H

View File

@@ -0,0 +1,65 @@
//
// Created by Krad on 2021/11/10.
//
#include "GUIFormBaseDialog.h"
#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");
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(tr("OK"));
btnCancel = new QPushButton(btnWidget);
btnCancel->setText(tr("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();
});
}
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);
}
}
}

View File

@@ -0,0 +1,28 @@
//
// Created by Krad on 2021/11/10.
//
#ifndef GUI_GUIFORMBASEDIALOG_H
#define GUI_GUIFORMBASEDIALOG_H
enum DialogButtonMode
{
None,OkOnly,OkAndCancel
};
#include <QDialog>
class GUIFormBaseDialog: public QDialog {
Q_OBJECT
public:
explicit GUIFormBaseDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~GUIFormBaseDialog();
void setButtonMode(DialogButtonMode mode);
protected:
virtual bool updateReferenceData(){
return false;
};
QWidget* formWidget = nullptr;
QPushButton* btnCancel = nullptr;
QPushButton* btnOk = nullptr;
};
#endif //GUI_GUIFORMBASEDIALOG_H

View File

@@ -0,0 +1,37 @@
//
// Created by Krad on 2021/11/24.
//
#include "SelectDialog.h"
#include "components/SlidePickerBox.h"
#include <QVBoxLayout>
#include <QLabel>
SelectDialog::SelectDialog(QWidget* parent, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
this->setFixedSize(360, 380);
QVBoxLayout* layout = new QVBoxLayout(formWidget);
box = new SlidePickerBox(formWidget);
box->setObjectName("slider_one");
layout->addWidget(box);
}
SelectDialog::~SelectDialog() {
}
bool SelectDialog::updateReferenceData() {
return true;
}
void SelectDialog::setValues(QStringList dates) {
box->setItems(dates);
}
QString SelectDialog::getSelectedValue() {
return box->getSelectedValue();
}
void SelectDialog::setSelectedValue(const QString& val) {
box->setSelectedValue(val);
}

View File

@@ -0,0 +1,24 @@
//
// Created by Krad on 2021/11/24.
//
#ifndef GUI_SelectDialog_H
#define GUI_SelectDialog_H
#include "GUIFormBaseDialog.h"
class SlidePickerBox;
class SelectDialog :public GUIFormBaseDialog{
Q_OBJECT
public:
explicit SelectDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
~SelectDialog() override;
void setValues(QStringList values);
QString getSelectedValue();
void setSelectedValue(const QString& val);
protected:
bool updateReferenceData() override;
SlidePickerBox* box = nullptr;
};
#endif //GUI_SelectDialog_H

View File

@@ -0,0 +1,107 @@
#include "log/UserOperationLog.h"
#include "guimessagedialog.h"
#include "ui_guimessagedialog.h"
#include "event/EventCenter.h"
GUIMessageDialog::GUIMessageDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::GUIMessageDialog)
{
ui->setupUi(this);
this->setObjectName("MessageDialog");
this->setWindowFlags (Qt :: FramelessWindowHint | Qt :: Dialog);
this->showFullScreen ();
ui->lbl_msg->setVisible(false);
ui->lbl_progressicon->setVisible(false);
ui->btn_main->setVisible(false);
ui->btn_main->setText("OK");
this->setWindowOpacity(0.6);
for (int i=1; i<=6;i++)
{
QString str(" ");
for(int j=0;j<i;j++)
{
str[j]='.';
}
frame.append(str);
}
for (int i=1; i<=6;i++)
{
QString str("......");
for(int j=0;j<i;j++)
{
str[j]=' ';
}
frame.append(str);
}
}
GUIMessageDialog::~GUIMessageDialog()
{
delete ui;
}
void GUIMessageDialog::timerEvent(QTimerEvent *event) {
if (frameIndex>11) frameIndex = frameIndex % 12;
ui->lbl_progressicon->setText(frame[frameIndex++]);
this->update();
}
void GUIMessageDialog::stopLoading() {
if (timerID!=-1){
killTimer(timerID);
timerID=-1;
}
disconnect(ui->btn_main,0,0,0);
ui->lbl_progressicon->setVisible(false);
}
void GUIMessageDialog::startLoading() {
ui->lbl_progressicon->setVisible(true);
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
}
accept();
EventCenter::Default()->triggerEvent(GUIEvents::RequestStop, nullptr, nullptr);
LOG_USER_OPERATION(Stop);
});
timerID = startTimer(100);
ui->btn_main->setText("Stop");
ui->btn_main->setVisible(true);
}
void GUIMessageDialog::showMessage(QString msg) {
ui->lbl_msg->setVisible(true);
ui->lbl_msg->setText(msg);
}
void GUIMessageDialog::showExitButton() {
ui->btn_main->setText("OK");
ui->btn_main->setVisible(true);
disconnect(ui->btn_main,0,0,0);
connect(ui->btn_main,&QToolButton::clicked,[=](){
if (timerID != -1){
killTimer(timerID);
timerID = -1;
}
accept();
LOG_USER_OPERATION(ConfirmError);
});
}
void GUIMessageDialog::hideMessage() {
ui->lbl_msg->setVisible(false);
ui->lbl_msg->setText("");
}
void GUIMessageDialog::hideExitButton() {
ui->btn_main->setVisible(false);
disconnect(ui->btn_main,0,0,0);
}
void GUIMessageDialog::setOpacity(double opacity) {
this->setWindowOpacity(opacity);
}

View File

@@ -0,0 +1,33 @@
#ifndef GUIMESSAGEDIALOG_H
#define GUIMESSAGEDIALOG_H
#include <QDialog>
#include <QList>
namespace Ui {
class GUIMessageDialog;
}
class GUIMessageDialog : public QDialog
{
Q_OBJECT
public:
explicit GUIMessageDialog(QWidget *parent = nullptr);
~GUIMessageDialog();
void showMessage(QString msg);
void hideMessage();
void showExitButton();
void hideExitButton();
void startLoading();
void stopLoading();
void setOpacity(double);
protected:
void timerEvent(QTimerEvent* event) override ;
private:
Ui::GUIMessageDialog *ui;
QList<QString> frame;
int frameIndex=0;
int timerID = -1;
};
#endif // GUIMESSAGEDIALOG_H

View File

@@ -0,0 +1,116 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GUIMessageDialog</class>
<widget class="QDialog" name="GUIMessageDialog">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1433</width>
<height>906</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>680</number>
</property>
<property name="topMargin">
<number>380</number>
</property>
<property name="rightMargin">
<number>680</number>
</property>
<property name="bottomMargin">
<number>380</number>
</property>
<item>
<widget class="QWidget" name="innerWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QWidget" name="widget_2" native="true">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="lbl_msg">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lbl_progressicon">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QToolButton" name="btn_main">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>