Откл-е запр-в на EditorTrainees EditorInstructors

This commit is contained in:
2026-01-22 16:42:03 +03:00
parent ebbfc484b4
commit a43a547631
7 changed files with 105 additions and 37 deletions

View File

@@ -6,6 +6,7 @@
ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidget *parent) : ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidget *parent) :
InstructorsView(connectorToServer, CommonView::TypeView::onlyView, parent), InstructorsView(connectorToServer, CommonView::TypeView::onlyView, parent),
dlgRedactor(nullptr), dlgRedactor(nullptr),
flTryEditorInstructors(false),
ui(new Ui::ViewerInstructors) ui(new Ui::ViewerInstructors)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -20,6 +21,8 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
setNotLoggedInVisible(true); setNotLoggedInVisible(true);
ui->btnEditorInstructors->setVisible(false); ui->btnEditorInstructors->setVisible(false);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, this, &ViewerInstructors::slot_checkTryBlockResult);
} }
ViewerInstructors::~ViewerInstructors() ViewerInstructors::~ViewerInstructors()
@@ -48,6 +51,8 @@ void ViewerInstructors::deactivate()
dlgRedactor = nullptr; dlgRedactor = nullptr;
} }
flTryEditorInstructors = false;
CommonView::deactivate(); CommonView::deactivate();
updateButtons(); updateButtons();
} }
@@ -75,23 +80,31 @@ void ViewerInstructors::slot_receiveMessage(ClientMessage clientMessage)
slot_NeedUpdateUI(true, false); slot_NeedUpdateUI(true, false);
} }
void ViewerInstructors::slot_checkTryBlockResult(bool result, QString type)
{
if(flTryEditorInstructors)
{
if(type == "EditorInstructors")
{
if(result)
{//Одобрено
dialog_EditorInstructors();
}
else
{//Отказ
SpecMsgBox::WarningClose(this, tr("The server rejected your request to access instructors control.\nAnother instructor is managing instructors.\nPlease try again later."));
}
flTryEditorInstructors = false;
}
}
}
void ViewerInstructors::on_btnEditorInstructors_clicked() void ViewerInstructors::on_btnEditorInstructors_clicked()
{ {
flTryEditorInstructors = true;
connectorToServer->sendQueryBlockAuth(true, "EditorInstructors"); connectorToServer->sendQueryBlockAuth(true, "EditorInstructors");
dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this);
dlgRedactor->exec();
if(dlgRedactor)
{
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(authComplited)
loadInstructorsFromDB();
connectorToServer->sendQueryBlockAuth(false, "EditorInstructors");
} }
void ViewerInstructors::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) void ViewerInstructors::on_treeWidgetCurrentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous)
@@ -143,3 +156,20 @@ void ViewerInstructors::updateButtons()
ui->btnEditorInstructors->setEnabled(false); ui->btnEditorInstructors->setEnabled(false);
} }
} }
void ViewerInstructors::dialog_EditorInstructors()
{
dlgRedactor = new DialogRedactorInstructors(connectorToServer, adminMode, this);
dlgRedactor->exec();
if(dlgRedactor)
{
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(authComplited)
loadInstructorsFromDB();
connectorToServer->sendQueryBlockAuth(false, "EditorInstructors");
}

View File

@@ -29,6 +29,8 @@ protected:
public slots: public slots:
void slot_receiveMessage(ClientMessage clientMessage); void slot_receiveMessage(ClientMessage clientMessage);
void slot_checkTryBlockResult(bool result, QString type);
public Q_SLOTS: public Q_SLOTS:
void on_btnEditorInstructors_clicked(); void on_btnEditorInstructors_clicked();
@@ -41,9 +43,13 @@ Q_SIGNALS:
private: private:
void updateButtons() override; void updateButtons() override;
void dialog_EditorInstructors();
private: private:
DialogRedactorInstructors* dlgRedactor; DialogRedactorInstructors* dlgRedactor;
bool flTryEditorInstructors;
private: private:
Ui::ViewerInstructors *ui; Ui::ViewerInstructors *ui;
}; };

View File

