diff --git a/DOCS/Андрей/Board.md b/DOCS/Андрей/Board.md index dbf485e..2a0faaf 100644 --- a/DOCS/Андрей/Board.md +++ b/DOCS/Андрей/Board.md @@ -12,6 +12,9 @@ kanban-plugin: board ## Completed +- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!) + [Возможно, поможет переинициализация мессенджера при переавторизации инструктора?] +- [ ] Отображать текущую версию data в статус баре - [ ] Сделать крутилку на начальную загрузку Сервера - [ ] Логин суперпользователя PostgreSQL предлагать по умолчанию postgres - [ ] Сделать несколько попыток подключения к серверу @@ -64,15 +67,12 @@ kanban-plugin: board ## GUI Messenger -- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!) - [Возможно, поможет переинициализация мессенджера при переавторизации инструктора?] - [ ] Не влазиют слишком большие сообщения - [ ] Не видно новых пришедших сообщений, если выбран другой Юзер ## GUI общие -- [ ] Отображать текущую версию data в статус баре - [ ] Текстовый поиск в задачах diff --git a/GUIdataBaseLMS/mainwindow.cpp b/GUIdataBaseLMS/mainwindow.cpp index e5e3cdb..1290c67 100644 --- a/GUIdataBaseLMS/mainwindow.cpp +++ b/GUIdataBaseLMS/mainwindow.cpp @@ -13,11 +13,10 @@ MainWindow::MainWindow(QWidget *parent) ui->setupUi(this); instructorsAndTraineesWidget = new InstructorsAndTraineesWidget(this); + ui->horizontalLayout->addWidget(instructorsAndTraineesWidget); connect(instructorsAndTraineesWidget, &InstructorsAndTraineesWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged); - ui->horizontalLayout->addWidget(instructorsAndTraineesWidget); - this->move(0, 0); //this->showNormal(); this->showMaximized(); diff --git a/InstructorsAndTrainees/CMakeLists.txt b/InstructorsAndTrainees/CMakeLists.txt index d6cc70a..2731772 100644 --- a/InstructorsAndTrainees/CMakeLists.txt +++ b/InstructorsAndTrainees/CMakeLists.txt @@ -27,8 +27,6 @@ add_library(InstructorsAndTrainees SHARED specialmessagebox/specialmessagebox.cpp specialmessagebox/specialmessagebox.h specialmessagebox/specialmessagebox.ui - specialmessagebox/notifycontroller.cpp - specialmessagebox/notifycontroller.h authorization/dialogauthorization.cpp authorization/dialogauthorization.h @@ -141,6 +139,8 @@ add_library(InstructorsAndTrainees SHARED widgets/waitanimationwidget.cpp widgets/waitanimationwidget.h widgets/waitanimationwidget.ui + widgets/widgettools.cpp + widgets/widgettools.h InstructorsAndTrainees.qrc ) diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 8705ca1..ea1e1cd 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp @@ -413,7 +413,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket) QFile xmlInFile(xmlFileName); if (!xmlInFile.open(QFile::ReadOnly | QFile::Text)) { - SpecialMessageBox(nullptr, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + xmlFileName).exec(); + SpecMsgBox::CriticalClose(nullptr, tr("The file could not be opened ") + xmlFileName); return; } else @@ -490,17 +490,17 @@ void RecognizeSystem::xmlParser(QByteArray array) if (value == "BASEDELETETRY") { - emit sigNotify(tr("You cannot delete the basic version!")); + emit sigNotifyVersionControl(tr("You cannot delete the basic version!")); } if (value == "TRYACTIVEDELETE") { - emit sigNotify(tr("You cannot delete the active version")); + emit sigNotifyVersionControl(tr("You cannot delete the active version")); } if (value == "DUPLICATEVERNAME") { - emit sigNotify(tr("This name already exists")); + emit sigNotifyVersionControl(tr("This name already exists")); } } } diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h index f679249..d731718 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h @@ -56,7 +56,7 @@ signals: void sigAnswerQueryTasksXML_AMM(QByteArray array); void sigShowServerDataList(QList *versions); void sigSetVersion(StreamingVersionData* serverVersion); - void sigNotify(QString text, QWidget *parentWidget = nullptr); + void sigNotifyVersionControl(QString text); void sigAnimationActivated(bool flag); void sigHashReady(); void sigAnswerQuerySubProc(QList listSubProc, QString parentTask_dmCode); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index 839809e..7f27b0c 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -1,15 +1,13 @@ #include "connectortoserver.h" #include -ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : +ConnectorToServer::ConnectorToServer(QObject *parent) : QObject(parent), - parentWidget(parentWidget), connectionThread(nullptr), client(nullptr), dataParser(nullptr), sendSystem(nullptr), recognizeSystem(nullptr), - notifyController(nullptr), fl_GetedOfflineMessages(false), nameInstructorLoggedInLocal("") { @@ -19,7 +17,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : ConnectorToServer::~ConnectorToServer() { delete client; - delete notifyController; delete recognizeSystem; delete sendSystem; delete dataParser; @@ -115,6 +112,11 @@ void ConnectorToServer::slot_getVersion() emit signal_SendGetVersion(); } +void ConnectorToServer::slot_NotifyVersionControl(QString text) +{ + emit signal_NotifyVersionControl(text); +} + void ConnectorToServer::initialize() { createObjects(); @@ -159,7 +161,7 @@ void ConnectorToServer::bindConnection() connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer,Qt::AutoConnection); - connect(recognizeSystem,&RecognizeSystem::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection); + connect(recognizeSystem,&RecognizeSystem::sigNotifyVersionControl,this,&ConnectorToServer::slot_NotifyVersionControl,Qt::AutoConnection); connect(recognizeSystem,&RecognizeSystem::sigHashReady,this,&ConnectorToServer::slot_HashReady); @@ -190,8 +192,6 @@ void ConnectorToServer::createObjects() recognizeSystem = new RecognizeSystem; recognizeSystem->moveToThread(connectionThread); - notifyController = new NotifyController(parentWidget); - connectionThread->start(); connectionThread->setPriority(QThread::HighestPriority); } diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index be5d2db..cace4d2 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -14,7 +14,6 @@ #include "computer.h" #include "classroom.h" #include "Datas.h" -#include "notifycontroller.h" #include "streamingversiondata.h" class ConnectorToServer : public QObject @@ -22,7 +21,7 @@ class ConnectorToServer : public QObject Q_OBJECT public: - explicit ConnectorToServer(QWidget* parentWidget, QObject *parent = nullptr); + explicit ConnectorToServer(QObject *parent = nullptr); ~ConnectorToServer(); public: @@ -116,6 +115,8 @@ public slots: void slot_getVersion(); + void slot_NotifyVersionControl(QString text); + signals: void sigSetConnect(ServerSettings* serverSettings,QThread *thread); void sigStopConnect(); @@ -157,19 +158,19 @@ signals: void signal_showServerList(QList *serverList); void signal_SendGetVersion(); + void signal_NotifyVersionControl(QString text); + private: void initialize(); void bindConnection(); void createObjects(); private: - QWidget* parentWidget; QThread *connectionThread; TCPClient *client; DataParser *dataParser; SendSystem *sendSystem; RecognizeSystem *recognizeSystem; - NotifyController *notifyController; //Списочная модель БД СУО QMutex mtxAccess; diff --git a/InstructorsAndTrainees/instructors/dialogeditinstructor.cpp b/InstructorsAndTrainees/instructors/dialogeditinstructor.cpp index b9c0651..1eb1547 100644 --- a/InstructorsAndTrainees/instructors/dialogeditinstructor.cpp +++ b/InstructorsAndTrainees/instructors/dialogeditinstructor.cpp @@ -22,7 +22,7 @@ DialogEditInstructor::DialogEditInstructor(bool adminMode, QWidget *parent) : ui->btnViewPassword->setObjectName("btnViewPassword"); ui->btnChangePassword->setObjectName("btnChangePassword"); - ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); + //ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this)); ui->editPassword->setEnabled(false); diff --git a/InstructorsAndTrainees/instructors/dialogeditinstructor.h b/InstructorsAndTrainees/instructors/dialogeditinstructor.h index 567191b..398a787 100644 --- a/InstructorsAndTrainees/instructors/dialogeditinstructor.h +++ b/InstructorsAndTrainees/instructors/dialogeditinstructor.h @@ -3,7 +3,7 @@ #include #include "instructor.h" -#include "ui_dialogeditinstructor.h" +//#include "ui_dialogeditinstructor.h" namespace Ui { class DialogEditInstructor; diff --git a/InstructorsAndTrainees/instructors/editorinstructors.cpp b/InstructorsAndTrainees/instructors/editorinstructors.cpp index c3b2712..223358a 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.cpp +++ b/InstructorsAndTrainees/instructors/editorinstructors.cpp @@ -1,12 +1,12 @@ #include #include "editorinstructors.h" -#include "dialogeditinstructor.h" #include "specialmessagebox.h" #include "ui_editorinstructors.h" EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : InstructorsView(connectorToServer, CommonView::TypeView::control, parent), - ui(new Ui::EditorInstructors) + ui(new Ui::EditorInstructors), + dlgEditInstructor(nullptr) { ui->setupUi(this); @@ -34,12 +34,20 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool EditorInstructors::~EditorInstructors() { + if(dlgEditInstructor) + { + dlgEditInstructor->close(); + delete dlgEditInstructor; + dlgEditInstructor = nullptr; + } + delete ui; } void EditorInstructors::closeEvent(QCloseEvent *event) { - + if(dlgEditInstructor) + dlgEditInstructor->close(); } void EditorInstructors::on_btnNewInstructor_clicked() @@ -74,17 +82,17 @@ void EditorInstructors::on_btnDeleteInstructor_clicked() if(connectorToServer->isAdminInstructor(id)) {//Это Админ! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete the Administrator.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot delete the Administrator.")); return; } if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in instructor.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in instructor.")); return; } - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id); @@ -119,7 +127,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked() {//Не Архивный if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in instructor.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in instructor.")); return; } @@ -156,7 +164,7 @@ void EditorInstructors::on_btnEdit_clicked() if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in instructor.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in instructor.")); return; } @@ -262,19 +270,19 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) if(instructor.getName() == QStringLiteral("")) {//Имя не корректно! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getLogin() == QStringLiteral("")) {//Логин не корректен! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getPassword() == QStringLiteral("")) {//Пароль не корректный! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); return false; } @@ -283,7 +291,7 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin()); if((user_I && (user_I != instructor.getID())) || (user_T && (user_T != instructor.getID()))) {//Логин уже существует! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } @@ -292,22 +300,25 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instructor_edit) { - DialogEditInstructor dlg(adminMode, this); - dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint); + dlgEditInstructor = new DialogEditInstructor(adminMode, this); + dlgEditInstructor->setWindowFlags(dlgEditInstructor->windowFlags() & ~Qt::WindowContextHelpButtonHint); - dlg.setInstructor(instructor); + dlgEditInstructor->setInstructor(instructor); - while (true) + bool flStop = false; + bool res = false; + + while (!flStop) { - switch( dlg.exec() ) + switch( dlgEditInstructor->exec() ) { case QDialog::Accepted: { - *instructor_edit = dlg.getInstructor(); + *instructor_edit = dlgEditInstructor->getInstructor(); if(! verifyInstructor(*instructor_edit)) { - dlg.setInstructor(*instructor_edit); + dlgEditInstructor->setInstructor(*instructor_edit); continue; } @@ -318,14 +329,28 @@ bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instru instructor_edit->setNeedSetPassword(false); } - return true; + flStop = true; + res = true; + break; } case QDialog::Rejected: - return false; + flStop = true; + res = false; + break; default: - return false; + flStop = true; + res = false; + break; } } + + if(dlgEditInstructor) + { + delete dlgEditInstructor; + dlgEditInstructor = nullptr; + } + + return res; } diff --git a/InstructorsAndTrainees/instructors/editorinstructors.h b/InstructorsAndTrainees/instructors/editorinstructors.h index 94cfe24..fa0c280 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -4,6 +4,10 @@ #include #include #include "instructorsview.h" +#include "dialogeditinstructor.h" +#include "specialmessagebox.h" + +class DialogEditInstructor; namespace Ui { class EditorInstructors; @@ -35,8 +39,10 @@ private: bool editInstructor(Instructor instructor, Instructor* instructor_edit); -private: +private: Ui::EditorInstructors *ui; + + DialogEditInstructor* dlgEditInstructor; }; #endif // DIALOGINSTRUCTORS_H diff --git a/InstructorsAndTrainees/instructors/editorinstructors.ui b/InstructorsAndTrainees/instructors/editorinstructors.ui index 1f1de14..0f9f1b9 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.ui +++ b/InstructorsAndTrainees/instructors/editorinstructors.ui @@ -51,7 +51,7 @@ New instructor - + :/resources/icons/addInstructor.png:/resources/icons/addInstructor.png @@ -89,7 +89,7 @@ Delete instructor - + :/resources/icons/deleteInstructor.png:/resources/icons/deleteInstructor.png @@ -127,7 +127,7 @@ To archive - + :/resources/icons/instructorArchive.png:/resources/icons/instructorArchive.png @@ -165,7 +165,7 @@ Edit - + :/resources/icons/edit.png:/resources/icons/edit.png @@ -216,7 +216,7 @@ Show archive - + :/resources/icons/archive.png:/resources/icons/archive.png @@ -240,7 +240,7 @@ - + diff --git a/InstructorsAndTrainees/instructors/viewerinstructors.cpp b/InstructorsAndTrainees/instructors/viewerinstructors.cpp index 58499e8..e22505e 100644 --- a/InstructorsAndTrainees/instructors/viewerinstructors.cpp +++ b/InstructorsAndTrainees/instructors/viewerinstructors.cpp @@ -25,7 +25,11 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg ViewerInstructors::~ViewerInstructors() { if(dlgRedactor) + { dlgRedactor->close(); + delete dlgRedactor; + dlgRedactor = nullptr; + } delete ui; } @@ -38,7 +42,11 @@ void ViewerInstructors::setAuthComplited(bool authComplited) void ViewerInstructors::deactivate() { if(dlgRedactor) + { dlgRedactor->close(); + delete dlgRedactor; + dlgRedactor = nullptr; + } CommonView::deactivate(); updateButtons(); diff --git a/InstructorsAndTrainees/instructors/viewerinstructors.ui b/InstructorsAndTrainees/instructors/viewerinstructors.ui index e21ea15..319eb41 100644 --- a/InstructorsAndTrainees/instructors/viewerinstructors.ui +++ b/InstructorsAndTrainees/instructors/viewerinstructors.ui @@ -44,7 +44,7 @@ Editor of Instructors - + :/resources/icons/DB-instructors.png:/resources/icons/DB-instructors.png @@ -67,7 +67,7 @@ - + diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index ecd32f6..8b80c1f 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -7,6 +7,7 @@ #include "dialogsettings.h" #include "specialmessagebox.h" #include "hashtools.h" +#include "widgettools.h" const QString InstructorsAndTraineesWidget::languageENG = "en_EN"; @@ -14,8 +15,7 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU"; InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : - QWidget(parent), - waitAnimationWidget(nullptr), + QWidget(parent), connectorToServer(nullptr), viewerTrainees(nullptr), viewerInstructors(nullptr), @@ -24,15 +24,12 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : dlgTasksCommon(nullptr), dlgSettings(nullptr), dlgAuthorization(nullptr), - adminMode(false), - loginInstructorLoggedInLocal(QStringLiteral("")), - nameInstructorLoggedInLocal(QStringLiteral("")), - idInstructorLoggedInLocal("0"), - language(languageENG), + waitAnimationWidget(nullptr), flSettingsServerIsChanged(false), flTryConnectToServer(false), cntTryConnectToServer(0), flTryLogin(false), + language(languageENG), ui(new Ui::InstructorsAndTraineesWidget) { ui->setupUi(this); @@ -50,7 +47,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : setLanguageInterfase(); - connectorToServer = new ConnectorToServer(this); + connectorToServer = new ConnectorToServer(); connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult); connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult); connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked); @@ -108,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget() { if(authorizationIsCompleted()) - deAuthorizationInstructor(loginInstructorLoggedInLocal); + deAuthorizationInstructor(instructorLoggedInLocal.getLogin()); if(dlgTasksCommon) { @@ -154,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event) {// переведём окно заново ui->retranslateUi(this); - updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal); + updateLabelLoggedInInstructor(instructorLoggedInLocal); updateLabelServer(); } } @@ -179,7 +176,7 @@ QString InstructorsAndTraineesWidget::loadStyleSheet() QFile styleSheetFile(fileName); if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text)) { - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + fileName).exec(); + SpecMsgBox::CriticalClose(this, tr("The file could not be opened ") + fileName); return QStringLiteral(""); } else @@ -209,28 +206,28 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se { if (serverAuth->Result) { - loginInstructorLoggedInLocal = serverAuth->Login; - nameInstructorLoggedInLocal = serverAuth->ClientName; - idInstructorLoggedInLocal = serverAuth->Id; + instructorLoggedInLocal.setLogin(serverAuth->Login); + instructorLoggedInLocal.setName(serverAuth->ClientName); + instructorLoggedInLocal.setID(serverAuth->Id.toInt()); - if(loginInstructorLoggedInLocal == QStringLiteral("admin")) - adminMode = true; + if(serverAuth->Login == QStringLiteral("admin")) + instructorLoggedInLocal.setIsAdmin(true); else - adminMode = false; + instructorLoggedInLocal.setIsAdmin(false); - viewerInstructors->setAdminMode(adminMode); - viewerTrainees->setAdminMode(adminMode); + viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin()); + viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin()); viewerInstructors->setAuthComplited(true); viewerTrainees->setAuthComplited(true); ui->btnEditorTrainees->setEnabled(true); - if(adminMode) + if(instructorLoggedInLocal.getIsAdmin()) ui->btnEditorInstructors->setEnabled(true); emit signal_NeedUpdateUI(true, true); - updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName); - connectorToServer->setLoginName(nameInstructorLoggedInLocal); + updateLabelLoggedInInstructor(instructorLoggedInLocal); + connectorToServer->setLoginName(instructorLoggedInLocal.getName()); messangerController->setUserLocalGUI_ID(serverAuth->Id.toInt()); @@ -255,12 +252,13 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization { if (serverDeAuth->Result) { - loginInstructorLoggedInLocal = QStringLiteral(""); - nameInstructorLoggedInLocal = QStringLiteral(""); - adminMode = false; + instructorLoggedInLocal.setLogin(QStringLiteral("")); + instructorLoggedInLocal.setName(QStringLiteral("")); + instructorLoggedInLocal.setIsAdmin(false); + instructorLoggedInLocal.setID(0); - viewerInstructors->setAdminMode(adminMode); - viewerTrainees->setAdminMode(adminMode); + viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin()); + viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin()); viewerInstructors->setAuthComplited(false); viewerTrainees->setAuthComplited(false); @@ -268,12 +266,12 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization ui->btnEditorInstructors->setEnabled(false); ui->btnPersonalCard->setEnabled(false); - updateLabelLoggedInInstructor("",""); + updateLabelLoggedInInstructor(instructorLoggedInLocal); } else { ui->btnAuthorizationInstructor->setChecked(true); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); + SpecMsgBox::CriticalClose(this, tr("Instructor deauthorization") + "\n" + tr("Error!")); } } @@ -285,7 +283,7 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked() waitAnimationWidget->hideWithStop(); ui->btnAuthorizationInstructor->setChecked(false); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + tr("Server blocked!")); } } @@ -317,7 +315,7 @@ void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error) errorTextMsg = tr("Login or password error!"); } - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + errorTextMsg); } } @@ -336,7 +334,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png"))); - updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal); + updateLabelLoggedInInstructor(instructorLoggedInLocal); flTryConnectToServer = false; cntTryConnectToServer = 0; @@ -375,10 +373,12 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) messangerController->deleteAllWidgets(); - loginInstructorLoggedInLocal = ""; - nameInstructorLoggedInLocal = ""; + instructorLoggedInLocal.setLogin(QStringLiteral("")); + instructorLoggedInLocal.setName(QStringLiteral("")); + instructorLoggedInLocal.setIsAdmin(false); + instructorLoggedInLocal.setID(0); - updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal); + updateLabelLoggedInInstructor(instructorLoggedInLocal); if(flTryConnectToServer) @@ -386,7 +386,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(cntTryConnectToServer < 10) { cntTryConnectToServer++; - QTimer::singleShot(1000, this, SLOT(slot_ConnectToServer())); + QTimer::singleShot(1000, this, SLOT(slot_TryConnectToServer())); } else { @@ -406,7 +406,10 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(!flSettingsServerIsChanged) { if(!flTryConnectToServer) - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); + { + WidgetTools::closeAllChildWidgets(this, "SpecMsgBox"); + SpecMsgBox::WarningClose(this, tr("The server is not available!")); + } } else flSettingsServerIsChanged = false; @@ -443,7 +446,7 @@ void InstructorsAndTraineesWidget::slot_instructorSelected(int id_instructor) /*Messanger*/ messangerController->deleteWidget(messangerWidget); - if(id_instructor && id_instructor != idInstructorLoggedInLocal.toInt()) + if(id_instructor && id_instructor != instructorLoggedInLocal.getID()) { Instructor instructor = connectorToServer->getInstructor(id_instructor); if(instructor.getID()) @@ -456,7 +459,7 @@ void InstructorsAndTraineesWidget::slot_AnswerDocsChanged() viewerTrainees->getAmmTasksWidgetCommon()->setDocsActualed(false); } -void InstructorsAndTraineesWidget::slot_ConnectToServer() +void InstructorsAndTraineesWidget::slot_TryConnectToServer() { updateLabelServer(); connectorToServer->SetConnectToServer(); @@ -519,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login) bool InstructorsAndTraineesWidget::authorizationIsCompleted() { - if(loginInstructorLoggedInLocal == QStringLiteral("")) + if(instructorLoggedInLocal.getLogin() == QStringLiteral("")) return false; else return true; @@ -536,7 +539,7 @@ void InstructorsAndTraineesWidget::on_btnConnectionToServer_clicked() updateLabelServer(); - QTimer::singleShot(1000, this, SLOT(slot_ConnectToServer())); + QTimer::singleShot(1000, this, SLOT(slot_TryConnectToServer())); } void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked() @@ -558,7 +561,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked() {//ДеАвторизация Инструктора локальная (Администратора) if(authorizationIsCompleted()) { - if(deAuthorizationInstructor(loginInstructorLoggedInLocal)) + if(deAuthorizationInstructor(instructorLoggedInLocal.getLogin())) { disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI); disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerTrainees,&ViewerTrainees::slot_NeedUpdateUI); @@ -578,13 +581,13 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked() } } -void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login, QString name) +void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(Instructor& instructor) { if(authorizationIsCompleted()) { - QString nameLoggedInInstructor = QString("%1 (%2)").arg(name, login); + QString nameLoggedInInstructor = QString("%1 (%2)").arg(instructor.getName(), instructor.getLogin()); ui->lblLoggedInInstructor->setText(nameLoggedInInstructor); - if(loginInstructorLoggedInLocal == QStringLiteral("admin")) + if(instructor.getIsAdmin()) ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/admin.png"))); else ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/instructor.png"))); @@ -640,7 +643,7 @@ void InstructorsAndTraineesWidget::setLanguageInterfase() void InstructorsAndTraineesWidget::on_btnSettings_clicked() { - dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this); + dlgSettings = new DialogSettings(connectorToServer, authorizationIsCompleted(), this); dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint); connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged); @@ -654,12 +657,12 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked() if(dlgSettings->settingsServerIsChanged()) { - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); + SpecMsgBox::WarningClose(this, tr("Server settings have been changed.\nPlease reconnect to the server.")); flSettingsServerIsChanged = true; if(authorizationIsCompleted()) - deAuthorizationInstructor(loginInstructorLoggedInLocal); + deAuthorizationInstructor(instructorLoggedInLocal.getLogin()); connectorToServer->StopConnectToServer(); } diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 747ffd6..1d3008e 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.h +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.h @@ -13,6 +13,7 @@ #include "dialogtaskscommon.h" #include "dialogsettings.h" #include "dialogauthorization.h" +#include "instructor.h" namespace Ui { @@ -65,7 +66,7 @@ public Q_SLOTS: void slot_AnswerDocsChanged(); - void slot_ConnectToServer(); + void slot_TryConnectToServer(); Q_SIGNALS: //сигнал смены языка @@ -79,24 +80,18 @@ private Q_SLOTS: void on_btnSettings_clicked(); void on_btnEditorTrainees_clicked(); void on_btnEditorInstructors_clicked(); - void on_btnPersonalCard_clicked(); - void on_btnTasksCommon_clicked(); private: - //Авторизация инструктора локальная (на ГУИ) bool authorizationInstructorDialog(QWidget* parent = nullptr); bool deAuthorizationInstructor(QString login); bool authorizationIsCompleted(); - void updateLabelLoggedInInstructor(QString login, QString name); + void updateLabelLoggedInInstructor(Instructor& instructor); void updateLabelServer(); - void setLanguageInterfase(); private: - WaitAnimationWidget *waitAnimationWidget; - ConnectorToServer* connectorToServer; ViewerTrainees* viewerTrainees; @@ -108,13 +103,9 @@ private: DialogSettings* dlgSettings; DialogAuthorization* dlgAuthorization; - bool adminMode; - QString loginInstructorLoggedInLocal; - QString nameInstructorLoggedInLocal; - QString idInstructorLoggedInLocal; + WaitAnimationWidget *waitAnimationWidget; - QTranslator qtLanguageTranslator; - QString language; + Instructor instructorLoggedInLocal; bool flSettingsServerIsChanged; @@ -123,6 +114,9 @@ private: bool flTryLogin; + QTranslator qtLanguageTranslator; + QString language; + Ui::InstructorsAndTraineesWidget *ui; }; diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.ui b/InstructorsAndTrainees/instructorsandtraineeswidget.ui index f6b7147..ed5730c 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.ui +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.ui @@ -6,8 +6,8 @@ 0 0 - 1314 - 901 + 1300 + 900 diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index c881502..070e5d0 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp @@ -57,6 +57,7 @@ void DialogVersionControl::initialize(QString authorName) connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation); connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList); + connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl); connect(this, &DialogVersionControl::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion); connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion); @@ -114,7 +115,7 @@ void DialogVersionControl::sendCopyEmit(QString newName) if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -127,7 +128,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -160,7 +161,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -172,7 +173,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -209,6 +210,11 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion) flGetVersion = true; } +void DialogVersionControl::slot_NotifyVersionControl(QString text) +{ + SpecMsgBox::WarningClose(this, text); +} + void DialogVersionControl::resizeEvent(QResizeEvent *event) { QSize size = event->size(); diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.h b/InstructorsAndTrainees/settings/dialogversioncontrol.h index 146f1fb..fe697d9 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.h +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.h @@ -39,6 +39,7 @@ private slots: void slot_activateLoadAnimation(bool flag); void slot_showServerList(QList *serverList); void slot_SetVersion(StreamingVersionData* serverVersion); + void slot_NotifyVersionControl(QString text); signals: void sigSendDeleteVersion(StreamingVersionData *streaming); diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp deleted file mode 100644 index 659ae1c..0000000 --- a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include - -#include "notifycontroller.h" -#include "specialmessagebox.h" - -NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) : - QObject(parent), - parentWidget(parentWidget) -{ - -} - -void NotifyController::showWarning(QString text, QWidget *parentWidget) -{ - if(parentWidget) - SpecialMessageBox(parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); - else - SpecialMessageBox(this->parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); -} diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.h b/InstructorsAndTrainees/specialmessagebox/notifycontroller.h deleted file mode 100644 index 638e30b..0000000 --- a/InstructorsAndTrainees/specialmessagebox/notifycontroller.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef NOTIFYCONTROLLER_H -#define NOTIFYCONTROLLER_H - -#include -#include - -class NotifyController : public QObject -{ - Q_OBJECT -public: - explicit NotifyController(QWidget *parentWidget = nullptr, QObject *parent = nullptr); - - void showWarning(QString text, QWidget *parentWidget = nullptr); - -private: - QWidget *parentWidget; - -}; - -#endif // NOTIFYCONTROLLER_H diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp index 11ff87b..c427873 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -2,12 +2,14 @@ #include "specialmessagebox.h" #include "ui_specialmessagebox.h" -SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) : +SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) : QDialog(parent), ui(new Ui::SpecialMessageBox) { ui->setupUi(this); + this->setObjectName("SpecMsgBox"); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); if(type == TypeSpecMsgBox::warningYesNo) @@ -22,14 +24,14 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const ui->btnNo->setVisible(false); ui->btnYes->setText(tr("Close")); } - else if(type == TypeSpecMsgBox::critical) + else if(type == TypeSpecMsgBox::criticalClose) { ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/critical.png"))); this->setWindowTitle(tr("Error!")); ui->btnNo->setVisible(false); ui->btnYes->setText(tr("Close")); } - else if(type == TypeSpecMsgBox::info) + else if(type == TypeSpecMsgBox::infoOk) { ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/info.png"))); this->setWindowTitle(tr("Information")); @@ -40,17 +42,43 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const ui->lblText->setText(text); } -SpecialMessageBox::~SpecialMessageBox() +SpecMsgBox::~SpecMsgBox() { delete ui; } -void SpecialMessageBox::on_btnYes_clicked() +int SpecMsgBox::WarningYesNo(QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningYesNo, text); +} + +int SpecMsgBox::WarningClose(QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningClose, text); +} + +int SpecMsgBox::CriticalClose(QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(parent, TypeSpecMsgBox::criticalClose, text); +} + +int SpecMsgBox::InfoOk(QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(parent, TypeSpecMsgBox::infoOk, text); +} + +int SpecMsgBox::work(QWidget *parent, TypeSpecMsgBox type, const QString& text) +{ + SpecMsgBox *msgBox = new SpecMsgBox(parent, type, text); + return msgBox->exec(); +} + +void SpecMsgBox::on_btnYes_clicked() { this->accept(); } -void SpecialMessageBox::on_btnNo_clicked() +void SpecMsgBox::on_btnNo_clicked() { this->reject(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h index 4bbc082..e01c823 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h @@ -2,12 +2,13 @@ #define SPECIALMESSAGEBOX_H #include +#include "instructorsAndTrainees_global.h" namespace Ui { class SpecialMessageBox; } -class SpecialMessageBox : public QDialog +class INSTRUCTORSANDTRAINEES_EXPORT SpecMsgBox : public QDialog { Q_OBJECT @@ -15,13 +16,23 @@ public: enum TypeSpecMsgBox { warningYesNo, warningClose, - critical, - info + criticalClose, + infoOk }; +private: + explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); public: - explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); - ~SpecialMessageBox(); + ~SpecMsgBox(); + +public: + static int WarningYesNo(QWidget *parent, const QString& text); + static int WarningClose(QWidget *parent, const QString& text); + static int CriticalClose(QWidget *parent, const QString& text); + static int InfoOk(QWidget *parent, const QString& text); + +private: + static int work(QWidget *parent, TypeSpecMsgBox type, const QString& text); private slots: void on_btnYes_clicked(); diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp index f66b0d9..2a7d59a 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -9,6 +9,7 @@ #include "ui_ammtaskswidget.h" #include "checkertask.h" #include "specialmessagebox.h" +#include "widgettools.h" AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) : QWidget(parent), @@ -145,16 +146,17 @@ void AMMtasksWidget::resizeEvent(QResizeEvent *event) waitAnimationWidget->resize(size); } -void AMMtasksWidget::closeDlgCheckTask() +void AMMtasksWidget::closeEvent(QCloseEvent *event) +{ + closeChildDlg(); +} + +void AMMtasksWidget::closeChildDlg() { if(dlgCheckerTask) dlgCheckerTask->close(); -} - -void AMMtasksWidget::closeDlgListSubProc() -{ if(dlgListSubProc) - dlgListSubProc->close(); + dlgListSubProc->close(); } void AMMtasksWidget::changeEvent(QEvent *event) @@ -325,7 +327,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) lastSelectedTask.listSubProc.clear(); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } @@ -347,7 +349,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) { lastSelectedTask.listSubProc.clear(); - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } @@ -504,7 +506,7 @@ void AMMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id); diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index 900a4e9..32bba57 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.h +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.h @@ -10,6 +10,7 @@ #include "dialogchekertask.h" #include "dialoglistsubproc.h" #include "waitanimationwidget.h" +#include "specialmessagebox.h" namespace Ui { class AMMtasksWidget; @@ -31,8 +32,10 @@ public: public: void resizeEvent(QResizeEvent *event) override; - void closeDlgCheckTask(); - void closeDlgListSubProc(); + void closeEvent(QCloseEvent *event) override; + + void closeChildDlg(); + protected: void changeEvent(QEvent * event) override; diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index b0ab2ac..a4af13e 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -48,6 +48,7 @@ CheckerTask::~CheckerTask() delete fimTasksWidget; fimTasksWidget = nullptr; } + delete ui; } @@ -175,7 +176,7 @@ void CheckerTask::on_btnWrong_clicked() msgString = tr("Change task status?\nThe status will be set:\n'new'"); } - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); @@ -202,7 +203,7 @@ void CheckerTask::on_btnRight_clicked() msgString = tr("Change task status?\nThe status will be set:\n'completed'"); } - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index f08edeb..639e55c 100644 --- a/InstructorsAndTrainees/tasks/checkertask.h +++ b/InstructorsAndTrainees/tasks/checkertask.h @@ -6,6 +6,7 @@ //#include "fimtaskswidget.h" #include "module.h" #include "connectortoserver.h" +#include "specialmessagebox.h" namespace Ui { class CheckerTask; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index c87c9e2..70e58b5 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -101,9 +101,7 @@ FIMtasksWidget::~FIMtasksWidget() delete treeWidget; if(dlgCheckerTask) - { dlgCheckerTask->close(); - } delete ui; } @@ -130,7 +128,12 @@ void FIMtasksWidget::resizeEvent(QResizeEvent *event) waitAnimationWidget->resize(size); } -void FIMtasksWidget::closeDlgCheckTask() +void FIMtasksWidget::closeEvent(QCloseEvent *event) +{ + closeChildDlg(); +} + +void FIMtasksWidget::closeChildDlg() { if(dlgCheckerTask) dlgCheckerTask->close(); @@ -393,7 +396,7 @@ void FIMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_FIM_TO_TRAINEE, id); @@ -437,7 +440,7 @@ void FIMtasksWidget::on_btnCheck_clicked() void FIMtasksWidget::on_btnAssignTask_clicked() { - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) assignTaskFIMtoTrainee(); } diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index 34450a3..0e60bd0 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.h +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.h @@ -8,6 +8,7 @@ #include "tasktreepreparation.h" #include "dialogchekertask.h" #include "waitanimationwidget.h" +#include "specialmessagebox.h" namespace Ui { class FIMtasksWidget; @@ -31,7 +32,10 @@ public: public: void resizeEvent(QResizeEvent *event) override; - void closeDlgCheckTask(); + void closeEvent(QCloseEvent *event) override; + + void closeChildDlg(); + protected: void changeEvent(QEvent * event) override; diff --git a/InstructorsAndTrainees/trainees/dialogeditgroup.cpp b/InstructorsAndTrainees/trainees/dialogeditgroup.cpp index 51776e3..d1b0063 100644 --- a/InstructorsAndTrainees/trainees/dialogeditgroup.cpp +++ b/InstructorsAndTrainees/trainees/dialogeditgroup.cpp @@ -1,7 +1,8 @@ -#include "dialogeditgroup.h" -#include "computersLocations.h" #include #include +#include "dialogeditgroup.h" +#include "computersLocations.h" +#include "ui_dialogeditgroup.h" DialogEditGroup::DialogEditGroup(QWidget *parent) : QDialog(parent), @@ -11,7 +12,7 @@ DialogEditGroup::DialogEditGroup(QWidget *parent) : ui->setupUi(this); verify(); - ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); + //ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); ui->editName->setProperty("mandatoryField", true); } diff --git a/InstructorsAndTrainees/trainees/dialogeditgroup.h b/InstructorsAndTrainees/trainees/dialogeditgroup.h index 6ca8396..9258613 100644 --- a/InstructorsAndTrainees/trainees/dialogeditgroup.h +++ b/InstructorsAndTrainees/trainees/dialogeditgroup.h @@ -2,7 +2,7 @@ #define DIALOGEDITGROUP_H #include -#include "ui_dialogeditgroup.h" +//#include "ui_dialogeditgroup.h" #include "computersLocations.h" #include "group.h" diff --git a/InstructorsAndTrainees/trainees/dialogedittrainee.cpp b/InstructorsAndTrainees/trainees/dialogedittrainee.cpp index 4ff1e43..37ecd6a 100644 --- a/InstructorsAndTrainees/trainees/dialogedittrainee.cpp +++ b/InstructorsAndTrainees/trainees/dialogedittrainee.cpp @@ -22,7 +22,7 @@ DialogEditTrainee::DialogEditTrainee(bool adminMode, QWidget *parent) : ui->btnViewPassword->setObjectName("btnViewPassword"); ui->btnChangePassword->setObjectName("btnChangePassword"); - ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); + //ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this)); ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this)); ui->editPassword->setEnabled(false); diff --git a/InstructorsAndTrainees/trainees/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index 545a08f..e613087 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.cpp +++ b/InstructorsAndTrainees/trainees/editortrainees.cpp @@ -7,7 +7,9 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : TraineesView(connectorToServer, CommonView::TypeView::control, parent), - ui(new Ui::EditorTrainees) + ui(new Ui::EditorTrainees), + dlgEditTrainee(nullptr), + dlgEditGroup(nullptr) { ui->setupUi(this); @@ -38,12 +40,30 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM EditorTrainees::~EditorTrainees() { + if(dlgEditTrainee) + { + dlgEditTrainee->close(); + delete dlgEditTrainee; + dlgEditTrainee = nullptr; + } + + if(dlgEditGroup) + { + dlgEditGroup->close(); + delete dlgEditGroup; + dlgEditGroup = nullptr; + } + delete ui; } void EditorTrainees::closeEvent(QCloseEvent *event) { + if(dlgEditTrainee) + dlgEditTrainee->close(); + if(dlgEditGroup) + dlgEditGroup->close(); } void EditorTrainees::on_btnNewGroup_clicked() @@ -73,12 +93,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked() if(connectorToServer->getListTraineesInGroup(id_group).count() > 0) { - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")).exec(); + SpecMsgBox::CriticalClose(this, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")); return; } else {//Пустая группа - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); @@ -129,11 +149,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in trainee.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in trainee.")); return; } - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); @@ -168,7 +188,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked() {//Не Архивный if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in trainee.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in trainee.")); return; } @@ -214,7 +234,7 @@ void EditorTrainees::on_btnEdit_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in trainee.")).exec(); + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in trainee.")); return; } @@ -383,7 +403,7 @@ bool EditorTrainees::verifyGroup(Group group) if(group.getName() == QStringLiteral("")) {//Имя не корректно! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); return false; } @@ -393,7 +413,7 @@ bool EditorTrainees::verifyGroup(Group group) { if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID()) {//Имя уже существует - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing group name has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); return false; } } @@ -407,19 +427,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) if(trainee.getName() == QStringLiteral("")) {//Имя не корректно! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getLogin() == QStringLiteral("")) {//Логин не корректен! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getPassword() == QStringLiteral("")) {//Пароль не корректный! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); return false; } @@ -428,7 +448,7 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin()); if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID()))) {//Логин уже существует! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec(); + SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } @@ -437,53 +457,73 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) bool EditorTrainees::editGroup(Group group, Group *group_edit) { - DialogEditGroup dlg(this); - dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint); + dlgEditGroup = new DialogEditGroup(this); + dlgEditGroup->setWindowFlags(dlgEditGroup->windowFlags() & ~Qt::WindowContextHelpButtonHint); - dlg.setGroup(group); + dlgEditGroup->setGroup(group); - while (true) + bool flStop = false; + bool res = false; + + while (!flStop) { - switch( dlg.exec() ) + switch( dlgEditGroup->exec() ) { case QDialog::Accepted: { - *group_edit = dlg.getGroup(); + *group_edit = dlgEditGroup->getGroup(); if(! verifyGroup(*group_edit)) { - dlg.setGroup(*group_edit); + dlgEditGroup->setGroup(*group_edit); continue; } - return true; + flStop = true; + res = true; + break; } case QDialog::Rejected: - return false; + flStop = true; + res = false; + break; default: - return false; + flStop = true; + res = false; + break; } } + + if(dlgEditGroup) + { + delete dlgEditGroup; + dlgEditGroup = nullptr; + } + + return res; } bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit) { - DialogEditTrainee dlg(adminMode, this); - dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint); + dlgEditTrainee = new DialogEditTrainee(adminMode, this); + dlgEditTrainee->setWindowFlags(dlgEditTrainee->windowFlags() & ~Qt::WindowContextHelpButtonHint); - dlg.setTrainee(trainee); + dlgEditTrainee->setTrainee(trainee); - while (true) + bool flStop = false; + bool res = false; + + while (!flStop) { - switch( dlg.exec() ) + switch( dlgEditTrainee->exec() ) { case QDialog::Accepted: { - *trainee_edit = dlg.getTrainee(); + *trainee_edit = dlgEditTrainee->getTrainee(); if(! verifyTrainee(*trainee_edit)) { - dlg.setTrainee(*trainee_edit); + dlgEditTrainee->setTrainee(*trainee_edit); continue; } @@ -494,14 +534,28 @@ bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit) trainee_edit->setNeedSetPassword(false); } - return true; + flStop = true; + res = true; + break; } case QDialog::Rejected: - return false; + flStop = true; + res = false; + break; default: - return false; + flStop = true; + res = false; + break; } } + + if(dlgEditTrainee) + { + delete dlgEditTrainee; + dlgEditTrainee = nullptr; + } + + return res; } diff --git a/InstructorsAndTrainees/trainees/editortrainees.h b/InstructorsAndTrainees/trainees/editortrainees.h index 2272b45..5ce19ac 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -5,6 +5,9 @@ #include #include "traineesview.h" //#include "computersLocations.h" +#include "dialogedittrainee.h" +#include "dialogeditgroup.h" +#include "specialmessagebox.h" namespace Ui { class EditorTrainees; @@ -43,6 +46,9 @@ private: private: Ui::EditorTrainees *ui; + + DialogEditTrainee* dlgEditTrainee; + DialogEditGroup* dlgEditGroup; }; #endif // DIALOGTRAINEESGROUPS_H diff --git a/InstructorsAndTrainees/trainees/personalcardtrainee.cpp b/InstructorsAndTrainees/trainees/personalcardtrainee.cpp index f933ce4..ba2d006 100644 --- a/InstructorsAndTrainees/trainees/personalcardtrainee.cpp +++ b/InstructorsAndTrainees/trainees/personalcardtrainee.cpp @@ -78,10 +78,11 @@ PersonalCardTrainee::~PersonalCardTrainee() void PersonalCardTrainee::closeEvent(QCloseEvent *event) { - fimTasksWidget_personal->closeDlgCheckTask(); - ammTasksWidget_personal->closeDlgCheckTask(); + fimTasksWidget_personal->closeChildDlg(); + fimTasksWidget_common->closeChildDlg(); - ammTasksWidget_common->closeDlgListSubProc(); + ammTasksWidget_personal->closeChildDlg(); + ammTasksWidget_common->closeChildDlg(); } void PersonalCardTrainee::loadInfo() diff --git a/InstructorsAndTrainees/trainees/viewertrainees.cpp b/InstructorsAndTrainees/trainees/viewertrainees.cpp index e9a4370..865ac71 100644 --- a/InstructorsAndTrainees/trainees/viewertrainees.cpp +++ b/InstructorsAndTrainees/trainees/viewertrainees.cpp @@ -49,7 +49,11 @@ ViewerTrainees::~ViewerTrainees() } if(dlgRedactor) + { dlgRedactor->close(); + delete dlgRedactor; + dlgRedactor = nullptr; + } if(dlgCardTrainee) dlgCardTrainee->close(); @@ -66,7 +70,11 @@ void ViewerTrainees::setAuthComplited(bool authComplited) void ViewerTrainees::deactivate() { if(dlgRedactor) + { dlgRedactor->close(); + delete dlgRedactor; + dlgRedactor = nullptr; + } if(dlgCardTrainee) dlgCardTrainee->close(); diff --git a/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.qm b/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.qm index 5cbd005..08040d3 100644 Binary files a/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.qm and b/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.qm differ diff --git a/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.ts b/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.ts index e14cbb0..5e0aa97 100644 --- a/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.ts +++ b/InstructorsAndTrainees/translations/InstructorsAndTraineesWidget_ru_RU.ts @@ -971,7 +971,17 @@ Delete it anyway? Сервер: - + + Version of materials: + Версия материалов: + + + + ... + + + + Instructor: Инструктор: @@ -991,85 +1001,85 @@ Delete it anyway? Инструкторы - - - + + + none нет - + The file could not be opened Файл не может быть открыт - - + + Instructor authorization. Авторизация инструктора. - + Instructor deauthorization Деавторизация инструктора - + Error! Ошибка! - + Server blocked! Сервер заблокирован! - + Database error! Ошибка базы данных! - + The user is archived! Пользователь является архивным! - + The user is already logged in! Пользователь уже в сети! - + Login or password error! Ошибка логина или пароля! - + The server is not available! Сервер недоступен! - + Connection attempt Попытка соединения - + connected подключен - + not connected не подключен - + Server settings have been changed. Please reconnect to the server. Настройки сервера изменены. Выполните переподключение к серверу. - + Instructor authorization Авторизация инструктора diff --git a/InstructorsAndTrainees/widgets/widgettools.cpp b/InstructorsAndTrainees/widgets/widgettools.cpp new file mode 100644 index 0000000..cc30632 --- /dev/null +++ b/InstructorsAndTrainees/widgets/widgettools.cpp @@ -0,0 +1,24 @@ +#include "widgettools.h" + +WidgetTools::WidgetTools() +{ + +} + +// Рекурсивная функция для закрытия всех дочерних виджетов +void WidgetTools::closeAllChildWidgets(QWidget *parent, QString objName) +{ + // Ищем всех дочерних виджетов типа QWidget + QObjectList children = parent->children(); + foreach(auto obj, children) + { + if (auto wgt = qobject_cast(obj)) + { // Проверяем имя объекта + if(wgt->objectName() == objName) + { + wgt->close(); // Закрываем виджет + } + closeAllChildWidgets(wgt, objName); // Рекурсия для возможных внучатых виджетов + } + } +} diff --git a/InstructorsAndTrainees/widgets/widgettools.h b/InstructorsAndTrainees/widgets/widgettools.h new file mode 100644 index 0000000..5ca9374 --- /dev/null +++ b/InstructorsAndTrainees/widgets/widgettools.h @@ -0,0 +1,16 @@ +#ifndef WIDGETTOOLS_H +#define WIDGETTOOLS_H + +#include + +class WidgetTools +{ +public: + WidgetTools(); + +public: + static void closeAllChildWidgets(QWidget* parent, QString objName); + +}; + +#endif // WIDGETTOOLS_H diff --git a/ServerLMS/CMakeLists.txt b/ServerLMS/CMakeLists.txt index bc2d524..cb76b13 100644 --- a/ServerLMS/CMakeLists.txt +++ b/ServerLMS/CMakeLists.txt @@ -87,6 +87,7 @@ target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../Instr target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/authorization) target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks) target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets) +target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox) if(PROJECT_TYPE_DEBUG) target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees) else() diff --git a/ServerLMS/Data/Client.h b/ServerLMS/Data/Client.h index 4593183..18975cc 100644 --- a/ServerLMS/Data/Client.h +++ b/ServerLMS/Data/Client.h @@ -17,7 +17,8 @@ public: this->name = name; this->address = address; this->port = port; - this->fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login; + //this->fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login; + this->fullName = "IP: " + address + " port : " + port + " login: " + login; }; ~Client(){}; @@ -31,7 +32,8 @@ public: { this->login = login; isLoggedIn = true; - fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login; + //fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login; + fullName = "IP: " + address + " port : " + port + " login: " + login; } QString getLogin() { diff --git a/ServerLMS/Systems/logger.cpp b/ServerLMS/Systems/logger.cpp index fa687ac..b827be6 100644 --- a/ServerLMS/Systems/logger.cpp +++ b/ServerLMS/Systems/logger.cpp @@ -53,7 +53,22 @@ void Logger::setLogToFile(bool flag) void Logger::handleLog(QString msg, LogLevel logLevel) { + /* + color: red; * Красный * + color: green; * Зелёный * + color: blue; * Синий * + color: yellow; * Жёлтый * + color: black; * Чёрный * + color: white; * Белый * + color: purple; * Фиолетовый * + color: orange; * Оранжевый * + color: pink; * Розовый * + color: brown; * Коричневый * + color: gray; * Серый * + */ + QString level; + QString colorLevel = "pink"; #ifndef PROJECT_TYPE_DEBUG if(logLevel == DEBUG) @@ -62,24 +77,44 @@ void Logger::handleLog(QString msg, LogLevel logLevel) switch (logLevel) { - case INFO: level = "INFO"; break; - case WARNING: level = "WARNING"; break; - case ERROR: level = "ERROR"; break; - case CRITICAL: level = "CRITICAL"; break; - case DEBUG: level = "DEBUG"; break; + case INFO: + level = "INFO"; + colorLevel = "green"; + break; + + case WARNING: + level = "WARNING"; + colorLevel = "yellow"; + break; + + case ERROR: + level = "ERROR"; + colorLevel = "red"; + break; + + case CRITICAL: + level = "CRITICAL"; + colorLevel = "purple"; + break; + + case DEBUG: + level = "DEBUG"; + colorLevel = "brown"; + break; } QString timeStamp = QDateTime::currentDateTime().toString("hh:mm:ss"); QString message = timeStamp + " " + level + " " + msg; - + QString messageHTML = QString("

