diff --git a/GUIdataBaseLMS/CMakeLists.txt b/GUIdataBaseLMS/CMakeLists.txt index 04430c9..76da07e 100644 --- a/GUIdataBaseLMS/CMakeLists.txt +++ b/GUIdataBaseLMS/CMakeLists.txt @@ -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/widgets) 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) target_link_directories(GUIdataBaseLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees) else() diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 285a61b..c47337d 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -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() diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.h b/InstructorsAndTrainees/instructorsandtraineeswidget.h index 4328ee4..2b9b19d 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.h +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.h @@ -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; diff --git a/InstructorsAndTrainees/settings/dialogsettings.cpp b/InstructorsAndTrainees/settings/dialogsettings.cpp index 2f0c5b7..28fe4f1 100644 --- a/InstructorsAndTrainees/settings/dialogsettings.cpp +++ b/InstructorsAndTrainees/settings/dialogsettings.cpp @@ -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; + } } } diff --git a/InstructorsAndTrainees/settings/dialogsettings.h b/InstructorsAndTrainees/settings/dialogsettings.h index b77839c..78669d1 100644 --- a/InstructorsAndTrainees/settings/dialogsettings.h +++ b/InstructorsAndTrainees/settings/dialogsettings.h @@ -6,6 +6,7 @@ #include #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; }; diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index 50fb293..03064ed 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp @@ -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() diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.h b/InstructorsAndTrainees/settings/dialogversioncontrol.h index e82e9e6..146f1fb 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.h +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.h @@ -66,6 +66,8 @@ private: WaitAnimationWidget *waitAnimationWidget; + DialogNewVersion *dlgNewVersion; + QString authorName; bool flGetVersion;