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

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

@@ -22,6 +22,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
messangerWidget(nullptr),
messangerController(nullptr),
dlgTasksCommon(nullptr),
dlgSettings(nullptr),
adminMode(false),
loginInstructorLoggedInLocal(QStringLiteral("")),
nameInstructorLoggedInLocal(QStringLiteral("")),
@@ -107,6 +108,9 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
if(dlgTasksCommon)
dlgTasksCommon->close();
if(dlgSettings)
dlgSettings->close();
delete messangerController;
delete viewerInstructors;
delete viewerTrainees;
@@ -285,6 +289,9 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
viewerTrainees->deactivate();
viewerInstructors->deactivate();
if(dlgSettings)
dlgSettings->deactivate();
messangerController->deleteAllWidgets();
loginInstructorLoggedInLocal = "";
@@ -466,6 +473,9 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
viewerTrainees->deactivate();
viewerInstructors->deactivate();
if(dlgSettings)
dlgSettings->deactivate();
messangerController->deleteAllWidgets();
}
else
@@ -536,20 +546,19 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
void InstructorsAndTraineesWidget::on_btnSettings_clicked()
{
DialogSettings dlg(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(&dlg, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(&dlg, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(dlgSettings, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);
switch( dlg.exec() )
switch( dlgSettings->exec() )
{
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();
@@ -568,6 +577,12 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
default:
break;
}
if(dlgSettings)
{
delete dlgSettings;
dlgSettings = nullptr;
}
}
void InstructorsAndTraineesWidget::on_btnEditorTrainees_clicked()

View File

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

View File

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

View File

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

View File

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

View File

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