%1 %3 %4

"). + arg(timeStamp, colorLevel, level, msg); if (loggingType == LoggingType::WIDGET) { - emit sigLogToWidget(message); + emit sigLogToWidget(messageHTML); } else if(loggingType == LoggingType::CONSOLE) { - qDebug() << message; + qDebug() << messageHTML; } if(isLogToFile) diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index 8e4f422..7eb965e 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -32,6 +32,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : first (true), language(languageENG), errorCode(0), + versionStr("..."), flStartInitialization(false) { ui->setupUi(this); @@ -39,6 +40,9 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) : qDebug() << "ServerLMSWidget init thread ID " << QThread::currentThreadId(); ui->widget_Control->setObjectName("widgetControl"); + ui->btnStopServer->setObjectName("btnStopServer"); + ui->btnStartServer->setObjectName("btnStartServer"); + ui->btnSettings->setObjectName("btnSettings"); registerMetaType(); @@ -125,7 +129,8 @@ void ServerLMSWidget::slot_UpdateListClients() void ServerLMSWidget::slot_AddMessageToLog(QString message) { - ui->loggerTextField->appendPlainText(message); + //ui->loggerTextField->appendPlainText(message); + ui->loggerTextField->appendHtml(message); } void ServerLMSWidget::slot_ErrorPostgreSQL(QString text) @@ -170,6 +175,7 @@ void ServerLMSWidget::slot_startInitialization_step1() void ServerLMSWidget::slot_setVersion(QString versionStr) { + this->versionStr = versionStr; ui->lblVersionText->setText(versionStr); } @@ -387,7 +393,7 @@ void ServerLMSWidget::startInitialization_step0() Logger::instance().setLoggingType(LoggingType::WIDGET); Logger::instance().setLogToFile(true); - connect(this,&ServerLMSWidget::sigUpdateControllerInitialize,updateController,&UpdateController::initialize/*,Qt::DirectConnection*/); + connect(this,&ServerLMSWidget::sigUpdateControllerInitialize,updateController,&UpdateController::initialize,Qt::DirectConnection); connect(updateController,&UpdateController::sigInitializeFinished, this,&ServerLMSWidget::slot_startInitialization_step1/*,Qt::DirectConnection*/); connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection); connect(updateController,&UpdateController::sigErrorRequired,this,&ServerLMSWidget::setError); @@ -479,4 +485,6 @@ void ServerLMSWidget::updateStateServer() ui->btnStartServer->setEnabled(false); } } + + ui->lblVersionText->setText(versionStr); } diff --git a/ServerLMS/serverlmswidget.h b/ServerLMS/serverlmswidget.h index 38e1f3e..47aecac 100644 --- a/ServerLMS/serverlmswidget.h +++ b/ServerLMS/serverlmswidget.h @@ -29,8 +29,7 @@ #include "docsupdater.h" #include "waitanimationwidget.h" - - +#include "specialmessagebox.h" namespace Ui { @@ -109,6 +108,14 @@ public: void setError(int code) { + if(code == 100) + { + QString textError = tr("No Client files found!") + "\n\n" + + tr("* check Application for the presence of a folder with a build \n" + "* check SharedData for a folder with the base version and the name base"); + + SpecMsgBox::CriticalClose(this, textError); + } errorCode = code; } @@ -173,6 +180,8 @@ private: QString language; int errorCode; + QString versionStr; + bool flStartInitialization; }; diff --git a/ServerLMS/serverlmswidget.ui b/ServerLMS/serverlmswidget.ui index 8821854..24272ee 100644 --- a/ServerLMS/serverlmswidget.ui +++ b/ServerLMS/serverlmswidget.ui @@ -6,10 +6,16 @@ 0 0 - 1000 + 1200 600
+ + + 1200 + 600 + + Tahoma @@ -45,14 +51,14 @@ - 80 - 55 + 16777215 + 16777215 - 80 - 40 + 0 + 0 @@ -86,14 +92,14 @@ - 80 - 55 + 16777215 + 16777215 - 80 - 40 + 0 + 0 @@ -262,13 +268,13 @@ - 150 + 100 0 - 150 + 100 16777215 diff --git a/ServerLMS/settings/dialogsettingstray.cpp b/ServerLMS/settings/dialogsettingstray.cpp index 19fd21f..d7cfdc9 100644 --- a/ServerLMS/settings/dialogsettingstray.cpp +++ b/ServerLMS/settings/dialogsettingstray.cpp @@ -18,6 +18,7 @@ DialogSettingsTray::DialogSettingsTray(ProviderDBLMS* providerDBLMS, QWidget *pa ui->btnSave->setObjectName("btnSave"); ui->btnCheckDB->setObjectName("btnCheckDB"); ui->btnUpdateDocs->setObjectName("btnUpdateDocs"); + ui->checkLocalhost->setObjectName("checkLocalhost"); /* Создаем строку для регулярного выражения */ QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])"; diff --git a/ServerLMS/settings/dialogsettingstray.ui b/ServerLMS/settings/dialogsettingstray.ui index 241a4d4..986453b 100644 --- a/ServerLMS/settings/dialogsettingstray.ui +++ b/ServerLMS/settings/dialogsettingstray.ui @@ -70,11 +70,11 @@ - + - + - Host name + Local @@ -94,7 +94,18 @@ - Localhost + + + + + + + + + + + + IP address @@ -218,67 +229,11 @@ - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 58 - 58 - - - - Check - - - - :/resources/icons/checkDB.png:/resources/icons/checkDB.png - - - - 32 - 32 - - - - Qt::ToolButtonTextUnderIcon - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -329,19 +284,19 @@ - + - 80 + 58 58 - Update Docs + Check DB - - :/resources/icons/exchange.png:/resources/icons/exchange.png + + :/resources/icons/checkDB.png:/resources/icons/checkDB.png @@ -367,6 +322,32 @@ + + + + + 80 + 58 + + + + Update Docs + + + + :/resources/icons/exchange.png:/resources/icons/exchange.png + + + + 32 + 32 + + + + Qt::ToolButtonTextUnderIcon + + + diff --git a/ServerLMS/translations/ServerLMS_ru_RU.qm b/ServerLMS/translations/ServerLMS_ru_RU.qm index 40b1547..0da8f08 100644 Binary files a/ServerLMS/translations/ServerLMS_ru_RU.qm and b/ServerLMS/translations/ServerLMS_ru_RU.qm differ diff --git a/ServerLMS/translations/ServerLMS_ru_RU.ts b/ServerLMS/translations/ServerLMS_ru_RU.ts index edda8b9..191ce40 100644 --- a/ServerLMS/translations/ServerLMS_ru_RU.ts +++ b/ServerLMS/translations/ServerLMS_ru_RU.ts @@ -4,7 +4,7 @@ AssetsManager - + LLC Constanta-Design ООО Константа-Дизайн @@ -168,8 +168,8 @@ - - + + Error! Ошибка! @@ -184,35 +184,35 @@ Авторизация суперпользователя PostgreSQL - - + + Error connecting to PostgreSQL! Ошибка соединения с PostgreSQL! - - + + Possible reasons: Возможные причины: - - + + *superuser PostgreSQL login or password is incorrect; *логин или пароль суперпользователя PostgreSQL некорректен; - + *Port is incorrect. *Порт некорректен. - + *Port is incorrect; *Порт некорректен; - + *file 'pg_hba.conf' does not contain an entry for the IP address: *файл 'pg_hba.conf не содержит записи доступа для IP адреса: @@ -225,123 +225,129 @@ Форма - + Logger Логгер - + Clients Клиенты - + Settings Настройки - + Server: Сервер: - + Data base: База данных: - - + + + ... - + + Version of materials: + Версия материалов: + + + Authorization Авторизация - + Start Запустить - + Stop Остановить - + Server is started! Сервер запущен! - + Server is stoped! Сервер остановлен! - - + + Warning! Внимание! - + Database settings have been changed. The server will be restarted. Настройки Базы Данных были изменены. Сервер будет перезапущен. - + The file could not be opened Файл не может быть открыт - - + + Database connection error! Ошибка подключения Базы данных! - - + + Error! Ошибка! - + Error PostgreSQL! Ошибка PostgreSQL! - + Settings file could not be opened: Файл настроек не открыт: - + Database connection OK! База данных подключена! - + started запущен - + stoped остановлен - + connected подключена - + not connected не подключена diff --git a/TrayServerLMS/CMakeLists.txt b/TrayServerLMS/CMakeLists.txt index ba9ead2..6b5a501 100644 --- a/TrayServerLMS/CMakeLists.txt +++ b/TrayServerLMS/CMakeLists.txt @@ -38,3 +38,4 @@ target_link_libraries(TrayServerLMS PRIVATE libServerLMS.dll) target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees) target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks) target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets) +target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox) diff --git a/TrayServerLMS/main.cpp b/TrayServerLMS/main.cpp index 00c3910..231509a 100644 --- a/TrayServerLMS/main.cpp +++ b/TrayServerLMS/main.cpp @@ -6,6 +6,6 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; - w.show(); //По-умолчанию свернуто в трее + w.show(); //Закоментировать, если нужно, чтобы по-умолчанию было свернуто в трее! return a.exec(); } diff --git a/TrayServerLMS/mainwindow.cpp b/TrayServerLMS/mainwindow.cpp index a91dca1..aa74e20 100644 --- a/TrayServerLMS/mainwindow.cpp +++ b/TrayServerLMS/mainwindow.cpp @@ -1,6 +1,8 @@ #include #include #include +#include +#include "specialmessagebox.h" #include "mainwindow.h" #include "ui_mainwindow.h" @@ -16,18 +18,13 @@ MainWindow::MainWindow(QWidget *parent) : action_Exit(nullptr) { ui->setupUi(this); - - //Скрываем ненужные элементы окна - ui->menubar->setVisible(false); - ui->statusbar->setVisible(false); + setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint); serverLMSWidget = new ServerLMSWidget(this); - ui->verticalLayout_Main->addWidget(serverLMSWidget); connect(serverLMSWidget, &ServerLMSWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged); connect(serverLMSWidget, &ServerLMSWidget::signal_Tray_ShowMessage, this, &MainWindow::slot_Tray_ShowMessage); - connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_ShowWindow, this, &MainWindow::slot_TrayMenu_ShowWindow); connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_HideWindow, this, &MainWindow::slot_TrayMenu_HideWindow); @@ -204,24 +201,10 @@ void MainWindow::errorCheck() { if(serverLMSWidget->hasError() == 100) { - slot_TrayMenu_ShowWindow(); + slot_TrayMenu_ShowWindow(); - QMessageBox msgBox(this); - - msgBox.setWindowTitle(tr("Error!")); - msgBox.setIcon(QMessageBox::Critical); - msgBox.setText(tr("No Client files found!")); - msgBox.setInformativeText(tr("* check Application for the presence of a folder with a build \n" - "* check SharedData for a folder with the base version and the name base")); - msgBox.setStandardButtons(QMessageBox::Close); - msgBox.show(); - int ret = msgBox.exec(); - - if (ret == QMessageBox::Close) - { - //выключение с задержкой, так как eventLoop инициализируется позже - QTimer::singleShot(1000,this,&MainWindow::slot_TrayMenu_Exit); - } + //выключение с задержкой, так как eventLoop инициализируется позже + QTimer::singleShot(1000,this,&MainWindow::slot_TrayMenu_Exit); } } diff --git a/TrayServerLMS/mainwindow.h b/TrayServerLMS/mainwindow.h index 4ad9af4..89626bc 100644 --- a/TrayServerLMS/mainwindow.h +++ b/TrayServerLMS/mainwindow.h @@ -53,6 +53,7 @@ public slots: //Слот вывода сообщения из трея void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information); + //Слот отложенной инициализации void slot_LazyInitialization(); private: void exit(); diff --git a/TrayServerLMS/mainwindow.ui b/TrayServerLMS/mainwindow.ui index 2857fae..7fa747d 100644 --- a/TrayServerLMS/mainwindow.ui +++ b/TrayServerLMS/mainwindow.ui @@ -34,24 +34,6 @@ - - - false - - - - 0 - 0 - 1200 - 21 - - - - - - false - -