Откл-е запр-в на 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) :
InstructorsView(connectorToServer, CommonView::TypeView::onlyView, parent),
dlgRedactor(nullptr),
flTryEditorInstructors(false),
ui(new Ui::ViewerInstructors)
{
ui->setupUi(this);
@@ -20,6 +21,8 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
setNotLoggedInVisible(true);
ui->btnEditorInstructors->setVisible(false);
connect(connectorToServer, &ConnectorToServer::sigTryBlockResult, this, &ViewerInstructors::slot_checkTryBlockResult);
}
ViewerInstructors::~ViewerInstructors()
@@ -48,6 +51,8 @@ void ViewerInstructors::deactivate()
dlgRedactor = nullptr;
}
flTryEditorInstructors = false;
CommonView::deactivate();
updateButtons();
}
@@ -75,23 +80,31 @@ void ViewerInstructors::slot_receiveMessage(ClientMessage clientMessage)
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()
{
flTryEditorInstructors = true;
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)
@@ -143,3 +156,20 @@ void ViewerInstructors::updateButtons()
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:
void slot_receiveMessage(ClientMessage clientMessage);
void slot_checkTryBlockResult(bool result, QString type);
public Q_SLOTS:
void on_btnEditorInstructors_clicked();
@@ -41,9 +43,13 @@ Q_SIGNALS:
private:
void updateButtons() override;
void dialog_EditorInstructors();
private:
DialogRedactorInstructors* dlgRedactor;
bool flTryEditorInstructors;
private:
Ui::ViewerInstructors *ui;
};