Схлопывание диалогов при выключении Сервера

This commit is contained in:
2025-11-27 10:43:12 +03:00
parent f75ff9660f
commit 3e50bfe2e2
7 changed files with 72 additions and 14 deletions

View File

@@ -25,6 +25,7 @@ target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../
target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/messanger) target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/messanger)
target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets) target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets)
target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox) target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox)
target_include_directories(GUIdataBaseLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/settings)
if(PROJECT_TYPE_DEBUG) if(PROJECT_TYPE_DEBUG)
target_link_directories(GUIdataBaseLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees) target_link_directories(GUIdataBaseLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees)
else() else()

View File

@@ -22,6 +22,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
messangerWidget(nullptr), messangerWidget(nullptr),
messangerController(nullptr), messangerController(nullptr),
dlgTasksCommon(nullptr), dlgTasksCommon(nullptr),
dlgSettings(nullptr),
adminMode(false), adminMode(false),
loginInstructorLoggedInLocal(QStringLiteral("")), loginInstructorLoggedInLocal(QStringLiteral("")),
nameInstructorLoggedInLocal(QStringLiteral("")), nameInstructorLoggedInLocal(QStringLiteral("")),
@@ -107,6 +108,9 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
if(dlgTasksCommon) if(dlgTasksCommon)
dlgTasksCommon->close(); dlgTasksCommon->close();
if(dlgSettings)
dlgSettings->close();
delete messangerController; delete messangerController;
delete viewerInstructors; delete viewerInstructors;
delete viewerTrainees; delete viewerTrainees;
@@ -285,6 +289,9 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
viewerTrainees->deactivate(); viewerTrainees->deactivate();
viewerInstructors->deactivate(); viewerInstructors->deactivate();
if(dlgSettings)
dlgSettings->deactivate();
messangerController->deleteAllWidgets(); messangerController->deleteAllWidgets();
loginInstructorLoggedInLocal = ""; loginInstructorLoggedInLocal = "";
@@ -466,6 +473,9 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
viewerTrainees->deactivate(); viewerTrainees->deactivate();
viewerInstructors->deactivate(); viewerInstructors->deactivate();
if(dlgSettings)
dlgSettings->deactivate();
messangerController->deleteAllWidgets(); messangerController->deleteAllWidgets();
} }
else else
@@ -536,20 +546,19 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
void InstructorsAndTraineesWidget::on_btnSettings_clicked() void InstructorsAndTraineesWidget::on_btnSettings_clicked()
{ {
DialogSettings dlg(connectorToServer, (loginInstructorLoggedInLocal != ""), this); dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint); dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(&dlg, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged); connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(&dlg, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet); connect(dlgSettings, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);
switch( dlgSettings->exec() )
switch( dlg.exec() )
{ {
case QDialog::Accepted: case QDialog::Accepted:
{ {
language = dlg.getSettings().Language; language = dlgSettings->getSettings().Language;
if(dlg.settingsServerIsChanged()) if(dlgSettings->settingsServerIsChanged())
{ {
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec();
@@ -568,6 +577,12 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
default: default:
break; break;
} }
if(dlgSettings)
{
delete dlgSettings;
dlgSettings = nullptr;
}
} }
void InstructorsAndTraineesWidget::on_btnEditorTrainees_clicked() void InstructorsAndTraineesWidget::on_btnEditorTrainees_clicked()

View File

@@ -11,6 +11,7 @@
#include "connectortoserver.h" #include "connectortoserver.h"
#include "metatypes.h" #include "metatypes.h"
#include "dialogtaskscommon.h" #include "dialogtaskscommon.h"
#include "dialogsettings.h"
namespace Ui { namespace Ui {
@@ -98,6 +99,7 @@ private:
MessangerController* messangerController; MessangerController* messangerController;
DialogTasksCommon* dlgTasksCommon; DialogTasksCommon* dlgTasksCommon;
DialogSettings* dlgSettings;
bool adminMode; bool adminMode;
QString loginInstructorLoggedInLocal; QString loginInstructorLoggedInLocal;

View File

@@ -11,6 +11,7 @@ DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instru
ui(new Ui::DialogSettings), ui(new Ui::DialogSettings),
settings(nullptr), settings(nullptr),
connectorToServer(nullptr), connectorToServer(nullptr),
dlgVersionControl(nullptr),
flSettingsServerChanged(false) flSettingsServerChanged(false)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -76,10 +77,25 @@ DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instru
DialogSettings::~DialogSettings() DialogSettings::~DialogSettings()
{ {
if(dlgVersionControl)
dlgVersionControl->close();
delete ui; delete ui;
delete settings; delete settings;
} }
void DialogSettings::deactivate()
{
ui->btnSetVersion->setEnabled(false);
if(dlgVersionControl)
{
dlgVersionControl->close();
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
}
ServerSettings DialogSettings::getSettings() ServerSettings DialogSettings::getSettings()
{ {
return *settings; return *settings;
@@ -201,10 +217,15 @@ void DialogSettings::on_btnSetVersion_clicked()
if(connectorToServer) if(connectorToServer)
if(connectorToServer->getIsConnected()) if(connectorToServer->getIsConnected())
{ {
DialogVersionControl *versionSelectWidget = new DialogVersionControl(connectorToServer, this); dlgVersionControl = new DialogVersionControl(connectorToServer, this);
versionSelectWidget->initialize(connectorToServer->getLoginName()); dlgVersionControl->initialize(connectorToServer->getLoginName());
versionSelectWidget->exec(); dlgVersionControl->exec();
delete versionSelectWidget;
if(dlgVersionControl)
{
delete dlgVersionControl;
dlgVersionControl = nullptr;
}
} }
} }

View File

@@ -6,6 +6,7 @@
#include <QEvent> #include <QEvent>
#include "Datas.h" #include "Datas.h"
#include "connectortoserver.h" #include "connectortoserver.h"
#include "dialogversioncontrol.h"
namespace Ui { namespace Ui {
class DialogSettings; class DialogSettings;
@@ -19,6 +20,8 @@ public:
explicit DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent = nullptr); explicit DialogSettings(ConnectorToServer* connectorToServer, bool instructorIsLogged, QWidget *parent = nullptr);
~DialogSettings(); ~DialogSettings();
void deactivate();
ServerSettings getSettings(); ServerSettings getSettings();
bool settingsServerIsChanged(){ return flSettingsServerChanged;} bool settingsServerIsChanged(){ return flSettingsServerChanged;}
@@ -53,6 +56,8 @@ private:
ServerSettings *settings; ServerSettings *settings;
ConnectorToServer* connectorToServer; ConnectorToServer* connectorToServer;
DialogVersionControl *dlgVersionControl;
bool flSettingsServerChanged; bool flSettingsServerChanged;
}; };

View File

@@ -13,6 +13,7 @@ DialogVersionControl::DialogVersionControl(ConnectorToServer* connectorToServer,
selectedVersion(nullptr), selectedVersion(nullptr),
versionContainer(nullptr), versionContainer(nullptr),
waitAnimationWidget(nullptr), waitAnimationWidget(nullptr),
dlgNewVersion(nullptr),
authorName(""), authorName(""),
flGetVersion(false) flGetVersion(false)
{ {
@@ -32,6 +33,13 @@ DialogVersionControl::DialogVersionControl(ConnectorToServer* connectorToServer,
DialogVersionControl::~DialogVersionControl() DialogVersionControl::~DialogVersionControl()
{ {
if(dlgNewVersion)
{
dlgNewVersion->close();
delete dlgNewVersion;
dlgNewVersion = nullptr;
}
waitAnimationWidget->hideWithStop(); waitAnimationWidget->hideWithStop();
delete versionContainer; delete versionContainer;
@@ -123,7 +131,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
return; return;
} }
DialogNewVersion *dlgNewVersion = new DialogNewVersion(this); dlgNewVersion = new DialogNewVersion(this);
dlgNewVersion->initialize(selectedVersion->getViewName()); dlgNewVersion->initialize(selectedVersion->getViewName());
switch(dlgNewVersion->exec()) switch(dlgNewVersion->exec())
@@ -140,7 +148,11 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
break; break;
} }
if(dlgNewVersion)
{
delete dlgNewVersion; delete dlgNewVersion;
dlgNewVersion = nullptr;
}
} }
void DialogVersionControl::on_deleteVersionButton_clicked() void DialogVersionControl::on_deleteVersionButton_clicked()

View File

@@ -66,6 +66,8 @@ private:
WaitAnimationWidget *waitAnimationWidget; WaitAnimationWidget *waitAnimationWidget;
DialogNewVersion *dlgNewVersion;
QString authorName; QString authorName;
bool flGetVersion; bool flGetVersion;