@@ -703,8 +703,6 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged); connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
connect(dlgSettings, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet); connect(dlgSettings, &DialogSettings::signal_UpdateStyleSheet, this, &InstructorsAndTraineesWidget::slot_UpdateStyleSheet);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, dlgSettings, &DialogSettings::slot_checkTryBlockResult);
switch( dlgSettings->exec() ) switch( dlgSettings->exec() )
{ {
case QDialog::Accepted: case QDialog::Accepted:

View File

@@ -70,6 +70,8 @@ DialogSettings::DialogSettings(ConnectorToServer* connectorToServer, bool instru
ui->btnSave->setEnabled(false); ui->btnSave->setEnabled(false);
flSettingsServerChanged = false; flSettingsServerChanged = false;
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, this, &DialogSettings::slot_checkTryBlockResult);
} }
DialogSettings::~DialogSettings() DialogSettings::~DialogSettings()
@@ -219,9 +221,6 @@ void DialogSettings::on_btnSetVersion_clicked()
flTryVersionControl = true; flTryVersionControl = true;
connectorToServer->sendQueryBlockAuth(true, "VersionControl"); connectorToServer->sendQueryBlockAuth(true, "VersionControl");
//TODO пока сразу
//slot_VersionControl();
} }
} }
@@ -254,7 +253,7 @@ void DialogSettings::on_DialogSettings_accepted()
emit signal_LanguageChanged(language); emit signal_LanguageChanged(language);
} }
void DialogSettings::slot_VersionControl() void DialogSettings::dialog_VersionControl()
{ {
dlgVersionControl = new DialogVersionControl(connectorToServer, this); dlgVersionControl = new DialogVersionControl(connectorToServer, this);
dlgVersionControl->initialize(connectorToServer->getLoginName()); dlgVersionControl->initialize(connectorToServer->getLoginName());
@@ -277,7 +276,7 @@ void DialogSettings::slot_checkTryBlockResult(bool result, QString type)
{ {
if(result) if(result)
{//Одобрено {//Одобрено
slot_VersionControl(); dialog_VersionControl();
} }
else else
{//Отказ {//Отказ

View File

@@ -47,12 +47,11 @@ private slots:
void on_DialogSettings_accepted(); void on_DialogSettings_accepted();
public slots: public slots:
void slot_VersionControl();
void slot_checkTryBlockResult(bool result, QString type); void slot_checkTryBlockResult(bool result, QString type);
private: private:
bool saveSettings(); bool saveSettings();
void dialog_VersionControl();
private: private:
Ui::DialogSettings *ui; Ui::DialogSettings *ui;

View File

@@ -11,6 +11,7 @@ ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, MessangerCo
messangerController(messangerController), messangerController(messangerController),
dlgRedactor(nullptr), dlgRedactor(nullptr),
dlgCardTrainee(nullptr), dlgCardTrainee(nullptr),
flTryEditorTrainees(false),
ui(new Ui::ViewerTrainees) ui(new Ui::ViewerTrainees)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -32,6 +33,8 @@ ViewerTrainees::ViewerTrainees(ConnectorToServer* connectorToServer, MessangerCo
setNotLoggedInVisible(true); setNotLoggedInVisible(true);
ui->btnEditorTrainees->setVisible(false); ui->btnEditorTrainees->setVisible(false);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, this, &ViewerTrainees::slot_checkTryBlockResult);
} }
ViewerTrainees::~ViewerTrainees() ViewerTrainees::~ViewerTrainees()
@@ -79,6 +82,8 @@ void ViewerTrainees::deactivate()
if(dlgCardTrainee) if(dlgCardTrainee)
dlgCardTrainee->close(); dlgCardTrainee->close();
flTryEditorTrainees = false;
CommonView::deactivate(); CommonView::deactivate();
ammTasksWidgetCommon->deactivate(); ammTasksWidgetCommon->deactivate();
@@ -109,23 +114,31 @@ void ViewerTrainees::slot_receiveMessage(ClientMessage clientMessage)
slot_NeedUpdateUI(false, true); slot_NeedUpdateUI(false, true);
} }
void ViewerTrainees::slot_checkTryBlockResult(bool result, QString type)
{
if(flTryEditorTrainees)
{
if(type == "EditorTrainees")
{
if(result)
{//Одобрено
dialog_EditorTrainees();
}
else
{//Отказ
SpecMsgBox::WarningClose(this, tr("The server rejected your request to access trainees control.\nAnother instructor is managing trainees.\nPlease try again later."));
}
flTryEditorTrainees = false;
}
}
}
void ViewerTrainees::on_btnEditorTrainees_clicked() void ViewerTrainees::on_btnEditorTrainees_clicked()
{ {
flTryEditorTrainees = true;
connectorToServer->sendQueryBlockAuth(true, "EditorTrainees"); connectorToServer->sendQueryBlockAuth(true, "EditorTrainees");
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
dlgRedactor->exec();
if(dlgRedactor)
{
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(authComplited)
loadTraineesFromDB();
connectorToServer->sendQueryBlockAuth(false, "EditorTrainees");
} }
void ViewerTrainees::on_btnPersonalCard_clicked() void ViewerTrainees::on_btnPersonalCard_clicked()
@@ -236,3 +249,20 @@ void ViewerTrainees::updateButtons()
ui->btnEditorTrainees->setEnabled(false); ui->btnEditorTrainees->setEnabled(false);
} }
} }
void ViewerTrainees::dialog_EditorTrainees()
{
dlgRedactor = new DialogRedactorTrainees(connectorToServer, adminMode, this);
dlgRedactor->exec();
if(dlgRedactor)
{
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(authComplited)
loadTraineesFromDB();
connectorToServer->sendQueryBlockAuth(false, "EditorTrainees");
}

View File

@@ -36,6 +36,8 @@ protected:
public slots: public slots:
void slot_receiveMessage(ClientMessage clientMessage); void slot_receiveMessage(ClientMessage clientMessage);
void slot_checkTryBlockResult(bool result, QString type);
public Q_SLOTS: public Q_SLOTS:
void on_btnEditorTrainees_clicked(); void on_btnEditorTrainees_clicked();
void on_btnPersonalCard_clicked(); void on_btnPersonalCard_clicked();
@@ -50,6 +52,8 @@ Q_SIGNALS:
private: private:
void updateButtons() override; void updateButtons() override;
void dialog_EditorTrainees();
private: private:
AMMtasksWidget* ammTasksWidgetCommon; AMMtasksWidget* ammTasksWidgetCommon;
FIMtasksWidget* fimTasksWidgetCommon; FIMtasksWidget* fimTasksWidgetCommon;
@@ -59,6 +63,8 @@ private:
DialogRedactorTrainees* dlgRedactor; DialogRedactorTrainees* dlgRedactor;
DialogCardTrainee* dlgCardTrainee; DialogCardTrainee* dlgCardTrainee;
bool flTryEditorTrainees;
private: private:
Ui::ViewerTrainees *ui; Ui::ViewerTrainees *ui;
}; };