This commit is contained in:
2025-12-01 00:55:22 +03:00
parent df1ada6945
commit d2384d3758
5 changed files with 46 additions and 51 deletions

View File

@@ -22,7 +22,7 @@ DialogEditInstructor::DialogEditInstructor(bool adminMode, QWidget *parent) :
ui->btnViewPassword->setObjectName("btnViewPassword");
ui->btnChangePassword->setObjectName("btnChangePassword");
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
ui->editPassword->setEnabled(false);

View File

@@ -15,8 +15,7 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
QWidget(parent),
waitAnimationWidget(nullptr),
QWidget(parent),
connectorToServer(nullptr),
viewerTrainees(nullptr),
viewerInstructors(nullptr),
@@ -25,15 +24,12 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
dlgTasksCommon(nullptr),
dlgSettings(nullptr),
dlgAuthorization(nullptr),
adminMode(false),
loginInstructorLoggedInLocal(QStringLiteral("")),
nameInstructorLoggedInLocal(QStringLiteral("")),
idInstructorLoggedInLocal("0"),
language(languageENG),
waitAnimationWidget(nullptr),
flSettingsServerIsChanged(false),
flTryConnectToServer(false),
cntTryConnectToServer(0),
flTryLogin(false),
language(languageENG),
ui(new Ui::InstructorsAndTraineesWidget)
{
ui->setupUi(this);
@@ -109,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
{
if(authorizationIsCompleted())
deAuthorizationInstructor(loginInstructorLoggedInLocal);
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
if(dlgTasksCommon)
{
@@ -155,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
{// переведём окно заново
ui->retranslateUi(this);
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
updateLabelLoggedInInstructor(instructorLoggedInLocal);
updateLabelServer();
}
}
@@ -210,28 +206,28 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se
{
if (serverAuth->Result)
{
loginInstructorLoggedInLocal = serverAuth->Login;
nameInstructorLoggedInLocal = serverAuth->ClientName;
idInstructorLoggedInLocal = serverAuth->Id;
instructorLoggedInLocal.setLogin(serverAuth->Login);
instructorLoggedInLocal.setName(serverAuth->ClientName);
instructorLoggedInLocal.setID(serverAuth->Id.toInt());
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
adminMode = true;
if(serverAuth->Login == QStringLiteral("admin"))
instructorLoggedInLocal.setIsAdmin(true);
else
adminMode = false;
instructorLoggedInLocal.setIsAdmin(false);
viewerInstructors->setAdminMode(adminMode);
viewerTrainees->setAdminMode(adminMode);
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
viewerInstructors->setAuthComplited(true);
viewerTrainees->setAuthComplited(true);
ui->btnEditorTrainees->setEnabled(true);
if(adminMode)
if(instructorLoggedInLocal.getIsAdmin())
ui->btnEditorInstructors->setEnabled(true);
emit signal_NeedUpdateUI(true, true);
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
connectorToServer->setLoginName(nameInstructorLoggedInLocal);
updateLabelLoggedInInstructor(instructorLoggedInLocal);
connectorToServer->setLoginName(instructorLoggedInLocal.getName());
messangerController->setUserLocalGUI_ID(serverAuth->Id.toInt());
@@ -256,12 +252,13 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
{
if (serverDeAuth->Result)
{
loginInstructorLoggedInLocal = QStringLiteral("");
nameInstructorLoggedInLocal = QStringLiteral("");
adminMode = false;
instructorLoggedInLocal.setLogin(QStringLiteral(""));
instructorLoggedInLocal.setName(QStringLiteral(""));
instructorLoggedInLocal.setIsAdmin(false);
instructorLoggedInLocal.setID(0);
viewerInstructors->setAdminMode(adminMode);
viewerTrainees->setAdminMode(adminMode);
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
viewerInstructors->setAuthComplited(false);
viewerTrainees->setAuthComplited(false);
@@ -269,7 +266,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
ui->btnEditorInstructors->setEnabled(false);
ui->btnPersonalCard->setEnabled(false);
updateLabelLoggedInInstructor("","");
updateLabelLoggedInInstructor(instructorLoggedInLocal);
}
else
{
@@ -337,7 +334,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
updateLabelLoggedInInstructor(instructorLoggedInLocal);
flTryConnectToServer = false;
cntTryConnectToServer = 0;
@@ -376,10 +373,12 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
messangerController->deleteAllWidgets();
loginInstructorLoggedInLocal = "";
nameInstructorLoggedInLocal = "";
instructorLoggedInLocal.setLogin(QStringLiteral(""));
instructorLoggedInLocal.setName(QStringLiteral(""));
instructorLoggedInLocal.setIsAdmin(false);
instructorLoggedInLocal.setID(0);
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
updateLabelLoggedInInstructor(instructorLoggedInLocal);
if(flTryConnectToServer)
@@ -447,7 +446,7 @@ void InstructorsAndTraineesWidget::slot_instructorSelected(int id_instructor)
/*Messanger*/
messangerController->deleteWidget(messangerWidget);
if(id_instructor && id_instructor != idInstructorLoggedInLocal.toInt())
if(id_instructor && id_instructor != instructorLoggedInLocal.getID())
{
Instructor instructor = connectorToServer->getInstructor(id_instructor);
if(instructor.getID())
@@ -523,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login)
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
{
if(loginInstructorLoggedInLocal == QStringLiteral(""))
if(instructorLoggedInLocal.getLogin() == QStringLiteral(""))
return false;
else
return true;
@@ -562,7 +561,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
{//ДеАвторизация Инструктора локальная (Администратора)
if(authorizationIsCompleted())
{
if(deAuthorizationInstructor(loginInstructorLoggedInLocal))
if(deAuthorizationInstructor(instructorLoggedInLocal.getLogin()))
{
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerTrainees,&ViewerTrainees::slot_NeedUpdateUI);
@@ -582,13 +581,13 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
}
}
void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login, QString name)
void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(Instructor& instructor)
{
if(authorizationIsCompleted())
{
QString nameLoggedInInstructor = QString("%1 (%2)").arg(name, login);
QString nameLoggedInInstructor = QString("%1 (%2)").arg(instructor.getName(), instructor.getLogin());
ui->lblLoggedInInstructor->setText(nameLoggedInInstructor);
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
if(instructor.getIsAdmin())
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/admin.png")));
else
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/instructor.png")));
@@ -644,7 +643,7 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
void InstructorsAndTraineesWidget::on_btnSettings_clicked()
{
dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
dlgSettings = new DialogSettings(connectorToServer, authorizationIsCompleted(), this);
dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
@@ -663,7 +662,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
flSettingsServerIsChanged = true;
if(authorizationIsCompleted())
deAuthorizationInstructor(loginInstructorLoggedInLocal);
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
connectorToServer->StopConnectToServer();
}

View File

@@ -13,6 +13,7 @@
#include "dialogtaskscommon.h"
#include "dialogsettings.h"
#include "dialogauthorization.h"
#include "instructor.h"
namespace Ui {
@@ -86,13 +87,11 @@ private:
bool authorizationInstructorDialog(QWidget* parent = nullptr);
bool deAuthorizationInstructor(QString login);
bool authorizationIsCompleted();
void updateLabelLoggedInInstructor(QString login, QString name);
void updateLabelLoggedInInstructor(Instructor& instructor);
void updateLabelServer();
void setLanguageInterfase();
private:
WaitAnimationWidget *waitAnimationWidget;
ConnectorToServer* connectorToServer;
ViewerTrainees* viewerTrainees;
@@ -104,16 +103,10 @@ private:
DialogSettings* dlgSettings;
DialogAuthorization* dlgAuthorization;
bool adminMode;
QString loginInstructorLoggedInLocal;
QString nameInstructorLoggedInLocal;
QString idInstructorLoggedInLocal;
WaitAnimationWidget *waitAnimationWidget;
Instructor instructorLoggedInLocal;
QTranslator qtLanguageTranslator;
QString language;
bool flSettingsServerIsChanged;
bool flTryConnectToServer;
@@ -121,6 +114,9 @@ private:
bool flTryLogin;
QTranslator qtLanguageTranslator;
QString language;
Ui::InstructorsAndTraineesWidget *ui;
};

View File

@@ -12,7 +12,7 @@ DialogEditGroup::DialogEditGroup(QWidget *parent) :
ui->setupUi(this);
verify();
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
ui->editName->setProperty("mandatoryField", true);
}

View File

@@ -22,7 +22,7 @@ DialogEditTrainee::DialogEditTrainee(bool adminMode, QWidget *parent) :
ui->btnViewPassword->setObjectName("btnViewPassword");
ui->btnChangePassword->setObjectName("btnChangePassword");
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
ui->editPassword->setEnabled(false);