From 612fcc8aa7ef781f909951686f41188987e960a5 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Fri, 28 Nov 2025 11:28:39 +0300 Subject: [PATCH 1/8] refact --- .../instructors/dialogeditinstructor.h | 2 +- .../instructors/editorinstructors.cpp | 51 ++++++-- .../instructors/editorinstructors.h | 7 +- .../instructors/editorinstructors.ui | 12 +- .../instructors/viewerinstructors.cpp | 8 ++ .../instructors/viewerinstructors.ui | 4 +- .../trainees/dialogeditgroup.cpp | 5 +- .../trainees/dialogeditgroup.h | 2 +- .../trainees/editortrainees.cpp | 96 +++++++++++---- .../trainees/editortrainees.h | 5 + .../trainees/viewertrainees.cpp | 8 ++ .../InstructorsAndTraineesWidget_ru_RU.qm | Bin 23603 -> 23780 bytes .../InstructorsAndTraineesWidget_ru_RU.ts | 50 ++++---- ServerLMS/Data/Client.h | 6 +- ServerLMS/Systems/logger.cpp | 51 ++++++-- ServerLMS/serverlmswidget.cpp | 10 +- ServerLMS/serverlmswidget.h | 2 + ServerLMS/serverlmswidget.ui | 28 +++-- ServerLMS/settings/dialogsettingstray.cpp | 1 + ServerLMS/settings/dialogsettingstray.ui | 111 ++++++++---------- ServerLMS/translations/ServerLMS_ru_RU.qm | Bin 5852 -> 5956 bytes ServerLMS/translations/ServerLMS_ru_RU.ts | 84 +++++++------ TrayServerLMS/mainwindow.cpp | 1 + 23 files changed, 351 insertions(+), 193 deletions(-) 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..8f0a7d4 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() @@ -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..02e9e14 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -4,6 +4,9 @@ #include #include #include "instructorsview.h" +#include "dialogeditinstructor.h" + +class DialogEditInstructor; namespace Ui { class EditorInstructors; @@ -35,8 +38,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/trainees/dialogeditgroup.cpp b/InstructorsAndTrainees/trainees/dialogeditgroup.cpp index 51776e3..1e93300 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), 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/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index 545a08f..a04829a 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() @@ -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..ad4a22b 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -5,6 +5,8 @@ #include #include "traineesview.h" //#include "computersLocations.h" +#include "dialogedittrainee.h" +#include "dialogeditgroup.h" namespace Ui { class EditorTrainees; @@ -43,6 +45,9 @@ private: private: Ui::EditorTrainees *ui; + + DialogEditTrainee* dlgEditTrainee; + DialogEditGroup* dlgEditGroup; }; #endif // DIALOGTRAINEESGROUPS_H 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 5cbd0056316c09893e9409a2475fa504f68b54bb..08040d36c206f2bc04fdb6f5c23be19a5a1b6346 100644 GIT binary patch delta 1181 zcmXAne@xV69LL{x_Z)ZM`+fllfew*7AudaSJBuF&$B#n}juSXKkPz1fzTE@su=?mgD9&~r*#0G;|69;k0`z=A&v^uWAA*hc0(PTd*`xLN8v<;5Sc|chX99L-FeG6qvbU)J$&-z1vbPb-&A)s=U zr>YB#zoKq`GX1Orb<-(;@d?z+#F7x-t2Rj?l~YZ!eV6#S+H1U^uBbQ*#Q&!L@qsyD z^*@@1PoAR++IftoRCR{?HHqrt7x*qsoN9p&X&!Wb$4+-Q0MvWWNW&~FN`L1@$^a8Ni$(J=fs#AOyGesQT+*NtENYRl%P}=Jq#oyNYDP9Psz%Y+J2(QZTwx@+c`^<&jgFd zrK#HufF&rMt2;nBn~^SNZXod^(vm_BJLUzev!tc5_b6JGf{%3=?zfwPLaX4W@p3CsW7LWAM0x*mA-(;*JUVd>h%6E;4U>-!KT4tLlaB?cGtM#j zn~E7AHA`N!)1!$!^2!eCV8WCV`b`M>vv}J>gbrsK%vdxvatJD1}kJvmd(5{GY7M>qI)aZG|OfA rY!h-|){_|sqY+yh=0_(V4yb& delta 1137 zcmXYxeN0nV7{;Go?rnQ}FRcQiMX<^Q=NM3eEf$KUU|UM1g`#eQ0AmC)_lI-3IFo6+ zO_v#*Z1u)YK8j2+>Sm&*F5*WB!_8^7K*-o)=0J@)|G<4@n^{$fwy3mHAT7`>g0fo{gS{Qo%v!8|~MT9h`GRp%LiP-&spm~uj8t#_YW-X)N&W>w`sl71Mf7Qx7twk^l?DE ziz@43pn6WRa1P^T)OS2Z#l}!SoCO%4M}tIk%_;{ulek6Y`{kb+SqBf(=!<99xy-8J|5j-yi)Pd1~apRrxKYPE0qchJR~80)SorNT0E!aI5b6lPPktM@kx} z>R$yw*{^c(2J)pK zB-e~l#w#{5KD$|N`ru=#dPR=%^j+!Ka_?{r@Qfo{jy;zLEb5Zawvd3deEIyQ^A!Ir z`HG6%H!fv#ys9*6+|BFz^(C%jq~mve+|7#^KjKz+Nm(0?FbF&k6kOSHS!#&47*>Ea$=Y~erG CCNvKK 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/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..fb9ea90 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); } @@ -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..1093497 100644 --- a/ServerLMS/serverlmswidget.h +++ b/ServerLMS/serverlmswidget.h @@ -173,6 +173,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 40b15479c2d7872af9372f9072c139d90ddee0e4..0da8f085a91d2fbb64fff47195d661625a2d636e 100644 GIT binary patch delta 178 zcmcbkdqhvvW=D#|srPfHo>i3DpRjQ6T_*+xCWeWkWlSPr6MNH`L_{ZkwU@lb;kW54 z0|OTWM{5Ej1B1Xjj;V}}3=G28C;Ku6vbU8V0J6&`&t(*6TsV0vV>FYf#AYF;YGHRZ z79kc>76%qb77G@C1_c%y76TS1u!seaWzAy8V#Hv@puoWZ1Z+So7M5C6oSC1eke{ZI Yn^=-sl$n@QY^5++Ku~gXuc$vG0C5y9sQ>@~ delta 112 zcmV-$0FVE~F5E2@Jh)^S%I}<&%^@7WV4=O;LI3~(_>mQM0u%O;jb;K9wUPBd8F~m# zvh@G}3IGU&U;zLC5bg+-0YLx&6L*tM0Z|u`b|C-&5A_PDg5&@I0~QLXn#2GA6hV`{ S0b2qTxU(7pdlR$u6;A;)@+Kkx 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/mainwindow.cpp b/TrayServerLMS/mainwindow.cpp index a91dca1..1c2a437 100644 --- a/TrayServerLMS/mainwindow.cpp +++ b/TrayServerLMS/mainwindow.cpp @@ -16,6 +16,7 @@ MainWindow::MainWindow(QWidget *parent) : action_Exit(nullptr) { ui->setupUi(this); + setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint); //Скрываем ненужные элементы окна ui->menubar->setVisible(false); From 8ad6d06f186a1317c5a284e7d19cacfc7af008f2 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Fri, 28 Nov 2025 12:32:53 +0300 Subject: [PATCH 2/8] closeChildDlg --- .../tasks/ammtaskswidget.cpp | 39 +++++++++++++++---- InstructorsAndTrainees/tasks/ammtaskswidget.h | 9 ++++- InstructorsAndTrainees/tasks/checkertask.cpp | 26 +++++++++++-- InstructorsAndTrainees/tasks/checkertask.h | 3 ++ .../tasks/fimtaskswidget.cpp | 30 +++++++++++--- InstructorsAndTrainees/tasks/fimtaskswidget.h | 8 +++- .../trainees/personalcardtrainee.cpp | 7 ++-- 7 files changed, 100 insertions(+), 22 deletions(-) diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp index f66b0d9..4dcee7c 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -22,6 +22,7 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), dlgListSubProc(nullptr), + specialMessageBox(nullptr), flOnlyActive(false), lastCurrentID(0) { @@ -145,16 +146,19 @@ 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(); + if(specialMessageBox) + specialMessageBox->close(); } void AMMtasksWidget::changeEvent(QEvent *event) @@ -325,10 +329,16 @@ 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) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } break; } case QDialog::Rejected: @@ -347,10 +357,16 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) { lastSelectedTask.listSubProc.clear(); - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } } } @@ -504,11 +520,18 @@ 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) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); + + if(specialMessageBox->exec() == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id); } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } } } diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index 900a4e9..b85ed5e 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; @@ -100,6 +103,8 @@ private: DialogListSubProc* dlgListSubProc; + SpecialMessageBox* specialMessageBox; + bool flOnlyActive; //AMM int lastCurrentID; diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index b0ab2ac..77e44f8 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -8,6 +8,7 @@ CheckerTask::CheckerTask(ConnectorToServer* connectorToServer, QString type, QWi ui(new Ui::CheckerTask), connectorToServer(connectorToServer), fimTasksWidget(nullptr), + specialMessageBox(nullptr), flChanged(false), id_task(0), type("fim") @@ -48,12 +49,19 @@ CheckerTask::~CheckerTask() delete fimTasksWidget; fimTasksWidget = nullptr; } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } + delete ui; } void CheckerTask::closeEvent(QCloseEvent *event) { - + if(specialMessageBox) + specialMessageBox->close(); } void CheckerTask::setTask(TaskAmmFim* task) @@ -175,12 +183,18 @@ 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) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); + if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } void CheckerTask::on_btnRight_clicked() @@ -202,10 +216,16 @@ 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) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); + if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index f08edeb..5468af1 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; @@ -47,6 +48,8 @@ private: ConnectorToServer* connectorToServer; FIMtasksWidget* fimTasksWidget; + SpecialMessageBox* specialMessageBox; + bool flChanged; int id_task; QString type; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index c87c9e2..733967e 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -22,6 +22,7 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre taskTreePreparation(nullptr), waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), + specialMessageBox(nullptr), userName(""), lastCurrentID(0) { @@ -101,9 +102,9 @@ FIMtasksWidget::~FIMtasksWidget() delete treeWidget; if(dlgCheckerTask) - { dlgCheckerTask->close(); - } + if(specialMessageBox) + specialMessageBox->close(); delete ui; } @@ -130,10 +131,17 @@ void FIMtasksWidget::resizeEvent(QResizeEvent *event) waitAnimationWidget->resize(size); } -void FIMtasksWidget::closeDlgCheckTask() +void FIMtasksWidget::closeEvent(QCloseEvent *event) +{ + closeChildDlg(); +} + +void FIMtasksWidget::closeChildDlg() { if(dlgCheckerTask) dlgCheckerTask->close(); + if(specialMessageBox) + specialMessageBox->close(); } void FIMtasksWidget::changeEvent(QEvent *event) @@ -393,11 +401,17 @@ 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) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); + if(specialMessageBox->exec() == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_FIM_TO_TRAINEE, id); } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } } } @@ -437,8 +451,14 @@ void FIMtasksWidget::on_btnCheck_clicked() void FIMtasksWidget::on_btnAssignTask_clicked() { - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted) + specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + if(specialMessageBox->exec() == QDialog::Accepted) assignTaskFIMtoTrainee(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask) diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index 34450a3..15347c2 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; @@ -88,6 +92,8 @@ private: DialogChekerTask* dlgCheckerTask; + SpecialMessageBox* specialMessageBox; + QString userName; //FIM int lastCurrentID; 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() From fb493aca9f30f313a62844b96781802969c949c6 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Fri, 28 Nov 2025 21:01:33 +0300 Subject: [PATCH 3/8] =?UTF-8?q?SpecMsgBox=20=D0=B2=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=86=D0=B5=D1=81=D1=81=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DOCS/Андрей/Board.md | 6 +- .../Core/recognizesystem.cpp | 2 +- .../instructors/editorinstructors.cpp | 85 ++++++++++++++++--- .../instructors/editorinstructors.h | 2 + .../instructorsandtraineeswidget.cpp | 12 +-- .../settings/dialogversioncontrol.cpp | 8 +- .../specialmessagebox/notifycontroller.cpp | 4 +- .../specialmessagebox/specialmessagebox.cpp | 38 +++++++-- .../specialmessagebox/specialmessagebox.h | 19 +++-- .../tasks/ammtaskswidget.cpp | 6 +- InstructorsAndTrainees/tasks/ammtaskswidget.h | 2 +- InstructorsAndTrainees/tasks/checkertask.cpp | 4 +- InstructorsAndTrainees/tasks/checkertask.h | 2 +- .../tasks/fimtaskswidget.cpp | 4 +- InstructorsAndTrainees/tasks/fimtaskswidget.h | 2 +- .../trainees/editortrainees.cpp | 31 ++++--- .../trainees/editortrainees.h | 2 + 17 files changed, 169 insertions(+), 60 deletions(-) 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/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 8705ca1..043eb80 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(nullptr, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + xmlFileName).exec(); return; } else diff --git a/InstructorsAndTrainees/instructors/editorinstructors.cpp b/InstructorsAndTrainees/instructors/editorinstructors.cpp index 8f0a7d4..0811638 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.cpp +++ b/InstructorsAndTrainees/instructors/editorinstructors.cpp @@ -6,7 +6,8 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : InstructorsView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorInstructors), - dlgEditInstructor(nullptr) + dlgEditInstructor(nullptr), + specialMessageBox(nullptr) { ui->setupUi(this); @@ -41,6 +42,13 @@ EditorInstructors::~EditorInstructors() dlgEditInstructor = nullptr; } + if(specialMessageBox) + { + specialMessageBox->close(); + delete specialMessageBox; + specialMessageBox = nullptr; + } + delete ui; } @@ -48,6 +56,9 @@ void EditorInstructors::closeEvent(QCloseEvent *event) { if(dlgEditInstructor) dlgEditInstructor->close(); + + if(specialMessageBox) + specialMessageBox->close(); } void EditorInstructors::on_btnNewInstructor_clicked() @@ -82,21 +93,39 @@ void EditorInstructors::on_btnDeleteInstructor_clicked() if(connectorToServer->isAdminInstructor(id)) {//Это Админ! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete the Administrator.")).exec(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete the Administrator.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return; } if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in instructor.")).exec(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete a logged-in instructor.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return; } - if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); + if(specialMessageBox->exec() == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id); } + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } } } } @@ -127,7 +156,13 @@ void EditorInstructors::on_btnToOrFromArchive_clicked() {//Не Архивный if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in instructor.")).exec(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot archive a logged-in instructor.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return; } @@ -164,7 +199,13 @@ void EditorInstructors::on_btnEdit_clicked() if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in instructor.")).exec(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot edit a logged-in instructor.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return; } @@ -270,19 +311,37 @@ 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(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } 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(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } 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(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return false; } @@ -291,7 +350,13 @@ 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(); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); + specialMessageBox->exec(); + if(specialMessageBox) + { + delete specialMessageBox; + specialMessageBox = nullptr; + } return 0; } diff --git a/InstructorsAndTrainees/instructors/editorinstructors.h b/InstructorsAndTrainees/instructors/editorinstructors.h index 02e9e14..9c3bfb0 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -5,6 +5,7 @@ #include #include "instructorsview.h" #include "dialogeditinstructor.h" +#include "specialmessagebox.h" class DialogEditInstructor; @@ -42,6 +43,7 @@ private: Ui::EditorInstructors *ui; DialogEditInstructor* dlgEditInstructor; + SpecMsgBox* specialMessageBox; }; #endif // DIALOGINSTRUCTORS_H diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index ecd32f6..42b93cd 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -179,7 +179,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(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + fileName).exec(); return QStringLiteral(""); } else @@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization else { ui->btnAuthorizationInstructor->setChecked(true); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); } } @@ -285,7 +285,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(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec(); } } @@ -317,7 +317,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(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec(); } } @@ -406,7 +406,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(!flSettingsServerIsChanged) { if(!flTryConnectToServer) - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); } else flSettingsServerIsChanged = false; @@ -654,7 +654,7 @@ 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(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); flSettingsServerIsChanged = true; diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index c881502..a83e629 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp @@ -114,7 +114,7 @@ void DialogVersionControl::sendCopyEmit(QString newName) if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -127,7 +127,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -160,7 +160,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -172,7 +172,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp index 659ae1c..0064b26 100644 --- a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp +++ b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp @@ -13,7 +13,7 @@ NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) : void NotifyController::showWarning(QString text, QWidget *parentWidget) { if(parentWidget) - SpecialMessageBox(parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); else - SpecialMessageBox(this->parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp index 11ff87b..1ce64dd 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -2,7 +2,7 @@ #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) { @@ -22,14 +22,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 +40,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(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningYesNo, text); +} + +int SpecMsgBox::WarningClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningClose, text); +} + +int SpecMsgBox::CriticalClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::criticalClose, text); +} + +int SpecMsgBox::InfoOk(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +{ + return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::infoOk, text); +} + +int SpecMsgBox::work(SpecMsgBox *msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text) +{ + 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..c431a54 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h @@ -7,7 +7,7 @@ namespace Ui { class SpecialMessageBox; } -class SpecialMessageBox : public QDialog +class SpecMsgBox : public QDialog { Q_OBJECT @@ -15,13 +15,22 @@ public: enum TypeSpecMsgBox { warningYesNo, warningClose, - critical, - info + criticalClose, + infoOk }; public: - explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); - ~SpecialMessageBox(); + explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); + ~SpecMsgBox(); + +public: + static int WarningYesNo(SpecMsgBox* msgBox, QWidget *parent, const QString& text); + static int WarningClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); + static int CriticalClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); + static int InfoOk(SpecMsgBox* msgBox, QWidget *parent, const QString& text); + +private: + static int work(SpecMsgBox* msgBox, 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 4dcee7c..013d784 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -329,7 +329,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) lastSelectedTask.listSubProc.clear(); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); @@ -357,7 +357,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) { lastSelectedTask.listSubProc.clear(); - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); @@ -520,7 +520,7 @@ void AMMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); if(specialMessageBox->exec() == QDialog::Accepted) { diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index b85ed5e..d89ed72 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.h +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.h @@ -103,7 +103,7 @@ private: DialogListSubProc* dlgListSubProc; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; bool flOnlyActive; //AMM diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index 77e44f8..668d89b 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -183,7 +183,7 @@ void CheckerTask::on_btnWrong_clicked() msgString = tr("Change task status?\nThe status will be set:\n'new'"); } - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); @@ -216,7 +216,7 @@ void CheckerTask::on_btnRight_clicked() msgString = tr("Change task status?\nThe status will be set:\n'completed'"); } - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index 5468af1..cbd76ad 100644 --- a/InstructorsAndTrainees/tasks/checkertask.h +++ b/InstructorsAndTrainees/tasks/checkertask.h @@ -48,7 +48,7 @@ private: ConnectorToServer* connectorToServer; FIMtasksWidget* fimTasksWidget; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; bool flChanged; int id_task; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index 733967e..57104b6 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -401,7 +401,7 @@ void FIMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); if(specialMessageBox->exec() == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); @@ -451,7 +451,7 @@ void FIMtasksWidget::on_btnCheck_clicked() void FIMtasksWidget::on_btnAssignTask_clicked() { - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(specialMessageBox->exec() == QDialog::Accepted) assignTaskFIMtoTrainee(); if(specialMessageBox) diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index 15347c2..c820eb3 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.h +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.h @@ -92,7 +92,7 @@ private: DialogChekerTask* dlgCheckerTask; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; QString userName; //FIM diff --git a/InstructorsAndTrainees/trainees/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index a04829a..8efc54b 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.cpp +++ b/InstructorsAndTrainees/trainees/editortrainees.cpp @@ -9,7 +9,8 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM TraineesView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorTrainees), dlgEditTrainee(nullptr), - dlgEditGroup(nullptr) + dlgEditGroup(nullptr), + specialMessageBox(nullptr) { ui->setupUi(this); @@ -54,6 +55,8 @@ EditorTrainees::~EditorTrainees() dlgEditGroup = nullptr; } + //SpecMsgBox::CloseAndDelete(specialMessageBox); + delete ui; } @@ -64,6 +67,8 @@ void EditorTrainees::closeEvent(QCloseEvent *event) if(dlgEditGroup) dlgEditGroup->close(); + + //SpecMsgBox::CloseAndDelete(specialMessageBox); } void EditorTrainees::on_btnNewGroup_clicked() @@ -93,12 +98,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(specialMessageBox, 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(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); @@ -149,11 +154,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(specialMessageBox, 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(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); @@ -188,7 +193,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(specialMessageBox, this, tr("You cannot archive a logged-in trainee.")); return; } @@ -234,7 +239,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(specialMessageBox, this, tr("You cannot edit a logged-in trainee.")); return; } @@ -403,7 +408,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(specialMessageBox, this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); return false; } @@ -413,7 +418,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(specialMessageBox, this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); return false; } } @@ -427,19 +432,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(specialMessageBox, 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(specialMessageBox, 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(specialMessageBox, this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); return false; } @@ -448,7 +453,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(specialMessageBox, this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } diff --git a/InstructorsAndTrainees/trainees/editortrainees.h b/InstructorsAndTrainees/trainees/editortrainees.h index ad4a22b..5255fb6 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -7,6 +7,7 @@ //#include "computersLocations.h" #include "dialogedittrainee.h" #include "dialogeditgroup.h" +#include "specialmessagebox.h" namespace Ui { class EditorTrainees; @@ -48,6 +49,7 @@ private: DialogEditTrainee* dlgEditTrainee; DialogEditGroup* dlgEditGroup; + SpecMsgBox* specialMessageBox; }; #endif // DIALOGTRAINEESGROUPS_H From d129fbded0fd57c3e4d929161fae1fcd0a305e93 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Sun, 30 Nov 2025 19:28:08 +0300 Subject: [PATCH 4/8] =?UTF-8?q?notifyController=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/recognizesystem.cpp | 8 +- .../connectorToServer/Core/recognizesystem.h | 2 +- .../connectorToServer/connectortoserver.cpp | 11 +-- .../connectorToServer/connectortoserver.h | 5 +- .../instructors/editorinstructors.cpp | 85 +++---------------- .../instructors/editorinstructors.h | 1 - .../instructorsandtraineeswidget.cpp | 12 +-- .../settings/dialogversioncontrol.cpp | 14 ++- .../settings/dialogversioncontrol.h | 1 + .../specialmessagebox/notifycontroller.cpp | 4 +- .../specialmessagebox/specialmessagebox.cpp | 20 ++--- .../specialmessagebox/specialmessagebox.h | 13 +-- .../tasks/ammtaskswidget.cpp | 28 +----- InstructorsAndTrainees/tasks/ammtaskswidget.h | 2 - InstructorsAndTrainees/tasks/checkertask.cpp | 25 +----- InstructorsAndTrainees/tasks/checkertask.h | 2 - .../tasks/fimtaskswidget.cpp | 21 +---- InstructorsAndTrainees/tasks/fimtaskswidget.h | 2 - .../trainees/editortrainees.cpp | 31 +++---- .../trainees/editortrainees.h | 1 - 20 files changed, 82 insertions(+), 206 deletions(-) diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 043eb80..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)) { - SpecMsgBox(nullptr, SpecMsgBox::TypeSpecMsgBox::criticalClose, 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..0dbae16 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -9,7 +9,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : dataParser(nullptr), sendSystem(nullptr), recognizeSystem(nullptr), - notifyController(nullptr), fl_GetedOfflineMessages(false), nameInstructorLoggedInLocal("") { @@ -19,7 +18,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : ConnectorToServer::~ConnectorToServer() { delete client; - delete notifyController; delete recognizeSystem; delete sendSystem; delete dataParser; @@ -115,6 +113,11 @@ void ConnectorToServer::slot_getVersion() emit signal_SendGetVersion(); } +void ConnectorToServer::slot_NotifyVersionControl(QString text) +{ + emit signal_NotifyVersionControl(text); +} + void ConnectorToServer::initialize() { createObjects(); @@ -159,7 +162,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 +193,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..9e07b7e 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -116,6 +116,8 @@ public slots: void slot_getVersion(); + void slot_NotifyVersionControl(QString text); + signals: void sigSetConnect(ServerSettings* serverSettings,QThread *thread); void sigStopConnect(); @@ -157,6 +159,8 @@ signals: void signal_showServerList(QList *serverList); void signal_SendGetVersion(); + void signal_NotifyVersionControl(QString text); + private: void initialize(); void bindConnection(); @@ -169,7 +173,6 @@ private: DataParser *dataParser; SendSystem *sendSystem; RecognizeSystem *recognizeSystem; - NotifyController *notifyController; //Списочная модель БД СУО QMutex mtxAccess; diff --git a/InstructorsAndTrainees/instructors/editorinstructors.cpp b/InstructorsAndTrainees/instructors/editorinstructors.cpp index 0811638..223358a 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.cpp +++ b/InstructorsAndTrainees/instructors/editorinstructors.cpp @@ -6,8 +6,7 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : InstructorsView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorInstructors), - dlgEditInstructor(nullptr), - specialMessageBox(nullptr) + dlgEditInstructor(nullptr) { ui->setupUi(this); @@ -42,13 +41,6 @@ EditorInstructors::~EditorInstructors() dlgEditInstructor = nullptr; } - if(specialMessageBox) - { - specialMessageBox->close(); - delete specialMessageBox; - specialMessageBox = nullptr; - } - delete ui; } @@ -56,9 +48,6 @@ void EditorInstructors::closeEvent(QCloseEvent *event) { if(dlgEditInstructor) dlgEditInstructor->close(); - - if(specialMessageBox) - specialMessageBox->close(); } void EditorInstructors::on_btnNewInstructor_clicked() @@ -93,39 +82,21 @@ void EditorInstructors::on_btnDeleteInstructor_clicked() if(connectorToServer->isAdminInstructor(id)) {//Это Админ! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete the Administrator.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot delete the Administrator.")); return; } if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in instructor.")); return; } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - if(specialMessageBox->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); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -156,13 +127,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked() {//Не Архивный if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot archive a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in instructor.")); return; } @@ -199,13 +164,7 @@ void EditorInstructors::on_btnEdit_clicked() if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot edit a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in instructor.")); return; } @@ -311,37 +270,19 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) if(instructor.getName() == QStringLiteral("")) {//Имя не корректно! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getLogin() == QStringLiteral("")) {//Логин не корректен! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getPassword() == QStringLiteral("")) {//Пароль не корректный! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); return false; } @@ -350,13 +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 = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } diff --git a/InstructorsAndTrainees/instructors/editorinstructors.h b/InstructorsAndTrainees/instructors/editorinstructors.h index 9c3bfb0..fa0c280 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -43,7 +43,6 @@ private: Ui::EditorInstructors *ui; DialogEditInstructor* dlgEditInstructor; - SpecMsgBox* specialMessageBox; }; #endif // DIALOGINSTRUCTORS_H diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 42b93cd..07c4027 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -179,7 +179,7 @@ QString InstructorsAndTraineesWidget::loadStyleSheet() QFile styleSheetFile(fileName); if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text)) { - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + fileName).exec(); + SpecMsgBox::CriticalClose(this, tr("The file could not be opened ") + fileName); return QStringLiteral(""); } else @@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization else { ui->btnAuthorizationInstructor->setChecked(true); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); + SpecMsgBox::CriticalClose(this, tr("Instructor deauthorization") + "\n" + tr("Error!")); } } @@ -285,7 +285,7 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked() waitAnimationWidget->hideWithStop(); ui->btnAuthorizationInstructor->setChecked(false); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + tr("Server blocked!")); } } @@ -317,7 +317,7 @@ void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error) errorTextMsg = tr("Login or password error!"); } - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + errorTextMsg); } } @@ -406,7 +406,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(!flSettingsServerIsChanged) { if(!flTryConnectToServer) - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); + SpecMsgBox::WarningClose(this, tr("The server is not available!")); } else flSettingsServerIsChanged = false; @@ -654,7 +654,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked() if(dlgSettings->settingsServerIsChanged()) { - SpecMsgBox(this, SpecMsgBox::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; diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index a83e629..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"); - SpecMsgBox(this, SpecMsgBox::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"); - SpecMsgBox(this, SpecMsgBox::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"); - SpecMsgBox(this, SpecMsgBox::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"); - SpecMsgBox(this, SpecMsgBox::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 index 0064b26..b4022a6 100644 --- a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp +++ b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp @@ -13,7 +13,7 @@ NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) : void NotifyController::showWarning(QString text, QWidget *parentWidget) { if(parentWidget) - SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(parentWidget, text); else - SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this->parentWidget, text); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp index 1ce64dd..68da470 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -45,29 +45,29 @@ SpecMsgBox::~SpecMsgBox() delete ui; } -int SpecMsgBox::WarningYesNo(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::WarningYesNo(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningYesNo, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningYesNo, text); } -int SpecMsgBox::WarningClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::WarningClose(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningClose, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningClose, text); } -int SpecMsgBox::CriticalClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::CriticalClose(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::criticalClose, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::criticalClose, text); } -int SpecMsgBox::InfoOk(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::InfoOk(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::infoOk, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::infoOk, text); } -int SpecMsgBox::work(SpecMsgBox *msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text) +int SpecMsgBox::work(QWidget *parent, TypeSpecMsgBox type, const QString& text) { - msgBox = new SpecMsgBox(parent, type, text); + SpecMsgBox *msgBox = new SpecMsgBox(parent, type, text); return msgBox->exec(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h index c431a54..a0789c0 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h @@ -19,18 +19,19 @@ public: infoOk }; -public: +private: explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); +public: ~SpecMsgBox(); public: - static int WarningYesNo(SpecMsgBox* msgBox, QWidget *parent, const QString& text); - static int WarningClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); - static int CriticalClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); - static int InfoOk(SpecMsgBox* msgBox, QWidget *parent, const QString& text); + 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(SpecMsgBox* msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text); + 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 013d784..d662450 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -22,7 +22,6 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), dlgListSubProc(nullptr), - specialMessageBox(nullptr), flOnlyActive(false), lastCurrentID(0) { @@ -157,8 +156,6 @@ void AMMtasksWidget::closeChildDlg() dlgCheckerTask->close(); if(dlgListSubProc) dlgListSubProc->close(); - if(specialMessageBox) - specialMessageBox->close(); } void AMMtasksWidget::changeEvent(QEvent *event) @@ -329,16 +326,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) lastSelectedTask.listSubProc.clear(); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->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); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } break; } case QDialog::Rejected: @@ -357,16 +348,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) { lastSelectedTask.listSubProc.clear(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->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); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -520,18 +505,11 @@ void AMMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - - if(specialMessageBox->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); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index d89ed72..32bba57 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.h +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.h @@ -103,8 +103,6 @@ private: DialogListSubProc* dlgListSubProc; - SpecMsgBox* specialMessageBox; - bool flOnlyActive; //AMM int lastCurrentID; diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index 668d89b..a4af13e 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -8,7 +8,6 @@ CheckerTask::CheckerTask(ConnectorToServer* connectorToServer, QString type, QWi ui(new Ui::CheckerTask), connectorToServer(connectorToServer), fimTasksWidget(nullptr), - specialMessageBox(nullptr), flChanged(false), id_task(0), type("fim") @@ -49,19 +48,13 @@ CheckerTask::~CheckerTask() delete fimTasksWidget; fimTasksWidget = nullptr; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } delete ui; } void CheckerTask::closeEvent(QCloseEvent *event) { - if(specialMessageBox) - specialMessageBox->close(); + } void CheckerTask::setTask(TaskAmmFim* task) @@ -183,18 +176,12 @@ void CheckerTask::on_btnWrong_clicked() msgString = tr("Change task status?\nThe status will be set:\n'new'"); } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } void CheckerTask::on_btnRight_clicked() @@ -216,16 +203,10 @@ void CheckerTask::on_btnRight_clicked() msgString = tr("Change task status?\nThe status will be set:\n'completed'"); } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index cbd76ad..639e55c 100644 --- a/InstructorsAndTrainees/tasks/checkertask.h +++ b/InstructorsAndTrainees/tasks/checkertask.h @@ -48,8 +48,6 @@ private: ConnectorToServer* connectorToServer; FIMtasksWidget* fimTasksWidget; - SpecMsgBox* specialMessageBox; - bool flChanged; int id_task; QString type; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index 57104b6..70e58b5 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -22,7 +22,6 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre taskTreePreparation(nullptr), waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), - specialMessageBox(nullptr), userName(""), lastCurrentID(0) { @@ -103,8 +102,6 @@ FIMtasksWidget::~FIMtasksWidget() if(dlgCheckerTask) dlgCheckerTask->close(); - if(specialMessageBox) - specialMessageBox->close(); delete ui; } @@ -140,8 +137,6 @@ void FIMtasksWidget::closeChildDlg() { if(dlgCheckerTask) dlgCheckerTask->close(); - if(specialMessageBox) - specialMessageBox->close(); } void FIMtasksWidget::changeEvent(QEvent *event) @@ -401,17 +396,11 @@ void FIMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - if(specialMessageBox->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); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -451,14 +440,8 @@ void FIMtasksWidget::on_btnCheck_clicked() void FIMtasksWidget::on_btnAssignTask_clicked() { - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) assignTaskFIMtoTrainee(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask) diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index c820eb3..0e60bd0 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.h +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.h @@ -92,8 +92,6 @@ private: DialogChekerTask* dlgCheckerTask; - SpecMsgBox* specialMessageBox; - QString userName; //FIM int lastCurrentID; diff --git a/InstructorsAndTrainees/trainees/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index 8efc54b..e613087 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.cpp +++ b/InstructorsAndTrainees/trainees/editortrainees.cpp @@ -9,8 +9,7 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM TraineesView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorTrainees), dlgEditTrainee(nullptr), - dlgEditGroup(nullptr), - specialMessageBox(nullptr) + dlgEditGroup(nullptr) { ui->setupUi(this); @@ -55,8 +54,6 @@ EditorTrainees::~EditorTrainees() dlgEditGroup = nullptr; } - //SpecMsgBox::CloseAndDelete(specialMessageBox); - delete ui; } @@ -67,8 +64,6 @@ void EditorTrainees::closeEvent(QCloseEvent *event) if(dlgEditGroup) dlgEditGroup->close(); - - //SpecMsgBox::CloseAndDelete(specialMessageBox); } void EditorTrainees::on_btnNewGroup_clicked() @@ -98,12 +93,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked() if(connectorToServer->getListTraineesInGroup(id_group).count() > 0) { - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")); + SpecMsgBox::CriticalClose(this, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")); return; } else {//Пустая группа - if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == 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); @@ -154,11 +149,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot delete a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in trainee.")); return; } - if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == 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); @@ -193,7 +188,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked() {//Не Архивный if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot archive a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in trainee.")); return; } @@ -239,7 +234,7 @@ void EditorTrainees::on_btnEdit_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot edit a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in trainee.")); return; } @@ -408,7 +403,7 @@ bool EditorTrainees::verifyGroup(Group group) if(group.getName() == QStringLiteral("")) {//Имя не корректно! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); return false; } @@ -418,7 +413,7 @@ bool EditorTrainees::verifyGroup(Group group) { if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID()) {//Имя уже существует - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); return false; } } @@ -432,19 +427,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) if(trainee.getName() == QStringLiteral("")) {//Имя не корректно! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getLogin() == QStringLiteral("")) {//Логин не корректен! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getPassword() == QStringLiteral("")) {//Пароль не корректный! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); return false; } @@ -453,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()))) {//Логин уже существует! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } diff --git a/InstructorsAndTrainees/trainees/editortrainees.h b/InstructorsAndTrainees/trainees/editortrainees.h index 5255fb6..5ce19ac 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -49,7 +49,6 @@ private: DialogEditTrainee* dlgEditTrainee; DialogEditGroup* dlgEditGroup; - SpecMsgBox* specialMessageBox; }; #endif // DIALOGTRAINEESGROUPS_H From d30e6b4927cc20eb25e7774efd6e86321deba761 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Sun, 30 Nov 2025 21:29:32 +0300 Subject: [PATCH 5/8] WidgetTools::closeAllChildWidgets --- InstructorsAndTrainees/CMakeLists.txt | 4 ++-- .../connectorToServer/connectortoserver.cpp | 3 +-- .../connectorToServer/connectortoserver.h | 4 +--- .../instructorsandtraineeswidget.cpp | 6 ++++- .../specialmessagebox/notifycontroller.cpp | 19 --------------- .../specialmessagebox/notifycontroller.h | 20 ---------------- .../specialmessagebox/specialmessagebox.cpp | 2 ++ .../tasks/ammtaskswidget.cpp | 3 ++- .../widgets/widgettools.cpp | 24 +++++++++++++++++++ InstructorsAndTrainees/widgets/widgettools.h | 16 +++++++++++++ 10 files changed, 53 insertions(+), 48 deletions(-) delete mode 100644 InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp delete mode 100644 InstructorsAndTrainees/specialmessagebox/notifycontroller.h create mode 100644 InstructorsAndTrainees/widgets/widgettools.cpp create mode 100644 InstructorsAndTrainees/widgets/widgettools.h 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/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index 0dbae16..7f27b0c 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -1,9 +1,8 @@ #include "connectortoserver.h" #include -ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : +ConnectorToServer::ConnectorToServer(QObject *parent) : QObject(parent), - parentWidget(parentWidget), connectionThread(nullptr), client(nullptr), dataParser(nullptr), diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index 9e07b7e..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: @@ -167,7 +166,6 @@ private: void createObjects(); private: - QWidget* parentWidget; QThread *connectionThread; TCPClient *client; DataParser *dataParser; diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 07c4027..7234dfe 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"; @@ -50,7 +51,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); @@ -406,7 +407,10 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(!flSettingsServerIsChanged) { if(!flTryConnectToServer) + { + WidgetTools::closeAllChildWidgets(this, "SpecMsgBox"); SpecMsgBox::WarningClose(this, tr("The server is not available!")); + } } else flSettingsServerIsChanged = false; diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp deleted file mode 100644 index b4022a6..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) - SpecMsgBox::WarningClose(parentWidget, text); - else - SpecMsgBox::WarningClose(this->parentWidget, text); -} 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 68da470..c427873 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -8,6 +8,8 @@ SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text { ui->setupUi(this); + this->setObjectName("SpecMsgBox"); + this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); if(type == TypeSpecMsgBox::warningYesNo) diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp index d662450..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), @@ -155,7 +156,7 @@ void AMMtasksWidget::closeChildDlg() if(dlgCheckerTask) dlgCheckerTask->close(); if(dlgListSubProc) - dlgListSubProc->close(); + dlgListSubProc->close(); } void AMMtasksWidget::changeEvent(QEvent *event) 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 From 54f1744e7fb9269836e63b86cee1688c4e34f18f Mon Sep 17 00:00:00 2001 From: krivoshein Date: Sun, 30 Nov 2025 22:54:09 +0300 Subject: [PATCH 6/8] =?UTF-8?q?errorCheck=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 1 + GUIdataBaseLMS/mainwindow.cpp | 3 +- .../specialmessagebox/specialmessagebox.h | 3 +- ServerLMS/CMakeLists.txt | 1 + ServerLMS/serverlmswidget.cpp | 2 +- ServerLMS/serverlmswidget.h | 11 ++++++-- TrayServerLMS/CMakeLists.txt | 1 + TrayServerLMS/main.cpp | 2 +- TrayServerLMS/mainwindow.cpp | 28 ++++--------------- TrayServerLMS/mainwindow.h | 1 + TrayServerLMS/mainwindow.ui | 18 ------------ 11 files changed, 23 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33b160b..4e5b419 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,3 +41,4 @@ add_dependencies(GUIdataBaseLMS InstructorsAndTrainees) add_dependencies(ServerLMS DataBaseLMS) add_dependencies(ServerLMS InstructorsAndTrainees) add_dependencies(TrayServerLMS ServerLMS) +add_dependencies(TrayServerLMS InstructorsAndTrainees) 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/specialmessagebox/specialmessagebox.h b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h index a0789c0..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 SpecMsgBox : public QDialog +class INSTRUCTORSANDTRAINEES_EXPORT SpecMsgBox : public QDialog { Q_OBJECT 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/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index fb9ea90..7eb965e 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -393,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); diff --git a/ServerLMS/serverlmswidget.h b/ServerLMS/serverlmswidget.h index 1093497..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; } 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 1c2a437..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" @@ -18,17 +20,11 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint); - //Скрываем ненужные элементы окна - ui->menubar->setVisible(false); - ui->statusbar->setVisible(false); - 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); @@ -205,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 - - From df1ada6945535f682b44625285745ff9595ce722 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Sun, 30 Nov 2025 23:12:00 +0300 Subject: [PATCH 7/8] refact --- CMakeLists.txt | 1 - InstructorsAndTrainees/instructorsandtraineeswidget.cpp | 6 +++--- InstructorsAndTrainees/instructorsandtraineeswidget.h | 8 +++----- InstructorsAndTrainees/instructorsandtraineeswidget.ui | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e5b419..33b160b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,4 +41,3 @@ add_dependencies(GUIdataBaseLMS InstructorsAndTrainees) add_dependencies(ServerLMS DataBaseLMS) add_dependencies(ServerLMS InstructorsAndTrainees) add_dependencies(TrayServerLMS ServerLMS) -add_dependencies(TrayServerLMS InstructorsAndTrainees) diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 7234dfe..de504e8 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -387,7 +387,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 { @@ -460,7 +460,7 @@ void InstructorsAndTraineesWidget::slot_AnswerDocsChanged() viewerTrainees->getAmmTasksWidgetCommon()->setDocsActualed(false); } -void InstructorsAndTraineesWidget::slot_ConnectToServer() +void InstructorsAndTraineesWidget::slot_TryConnectToServer() { updateLabelServer(); connectorToServer->SetConnectToServer(); @@ -540,7 +540,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() diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 747ffd6..36c4046 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.h +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.h @@ -65,7 +65,7 @@ public Q_SLOTS: void slot_AnswerDocsChanged(); - void slot_ConnectToServer(); + void slot_TryConnectToServer(); Q_SIGNALS: //сигнал смены языка @@ -79,19 +79,15 @@ 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 updateLabelServer(); - void setLanguageInterfase(); private: @@ -113,6 +109,8 @@ private: QString nameInstructorLoggedInLocal; QString idInstructorLoggedInLocal; + Instructor instructorLoggedInLocal; + QTranslator qtLanguageTranslator; QString language; 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 From d2384d37581a164de9c17dbe3f48b480038fd406 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Mon, 1 Dec 2025 00:55:22 +0300 Subject: [PATCH 8/8] refact --- .../instructors/dialogeditinstructor.cpp | 2 +- .../instructorsandtraineeswidget.cpp | 75 +++++++++---------- .../instructorsandtraineeswidget.h | 16 ++-- .../trainees/dialogeditgroup.cpp | 2 +- .../trainees/dialogedittrainee.cpp | 2 +- 5 files changed, 46 insertions(+), 51 deletions(-) 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/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index de504e8..8b80c1f 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -15,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), @@ -25,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); @@ -109,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) : InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget() { if(authorizationIsCompleted()) - deAuthorizationInstructor(loginInstructorLoggedInLocal); + deAuthorizationInstructor(instructorLoggedInLocal.getLogin()); if(dlgTasksCommon) { @@ -155,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event) {// переведём окно заново ui->retranslateUi(this); - updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal); + updateLabelLoggedInInstructor(instructorLoggedInLocal); updateLabelServer(); } } @@ -210,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()); @@ -256,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); @@ -269,7 +266,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization ui->btnEditorInstructors->setEnabled(false); ui->btnPersonalCard->setEnabled(false); - updateLabelLoggedInInstructor("",""); + updateLabelLoggedInInstructor(instructorLoggedInLocal); } else { @@ -337,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; @@ -376,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) @@ -447,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()) @@ -523,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login) bool InstructorsAndTraineesWidget::authorizationIsCompleted() { - if(loginInstructorLoggedInLocal == QStringLiteral("")) + if(instructorLoggedInLocal.getLogin() == QStringLiteral("")) return false; else return true; @@ -562,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); @@ -582,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"))); @@ -644,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); @@ -663,7 +662,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked() flSettingsServerIsChanged = true; if(authorizationIsCompleted()) - deAuthorizationInstructor(loginInstructorLoggedInLocal); + deAuthorizationInstructor(instructorLoggedInLocal.getLogin()); connectorToServer->StopConnectToServer(); } diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 36c4046..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 { @@ -86,13 +87,11 @@ 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; @@ -104,16 +103,10 @@ private: DialogSettings* dlgSettings; DialogAuthorization* dlgAuthorization; - bool adminMode; - QString loginInstructorLoggedInLocal; - QString nameInstructorLoggedInLocal; - QString idInstructorLoggedInLocal; + WaitAnimationWidget *waitAnimationWidget; Instructor instructorLoggedInLocal; - QTranslator qtLanguageTranslator; - QString language; - bool flSettingsServerIsChanged; bool flTryConnectToServer; @@ -121,6 +114,9 @@ private: bool flTryLogin; + QTranslator qtLanguageTranslator; + QString language; + Ui::InstructorsAndTraineesWidget *ui; }; diff --git a/InstructorsAndTrainees/trainees/dialogeditgroup.cpp b/InstructorsAndTrainees/trainees/dialogeditgroup.cpp index 1e93300..d1b0063 100644 --- a/InstructorsAndTrainees/trainees/dialogeditgroup.cpp +++ b/InstructorsAndTrainees/trainees/dialogeditgroup.cpp @@ -12,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/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);