Merge branch 'work31' into DEV

This commit is contained in:
2025-12-01 10:12:04 +03:00
55 changed files with 618 additions and 425 deletions

View File

@@ -12,6 +12,9 @@ kanban-plugin: board
## Completed
- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!)
[Возможно, поможет переинициализация мессенджера при переавторизации инструктора?]
- [ ] Отображать текущую версию data в статус баре
- [ ] Сделать крутилку на начальную загрузку Сервера
- [ ] Логин суперпользователя PostgreSQL предлагать по умолчанию postgres
- [ ] Сделать несколько попыток подключения к серверу
@@ -64,15 +67,12 @@ kanban-plugin: board
## GUI Messenger
- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!)
[Возможно, поможет переинициализация мессенджера при переавторизации инструктора?]
- [ ] Не влазиют слишком большие сообщения
- [ ] Не видно новых пришедших сообщений, если выбран другой Юзер
## GUI общие
- [ ] Отображать текущую версию data в статус баре
- [ ] Текстовый поиск в задачах

View File

@@ -13,11 +13,10 @@ MainWindow::MainWindow(QWidget *parent)
ui->setupUi(this);
instructorsAndTraineesWidget = new InstructorsAndTraineesWidget(this);
ui->horizontalLayout->addWidget(instructorsAndTraineesWidget);
connect(instructorsAndTraineesWidget, &InstructorsAndTraineesWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged);
ui->horizontalLayout->addWidget(instructorsAndTraineesWidget);
this->move(0, 0);
//this->showNormal();
this->showMaximized();

View File

@@ -27,8 +27,6 @@ add_library(InstructorsAndTrainees SHARED
specialmessagebox/specialmessagebox.cpp
specialmessagebox/specialmessagebox.h
specialmessagebox/specialmessagebox.ui
specialmessagebox/notifycontroller.cpp
specialmessagebox/notifycontroller.h
authorization/dialogauthorization.cpp
authorization/dialogauthorization.h
@@ -141,6 +139,8 @@ add_library(InstructorsAndTrainees SHARED
widgets/waitanimationwidget.cpp
widgets/waitanimationwidget.h
widgets/waitanimationwidget.ui
widgets/widgettools.cpp
widgets/widgettools.h
InstructorsAndTrainees.qrc
)

View File

@@ -413,7 +413,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
QFile xmlInFile(xmlFileName);
if (!xmlInFile.open(QFile::ReadOnly | QFile::Text))
{
SpecialMessageBox(nullptr, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + xmlFileName).exec();
SpecMsgBox::CriticalClose(nullptr, tr("The file could not be opened ") + xmlFileName);
return;
}
else
@@ -490,17 +490,17 @@ void RecognizeSystem::xmlParser(QByteArray array)
if (value == "BASEDELETETRY")
{
emit sigNotify(tr("You cannot delete the basic version!"));
emit sigNotifyVersionControl(tr("You cannot delete the basic version!"));
}
if (value == "TRYACTIVEDELETE")
{
emit sigNotify(tr("You cannot delete the active version"));
emit sigNotifyVersionControl(tr("You cannot delete the active version"));
}
if (value == "DUPLICATEVERNAME")
{
emit sigNotify(tr("This name already exists"));
emit sigNotifyVersionControl(tr("This name already exists"));
}
}
}

View File

@@ -56,7 +56,7 @@ signals:
void sigAnswerQueryTasksXML_AMM(QByteArray array);
void sigShowServerDataList(QList<StreamingVersionData*> *versions);
void sigSetVersion(StreamingVersionData* serverVersion);
void sigNotify(QString text, QWidget *parentWidget = nullptr);
void sigNotifyVersionControl(QString text);
void sigAnimationActivated(bool flag);
void sigHashReady();
void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode);

View File

@@ -1,15 +1,13 @@
#include "connectortoserver.h"
#include <QThread>
ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
ConnectorToServer::ConnectorToServer(QObject *parent) :
QObject(parent),
parentWidget(parentWidget),
connectionThread(nullptr),
client(nullptr),
dataParser(nullptr),
sendSystem(nullptr),
recognizeSystem(nullptr),
notifyController(nullptr),
fl_GetedOfflineMessages(false),
nameInstructorLoggedInLocal("")
{
@@ -19,7 +17,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
ConnectorToServer::~ConnectorToServer()
{
delete client;
delete notifyController;
delete recognizeSystem;
delete sendSystem;
delete dataParser;
@@ -115,6 +112,11 @@ void ConnectorToServer::slot_getVersion()
emit signal_SendGetVersion();
}
void ConnectorToServer::slot_NotifyVersionControl(QString text)
{
emit signal_NotifyVersionControl(text);
}
void ConnectorToServer::initialize()
{
createObjects();
@@ -159,7 +161,7 @@ void ConnectorToServer::bindConnection()
connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigNotifyVersionControl,this,&ConnectorToServer::slot_NotifyVersionControl,Qt::AutoConnection);
connect(recognizeSystem,&RecognizeSystem::sigHashReady,this,&ConnectorToServer::slot_HashReady);
@@ -190,8 +192,6 @@ void ConnectorToServer::createObjects()
recognizeSystem = new RecognizeSystem;
recognizeSystem->moveToThread(connectionThread);
notifyController = new NotifyController(parentWidget);
connectionThread->start();
connectionThread->setPriority(QThread::HighestPriority);
}

View File

@@ -14,7 +14,6 @@
#include "computer.h"
#include "classroom.h"
#include "Datas.h"
#include "notifycontroller.h"
#include "streamingversiondata.h"
class ConnectorToServer : public QObject
@@ -22,7 +21,7 @@ class ConnectorToServer : public QObject
Q_OBJECT
public:
explicit ConnectorToServer(QWidget* parentWidget, QObject *parent = nullptr);
explicit ConnectorToServer(QObject *parent = nullptr);
~ConnectorToServer();
public:
@@ -116,6 +115,8 @@ public slots:
void slot_getVersion();
void slot_NotifyVersionControl(QString text);
signals:
void sigSetConnect(ServerSettings* serverSettings,QThread *thread);
void sigStopConnect();
@@ -157,19 +158,19 @@ signals:
void signal_showServerList(QList<StreamingVersionData*> *serverList);
void signal_SendGetVersion();
void signal_NotifyVersionControl(QString text);
private:
void initialize();
void bindConnection();
void createObjects();
private:
QWidget* parentWidget;
QThread *connectionThread;
TCPClient *client;
DataParser *dataParser;
SendSystem *sendSystem;
RecognizeSystem *recognizeSystem;
NotifyController *notifyController;
//Списочная модель БД СУО
QMutex mtxAccess;

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

@@ -3,7 +3,7 @@
#include <QDialog>
#include "instructor.h"
#include "ui_dialogeditinstructor.h"
//#include "ui_dialogeditinstructor.h"
namespace Ui {
class DialogEditInstructor;

View File

@@ -1,12 +1,12 @@
#include <QMessageBox>
#include "editorinstructors.h"
#include "dialogeditinstructor.h"
#include "specialmessagebox.h"
#include "ui_editorinstructors.h"
EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
ui(new Ui::EditorInstructors)
ui(new Ui::EditorInstructors),
dlgEditInstructor(nullptr)
{
ui->setupUi(this);
@@ -34,12 +34,20 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool
EditorInstructors::~EditorInstructors()
{
if(dlgEditInstructor)
{
dlgEditInstructor->close();
delete dlgEditInstructor;
dlgEditInstructor = nullptr;
}
delete ui;
}
void EditorInstructors::closeEvent(QCloseEvent *event)
{
if(dlgEditInstructor)
dlgEditInstructor->close();
}
void EditorInstructors::on_btnNewInstructor_clicked()
@@ -74,17 +82,17 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
if(connectorToServer->isAdminInstructor(id))
{//Это Админ!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete the Administrator.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot delete the Administrator."));
return;
}
if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in instructor.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in instructor."));
return;
}
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id);
@@ -119,7 +127,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
{//Не Архивный
if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in instructor.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in instructor."));
return;
}
@@ -156,7 +164,7 @@ void EditorInstructors::on_btnEdit_clicked()
if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in instructor.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in instructor."));
return;
}
@@ -262,19 +270,19 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
if(instructor.getName() == QStringLiteral("<name>"))
{//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
return false;
}
if(instructor.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
return false;
}
if(instructor.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
return false;
}
@@ -283,7 +291,7 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin());
if((user_I && (user_I != instructor.getID())) || (user_T && (user_T != instructor.getID())))
{//Логин уже существует!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
@@ -292,22 +300,25 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instructor_edit)
{
DialogEditInstructor dlg(adminMode, this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlgEditInstructor = new DialogEditInstructor(adminMode, this);
dlgEditInstructor->setWindowFlags(dlgEditInstructor->windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlg.setInstructor(instructor);
dlgEditInstructor->setInstructor(instructor);
while (true)
bool flStop = false;
bool res = false;
while (!flStop)
{
switch( dlg.exec() )
switch( dlgEditInstructor->exec() )
{
case QDialog::Accepted:
{
*instructor_edit = dlg.getInstructor();
*instructor_edit = dlgEditInstructor->getInstructor();
if(! verifyInstructor(*instructor_edit))
{
dlg.setInstructor(*instructor_edit);
dlgEditInstructor->setInstructor(*instructor_edit);
continue;
}
@@ -318,14 +329,28 @@ bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instru
instructor_edit->setNeedSetPassword(false);
}
return true;
flStop = true;
res = true;
break;
}
case QDialog::Rejected:
return false;
flStop = true;
res = false;
break;
default:
return false;
flStop = true;
res = false;
break;
}
}
if(dlgEditInstructor)
{
delete dlgEditInstructor;
dlgEditInstructor = nullptr;
}
return res;
}

View File

@@ -4,6 +4,10 @@
#include <QDialog>
#include <QTreeWidget>
#include "instructorsview.h"
#include "dialogeditinstructor.h"
#include "specialmessagebox.h"
class DialogEditInstructor;
namespace Ui {
class EditorInstructors;
@@ -37,6 +41,8 @@ private:
private:
Ui::EditorInstructors *ui;
DialogEditInstructor* dlgEditInstructor;
};
#endif // DIALOGINSTRUCTORS_H

View File

@@ -51,7 +51,7 @@
<string>New instructor</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/addInstructor.png</normaloff>:/resources/icons/addInstructor.png</iconset>
</property>
<property name="iconSize">
@@ -89,7 +89,7 @@
<string>Delete instructor</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/deleteInstructor.png</normaloff>:/resources/icons/deleteInstructor.png</iconset>
</property>
<property name="iconSize">
@@ -127,7 +127,7 @@
<string>To archive</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/instructorArchive.png</normaloff>:/resources/icons/instructorArchive.png</iconset>
</property>
<property name="iconSize">
@@ -165,7 +165,7 @@
<string>Edit</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/edit.png</normaloff>:/resources/icons/edit.png</iconset>
</property>
<property name="iconSize">
@@ -216,7 +216,7 @@
<string>Show archive</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/archive.png</normaloff>:/resources/icons/archive.png</iconset>
</property>
<property name="iconSize">
@@ -240,7 +240,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -25,7 +25,11 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
ViewerInstructors::~ViewerInstructors()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
delete ui;
}
@@ -38,7 +42,11 @@ void ViewerInstructors::setAuthComplited(bool authComplited)
void ViewerInstructors::deactivate()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
CommonView::deactivate();
updateButtons();

View File

@@ -44,7 +44,7 @@
<string>Editor of Instructors</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/DB-instructors.png</normaloff>:/resources/icons/DB-instructors.png</iconset>
</property>
<property name="iconSize">
@@ -67,7 +67,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -7,6 +7,7 @@
#include "dialogsettings.h"
#include "specialmessagebox.h"
#include "hashtools.h"
#include "widgettools.h"
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
@@ -15,7 +16,6 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
QWidget(parent),
waitAnimationWidget(nullptr),
connectorToServer(nullptr),
viewerTrainees(nullptr),
viewerInstructors(nullptr),
@@ -24,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);
@@ -50,7 +47,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
setLanguageInterfase();
connectorToServer = new ConnectorToServer(this);
connectorToServer = new ConnectorToServer();
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
connect(connectorToServer, &ConnectorToServer::sigServerBlocked, this, &InstructorsAndTraineesWidget::slot_ServerBlocked);
@@ -108,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
{
if(authorizationIsCompleted())
deAuthorizationInstructor(loginInstructorLoggedInLocal);
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
if(dlgTasksCommon)
{
@@ -154,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
{// переведём окно заново
ui->retranslateUi(this);
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
updateLabelLoggedInInstructor(instructorLoggedInLocal);
updateLabelServer();
}
}
@@ -179,7 +176,7 @@ QString InstructorsAndTraineesWidget::loadStyleSheet()
QFile styleSheetFile(fileName);
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
{
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + fileName).exec();
SpecMsgBox::CriticalClose(this, tr("The file could not be opened ") + fileName);
return QStringLiteral("");
}
else
@@ -209,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());
@@ -255,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);
@@ -268,12 +266,12 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
ui->btnEditorInstructors->setEnabled(false);
ui->btnPersonalCard->setEnabled(false);
updateLabelLoggedInInstructor("","");
updateLabelLoggedInInstructor(instructorLoggedInLocal);
}
else
{
ui->btnAuthorizationInstructor->setChecked(true);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec();
SpecMsgBox::CriticalClose(this, tr("Instructor deauthorization") + "\n" + tr("Error!"));
}
}
@@ -285,7 +283,7 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked()
waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec();
SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + tr("Server blocked!"));
}
}
@@ -317,7 +315,7 @@ void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error)
errorTextMsg = tr("Login or password error!");
}
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec();
SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + errorTextMsg);
}
}
@@ -336,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;
@@ -375,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)
@@ -386,7 +386,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
if(cntTryConnectToServer < 10)
{
cntTryConnectToServer++;
QTimer::singleShot(1000, this, SLOT(slot_ConnectToServer()));
QTimer::singleShot(1000, this, SLOT(slot_TryConnectToServer()));
}
else
{
@@ -406,7 +406,10 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
if(!flSettingsServerIsChanged)
{
if(!flTryConnectToServer)
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec();
{
WidgetTools::closeAllChildWidgets(this, "SpecMsgBox");
SpecMsgBox::WarningClose(this, tr("The server is not available!"));
}
}
else
flSettingsServerIsChanged = false;
@@ -443,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())
@@ -456,7 +459,7 @@ void InstructorsAndTraineesWidget::slot_AnswerDocsChanged()
viewerTrainees->getAmmTasksWidgetCommon()->setDocsActualed(false);
}
void InstructorsAndTraineesWidget::slot_ConnectToServer()
void InstructorsAndTraineesWidget::slot_TryConnectToServer()
{
updateLabelServer();
connectorToServer->SetConnectToServer();
@@ -519,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login)
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
{
if(loginInstructorLoggedInLocal == QStringLiteral(""))
if(instructorLoggedInLocal.getLogin() == QStringLiteral(""))
return false;
else
return true;
@@ -536,7 +539,7 @@ void InstructorsAndTraineesWidget::on_btnConnectionToServer_clicked()
updateLabelServer();
QTimer::singleShot(1000, this, SLOT(slot_ConnectToServer()));
QTimer::singleShot(1000, this, SLOT(slot_TryConnectToServer()));
}
void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
@@ -558,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);
@@ -578,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")));
@@ -640,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);
@@ -654,12 +657,12 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
if(dlgSettings->settingsServerIsChanged())
{
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec();
SpecMsgBox::WarningClose(this, tr("Server settings have been changed.\nPlease reconnect to the server."));
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 {
@@ -65,7 +66,7 @@ public Q_SLOTS:
void slot_AnswerDocsChanged();
void slot_ConnectToServer();
void slot_TryConnectToServer();
Q_SIGNALS:
//сигнал смены языка
@@ -79,24 +80,18 @@ private Q_SLOTS:
void on_btnSettings_clicked();
void on_btnEditorTrainees_clicked();
void on_btnEditorInstructors_clicked();
void on_btnPersonalCard_clicked();
void on_btnTasksCommon_clicked();
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;
@@ -108,13 +103,9 @@ private:
DialogSettings* dlgSettings;
DialogAuthorization* dlgAuthorization;
bool adminMode;
QString loginInstructorLoggedInLocal;
QString nameInstructorLoggedInLocal;
QString idInstructorLoggedInLocal;
WaitAnimationWidget *waitAnimationWidget;
QTranslator qtLanguageTranslator;
QString language;
Instructor instructorLoggedInLocal;
bool flSettingsServerIsChanged;
@@ -123,6 +114,9 @@ private:
bool flTryLogin;
QTranslator qtLanguageTranslator;
QString language;
Ui::InstructorsAndTraineesWidget *ui;
};

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1314</width>
<height>901</height>
<width>1300</width>
<height>900</height>
</rect>
</property>
<property name="sizePolicy">

View File

@@ -57,6 +57,7 @@ void DialogVersionControl::initialize(QString authorName)
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList);
connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl);
connect(this, &DialogVersionControl::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion);
connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion);
@@ -114,7 +115,7 @@ void DialogVersionControl::sendCopyEmit(QString newName)
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
SpecMsgBox::WarningClose(this, text);
return;
}
@@ -127,7 +128,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
SpecMsgBox::WarningClose(this, text);
return;
}
@@ -160,7 +161,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked()
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
SpecMsgBox::WarningClose(this, text);
return;
}
@@ -172,7 +173,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked()
if (selectedVersion == nullptr)
{
QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
SpecMsgBox::WarningClose(this, text);
return;
}
@@ -209,6 +210,11 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
flGetVersion = true;
}
void DialogVersionControl::slot_NotifyVersionControl(QString text)
{
SpecMsgBox::WarningClose(this, text);
}
void DialogVersionControl::resizeEvent(QResizeEvent *event)
{
QSize size = event->size();

View File

@@ -39,6 +39,7 @@ private slots:
void slot_activateLoadAnimation(bool flag);
void slot_showServerList(QList<StreamingVersionData*> *serverList);
void slot_SetVersion(StreamingVersionData* serverVersion);
void slot_NotifyVersionControl(QString text);
signals:
void sigSendDeleteVersion(StreamingVersionData *streaming);

View File

@@ -1,19 +0,0 @@
#include <QMessageBox>
#include "notifycontroller.h"
#include "specialmessagebox.h"
NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) :
QObject(parent),
parentWidget(parentWidget)
{
}
void NotifyController::showWarning(QString text, QWidget *parentWidget)
{
if(parentWidget)
SpecialMessageBox(parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
else
SpecialMessageBox(this->parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec();
}

View File

@@ -1,20 +0,0 @@
#ifndef NOTIFYCONTROLLER_H
#define NOTIFYCONTROLLER_H
#include <QObject>
#include <QWidget>
class NotifyController : public QObject
{
Q_OBJECT
public:
explicit NotifyController(QWidget *parentWidget = nullptr, QObject *parent = nullptr);
void showWarning(QString text, QWidget *parentWidget = nullptr);
private:
QWidget *parentWidget;
};
#endif // NOTIFYCONTROLLER_H

View File

@@ -2,12 +2,14 @@
#include "specialmessagebox.h"
#include "ui_specialmessagebox.h"
SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) :
SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) :
QDialog(parent),
ui(new Ui::SpecialMessageBox)
{
ui->setupUi(this);
this->setObjectName("SpecMsgBox");
this->setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
if(type == TypeSpecMsgBox::warningYesNo)
@@ -22,14 +24,14 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const
ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close"));
}
else if(type == TypeSpecMsgBox::critical)
else if(type == TypeSpecMsgBox::criticalClose)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/critical.png")));
this->setWindowTitle(tr("Error!"));
ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close"));
}
else if(type == TypeSpecMsgBox::info)
else if(type == TypeSpecMsgBox::infoOk)
{
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/info.png")));
this->setWindowTitle(tr("Information"));
@@ -40,17 +42,43 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const
ui->lblText->setText(text);
}
SpecialMessageBox::~SpecialMessageBox()
SpecMsgBox::~SpecMsgBox()
{
delete ui;
}
void SpecialMessageBox::on_btnYes_clicked()
int SpecMsgBox::WarningYesNo(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::warningYesNo, text);
}
int SpecMsgBox::WarningClose(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::warningClose, text);
}
int SpecMsgBox::CriticalClose(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::criticalClose, text);
}
int SpecMsgBox::InfoOk(QWidget *parent, const QString &text)
{
return SpecMsgBox::work(parent, TypeSpecMsgBox::infoOk, text);
}
int SpecMsgBox::work(QWidget *parent, TypeSpecMsgBox type, const QString& text)
{
SpecMsgBox *msgBox = new SpecMsgBox(parent, type, text);
return msgBox->exec();
}
void SpecMsgBox::on_btnYes_clicked()
{
this->accept();
}
void SpecialMessageBox::on_btnNo_clicked()
void SpecMsgBox::on_btnNo_clicked()
{
this->reject();
}

View File

@@ -2,12 +2,13 @@
#define SPECIALMESSAGEBOX_H
#include <QDialog>
#include "instructorsAndTrainees_global.h"
namespace Ui {
class SpecialMessageBox;
}
class SpecialMessageBox : public QDialog
class INSTRUCTORSANDTRAINEES_EXPORT SpecMsgBox : public QDialog
{
Q_OBJECT
@@ -15,13 +16,23 @@ public:
enum TypeSpecMsgBox {
warningYesNo,
warningClose,
critical,
info
criticalClose,
infoOk
};
private:
explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
public:
explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
~SpecialMessageBox();
~SpecMsgBox();
public:
static int WarningYesNo(QWidget *parent, const QString& text);
static int WarningClose(QWidget *parent, const QString& text);
static int CriticalClose(QWidget *parent, const QString& text);
static int InfoOk(QWidget *parent, const QString& text);
private:
static int work(QWidget *parent, TypeSpecMsgBox type, const QString& text);
private slots:
void on_btnYes_clicked();

View File

@@ -9,6 +9,7 @@
#include "ui_ammtaskswidget.h"
#include "checkertask.h"
#include "specialmessagebox.h"
#include "widgettools.h"
AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
QWidget(parent),
@@ -145,14 +146,15 @@ void AMMtasksWidget::resizeEvent(QResizeEvent *event)
waitAnimationWidget->resize(size);
}
void AMMtasksWidget::closeDlgCheckTask()
void AMMtasksWidget::closeEvent(QCloseEvent *event)
{
closeChildDlg();
}
void AMMtasksWidget::closeChildDlg()
{
if(dlgCheckerTask)
dlgCheckerTask->close();
}
void AMMtasksWidget::closeDlgListSubProc()
{
if(dlgListSubProc)
dlgListSubProc->close();
}
@@ -325,7 +327,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
lastSelectedTask.listSubProc.clear();
dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc);
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
{
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
}
@@ -347,7 +349,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
{
lastSelectedTask.listSubProc.clear();
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
{
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
}
@@ -504,7 +506,7 @@ void AMMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id);

View File

@@ -10,6 +10,7 @@
#include "dialogchekertask.h"
#include "dialoglistsubproc.h"
#include "waitanimationwidget.h"
#include "specialmessagebox.h"
namespace Ui {
class AMMtasksWidget;
@@ -31,8 +32,10 @@ public:
public:
void resizeEvent(QResizeEvent *event) override;
void closeDlgCheckTask();
void closeDlgListSubProc();
void closeEvent(QCloseEvent *event) override;
void closeChildDlg();
protected:
void changeEvent(QEvent * event) override;

View File

@@ -48,6 +48,7 @@ CheckerTask::~CheckerTask()
delete fimTasksWidget;
fimTasksWidget = nullptr;
}
delete ui;
}
@@ -175,7 +176,7 @@ void CheckerTask::on_btnWrong_clicked()
msgString = tr("Change task status?\nThe status will be set:\n'new'");
}
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
{
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
this->parentWidget()->close();
@@ -202,7 +203,7 @@ void CheckerTask::on_btnRight_clicked()
msgString = tr("Change task status?\nThe status will be set:\n'completed'");
}
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
{
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
this->parentWidget()->close();

View File

@@ -6,6 +6,7 @@
//#include "fimtaskswidget.h"
#include "module.h"
#include "connectortoserver.h"
#include "specialmessagebox.h"
namespace Ui {
class CheckerTask;

View File

@@ -101,9 +101,7 @@ FIMtasksWidget::~FIMtasksWidget()
delete treeWidget;
if(dlgCheckerTask)
{
dlgCheckerTask->close();
}
delete ui;
}
@@ -130,7 +128,12 @@ void FIMtasksWidget::resizeEvent(QResizeEvent *event)
waitAnimationWidget->resize(size);
}
void FIMtasksWidget::closeDlgCheckTask()
void FIMtasksWidget::closeEvent(QCloseEvent *event)
{
closeChildDlg();
}
void FIMtasksWidget::closeChildDlg()
{
if(dlgCheckerTask)
dlgCheckerTask->close();
@@ -393,7 +396,7 @@ void FIMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_FIM_TO_TRAINEE, id);
@@ -437,7 +440,7 @@ void FIMtasksWidget::on_btnCheck_clicked()
void FIMtasksWidget::on_btnAssignTask_clicked()
{
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
assignTaskFIMtoTrainee();
}

View File

@@ -8,6 +8,7 @@
#include "tasktreepreparation.h"
#include "dialogchekertask.h"
#include "waitanimationwidget.h"
#include "specialmessagebox.h"
namespace Ui {
class FIMtasksWidget;
@@ -31,7 +32,10 @@ public:
public:
void resizeEvent(QResizeEvent *event) override;
void closeDlgCheckTask();
void closeEvent(QCloseEvent *event) override;
void closeChildDlg();
protected:
void changeEvent(QEvent * event) override;

View File

@@ -1,7 +1,8 @@
#include "dialogeditgroup.h"
#include "computersLocations.h"
#include <QPushButton>
#include <QRegExpValidator>
#include "dialogeditgroup.h"
#include "computersLocations.h"
#include "ui_dialogeditgroup.h"
DialogEditGroup::DialogEditGroup(QWidget *parent) :
QDialog(parent),
@@ -11,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

@@ -2,7 +2,7 @@
#define DIALOGEDITGROUP_H
#include <QDialog>
#include "ui_dialogeditgroup.h"
//#include "ui_dialogeditgroup.h"
#include "computersLocations.h"
#include "group.h"

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);

View File

@@ -7,7 +7,9 @@
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
ui(new Ui::EditorTrainees)
ui(new Ui::EditorTrainees),
dlgEditTrainee(nullptr),
dlgEditGroup(nullptr)
{
ui->setupUi(this);
@@ -38,12 +40,30 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM
EditorTrainees::~EditorTrainees()
{
if(dlgEditTrainee)
{
dlgEditTrainee->close();
delete dlgEditTrainee;
dlgEditTrainee = nullptr;
}
if(dlgEditGroup)
{
dlgEditGroup->close();
delete dlgEditGroup;
dlgEditGroup = nullptr;
}
delete ui;
}
void EditorTrainees::closeEvent(QCloseEvent *event)
{
if(dlgEditTrainee)
dlgEditTrainee->close();
if(dlgEditGroup)
dlgEditGroup->close();
}
void EditorTrainees::on_btnNewGroup_clicked()
@@ -73,12 +93,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
{
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")).exec();
SpecMsgBox::CriticalClose(this, tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
return;
}
else
{//Пустая группа
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
@@ -129,11 +149,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in trainee.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in trainee."));
return;
}
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
@@ -168,7 +188,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
{//Не Архивный
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in trainee.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in trainee."));
return;
}
@@ -214,7 +234,7 @@ void EditorTrainees::on_btnEdit_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in trainee.")).exec();
SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in trainee."));
return;
}
@@ -383,7 +403,7 @@ bool EditorTrainees::verifyGroup(Group group)
if(group.getName() == QStringLiteral("<group>"))
{//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
return false;
}
@@ -393,7 +413,7 @@ bool EditorTrainees::verifyGroup(Group group)
{
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
{//Имя уже существует
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing group name has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("An existing group name has been entered.\nThe changes will not be accepted."));
return false;
}
}
@@ -407,19 +427,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
if(trainee.getName() == QStringLiteral("<name>"))
{//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
return false;
}
if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
return false;
}
if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
return false;
}
@@ -428,7 +448,7 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin());
if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID())))
{//Логин уже существует!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec();
SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0;
}
@@ -437,53 +457,73 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
bool EditorTrainees::editGroup(Group group, Group *group_edit)
{
DialogEditGroup dlg(this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlgEditGroup = new DialogEditGroup(this);
dlgEditGroup->setWindowFlags(dlgEditGroup->windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlg.setGroup(group);
dlgEditGroup->setGroup(group);
while (true)
bool flStop = false;
bool res = false;
while (!flStop)
{
switch( dlg.exec() )
switch( dlgEditGroup->exec() )
{
case QDialog::Accepted:
{
*group_edit = dlg.getGroup();
*group_edit = dlgEditGroup->getGroup();
if(! verifyGroup(*group_edit))
{
dlg.setGroup(*group_edit);
dlgEditGroup->setGroup(*group_edit);
continue;
}
return true;
flStop = true;
res = true;
break;
}
case QDialog::Rejected:
return false;
flStop = true;
res = false;
break;
default:
return false;
flStop = true;
res = false;
break;
}
}
if(dlgEditGroup)
{
delete dlgEditGroup;
dlgEditGroup = nullptr;
}
return res;
}
bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
{
DialogEditTrainee dlg(adminMode, this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlgEditTrainee = new DialogEditTrainee(adminMode, this);
dlgEditTrainee->setWindowFlags(dlgEditTrainee->windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlg.setTrainee(trainee);
dlgEditTrainee->setTrainee(trainee);
while (true)
bool flStop = false;
bool res = false;
while (!flStop)
{
switch( dlg.exec() )
switch( dlgEditTrainee->exec() )
{
case QDialog::Accepted:
{
*trainee_edit = dlg.getTrainee();
*trainee_edit = dlgEditTrainee->getTrainee();
if(! verifyTrainee(*trainee_edit))
{
dlg.setTrainee(*trainee_edit);
dlgEditTrainee->setTrainee(*trainee_edit);
continue;
}
@@ -494,14 +534,28 @@ bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
trainee_edit->setNeedSetPassword(false);
}
return true;
flStop = true;
res = true;
break;
}
case QDialog::Rejected:
return false;
flStop = true;
res = false;
break;
default:
return false;
flStop = true;
res = false;
break;
}
}
if(dlgEditTrainee)
{
delete dlgEditTrainee;
dlgEditTrainee = nullptr;
}
return res;
}

View File

@@ -5,6 +5,9 @@
#include <QTreeWidget>
#include "traineesview.h"
//#include "computersLocations.h"
#include "dialogedittrainee.h"
#include "dialogeditgroup.h"
#include "specialmessagebox.h"
namespace Ui {
class EditorTrainees;
@@ -43,6 +46,9 @@ private:
private:
Ui::EditorTrainees *ui;
DialogEditTrainee* dlgEditTrainee;
DialogEditGroup* dlgEditGroup;
};
#endif // DIALOGTRAINEESGROUPS_H

View File

@@ -78,10 +78,11 @@ PersonalCardTrainee::~PersonalCardTrainee()
void PersonalCardTrainee::closeEvent(QCloseEvent *event)
{
fimTasksWidget_personal->closeDlgCheckTask();
ammTasksWidget_personal->closeDlgCheckTask();
fimTasksWidget_personal->closeChildDlg();
fimTasksWidget_common->closeChildDlg();
ammTasksWidget_common->closeDlgListSubProc();
ammTasksWidget_personal->closeChildDlg();
ammTasksWidget_common->closeChildDlg();
}
void PersonalCardTrainee::loadInfo()

View File

@@ -49,7 +49,11 @@ ViewerTrainees::~ViewerTrainees()
}
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(dlgCardTrainee)
dlgCardTrainee->close();
@@ -66,7 +70,11 @@ void ViewerTrainees::setAuthComplited(bool authComplited)
void ViewerTrainees::deactivate()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(dlgCardTrainee)
dlgCardTrainee->close();

View File

@@ -971,7 +971,17 @@ Delete it anyway?</source>
<translation>Сервер: </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="424"/>
<location filename="../instructorsandtraineeswidget.ui" line="386"/>
<source>Version of materials: </source>
<translation>Версия материалов: </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="393"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="448"/>
<source> Instructor: </source>
<translation> Инструктор: </translation>
</message>
@@ -991,85 +1001,85 @@ Delete it anyway?</source>
<translation>Инструкторы</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="369"/>
<location filename="../instructorsandtraineeswidget.ui" line="443"/>
<location filename="../instructorsandtraineeswidget.cpp" line="587"/>
<location filename="../instructorsandtraineeswidget.ui" line="375"/>
<location filename="../instructorsandtraineeswidget.ui" line="467"/>
<location filename="../instructorsandtraineeswidget.cpp" line="594"/>
<source>none</source>
<translation>нет</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="181"/>
<location filename="../instructorsandtraineeswidget.cpp" line="182"/>
<source>The file could not be opened </source>
<translation>Файл не может быть открыт </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="287"/>
<location filename="../instructorsandtraineeswidget.cpp" line="319"/>
<location filename="../instructorsandtraineeswidget.cpp" line="288"/>
<location filename="../instructorsandtraineeswidget.cpp" line="320"/>
<source>Instructor authorization.</source>
<translation>Авторизация инструктора.</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="275"/>
<location filename="../instructorsandtraineeswidget.cpp" line="276"/>
<source>Instructor deauthorization</source>
<translation>Деавторизация инструктора</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="275"/>
<location filename="../instructorsandtraineeswidget.cpp" line="276"/>
<source>Error!</source>
<translation>Ошибка!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="287"/>
<location filename="../instructorsandtraineeswidget.cpp" line="288"/>
<source>Server blocked!</source>
<translation>Сервер заблокирован!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="304"/>
<location filename="../instructorsandtraineeswidget.cpp" line="305"/>
<source>Database error!</source>
<translation>Ошибка базы данных!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="308"/>
<location filename="../instructorsandtraineeswidget.cpp" line="309"/>
<source>The user is archived!</source>
<translation>Пользователь является архивным!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="312"/>
<location filename="../instructorsandtraineeswidget.cpp" line="313"/>
<source>The user is already logged in!</source>
<translation>Пользователь уже в сети!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="316"/>
<location filename="../instructorsandtraineeswidget.cpp" line="317"/>
<source>Login or password error!</source>
<translation>Ошибка логина или пароля!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="402"/>
<location filename="../instructorsandtraineeswidget.cpp" line="409"/>
<source>The server is not available!</source>
<translation>Сервер недоступен!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="599"/>
<location filename="../instructorsandtraineeswidget.cpp" line="606"/>
<source>Connection attempt</source>
<translation>Попытка соединения</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="606"/>
<location filename="../instructorsandtraineeswidget.cpp" line="613"/>
<source>connected</source>
<translation>подключен</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="609"/>
<location filename="../instructorsandtraineeswidget.cpp" line="616"/>
<source>not connected</source>
<translation>не подключен</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="650"/>
<location filename="../instructorsandtraineeswidget.cpp" line="657"/>
<source>Server settings have been changed. Please reconnect to the server.</source>
<translation>Настройки сервера изменены. Выполните переподключение к серверу.</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="462"/>
<location filename="../instructorsandtraineeswidget.cpp" line="469"/>
<source>Instructor authorization</source>
<translation>Авторизация инструктора</translation>
</message>

View File

@@ -0,0 +1,24 @@
#include "widgettools.h"
WidgetTools::WidgetTools()
{
}
// Рекурсивная функция для закрытия всех дочерних виджетов
void WidgetTools::closeAllChildWidgets(QWidget *parent, QString objName)
{
// Ищем всех дочерних виджетов типа QWidget
QObjectList children = parent->children();
foreach(auto obj, children)
{
if (auto wgt = qobject_cast<QWidget*>(obj))
{ // Проверяем имя объекта
if(wgt->objectName() == objName)
{
wgt->close(); // Закрываем виджет
}
closeAllChildWidgets(wgt, objName); // Рекурсия для возможных внучатых виджетов
}
}
}

View File

@@ -0,0 +1,16 @@
#ifndef WIDGETTOOLS_H
#define WIDGETTOOLS_H
#include <QWidget>
class WidgetTools
{
public:
WidgetTools();
public:
static void closeAllChildWidgets(QWidget* parent, QString objName);
};
#endif // WIDGETTOOLS_H

View File

@@ -87,6 +87,7 @@ target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../Instr
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/authorization)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets)
target_include_directories(ServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox)
if(PROJECT_TYPE_DEBUG)
target_link_directories(ServerLMS PUBLIC ${REPO_PATH}/BUILDS/Debug64/InstructorsAndTrainees)
else()

View File

@@ -17,7 +17,8 @@ public:
this->name = name;
this->address = address;
this->port = port;
this->fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
//this->fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
this->fullName = "IP: " + address + " port : " + port + " login: " + login;
};
~Client(){};
@@ -31,7 +32,8 @@ public:
{
this->login = login;
isLoggedIn = true;
fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
//fullName = "Name: " + name + " IP: " + address + " port : " + port + " login: " + login;
fullName = "IP: " + address + " port : " + port + " login: " + login;
}
QString getLogin()
{

View File

@@ -53,7 +53,22 @@ void Logger::setLogToFile(bool flag)
void Logger::handleLog(QString msg, LogLevel logLevel)
{
/*
color: red; * Красный *
color: green; * Зелёный *
color: blue; * Синий *
color: yellow; * Жёлтый *
color: black; * Чёрный *
color: white; * Белый *
color: purple; * Фиолетовый *
color: orange; * Оранжевый *
color: pink; * Розовый *
color: brown; * Коричневый *
color: gray; * Серый *
*/
QString level;
QString colorLevel = "pink";
#ifndef PROJECT_TYPE_DEBUG
if(logLevel == DEBUG)
@@ -62,24 +77,44 @@ void Logger::handleLog(QString msg, LogLevel logLevel)
switch (logLevel)
{
case INFO: level = "INFO"; break;
case WARNING: level = "WARNING"; break;
case ERROR: level = "ERROR"; break;
case CRITICAL: level = "CRITICAL"; break;
case DEBUG: level = "DEBUG"; break;
case INFO:
level = "INFO";
colorLevel = "green";
break;
case WARNING:
level = "WARNING";
colorLevel = "yellow";
break;
case ERROR:
level = "ERROR";
colorLevel = "red";
break;
case CRITICAL:
level = "CRITICAL";
colorLevel = "purple";
break;
case DEBUG:
level = "DEBUG";
colorLevel = "brown";
break;
}
QString timeStamp = QDateTime::currentDateTime().toString("hh:mm:ss");
QString message = timeStamp + " " + level + " " + msg;
QString messageHTML = QString("<p><span style=\"color: blue;\">%1</span> <span style=\"color: %2;\">%3</span> <span style=\"color: black;\">%4</span></p>").
arg(timeStamp, colorLevel, level, msg);
if (loggingType == LoggingType::WIDGET)
{
emit sigLogToWidget(message);
emit sigLogToWidget(messageHTML);
}
else if(loggingType == LoggingType::CONSOLE)
{
qDebug() << message;
qDebug() << messageHTML;
}
if(isLogToFile)

View File

@@ -32,6 +32,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
first (true),
language(languageENG),
errorCode(0),
versionStr("..."),
flStartInitialization(false)
{
ui->setupUi(this);
@@ -39,6 +40,9 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
qDebug() << "ServerLMSWidget init thread ID " << QThread::currentThreadId();
ui->widget_Control->setObjectName("widgetControl");
ui->btnStopServer->setObjectName("btnStopServer");
ui->btnStartServer->setObjectName("btnStartServer");
ui->btnSettings->setObjectName("btnSettings");
registerMetaType();
@@ -125,7 +129,8 @@ void ServerLMSWidget::slot_UpdateListClients()
void ServerLMSWidget::slot_AddMessageToLog(QString message)
{
ui->loggerTextField->appendPlainText(message);
//ui->loggerTextField->appendPlainText(message);
ui->loggerTextField->appendHtml(message);
}
void ServerLMSWidget::slot_ErrorPostgreSQL(QString text)
@@ -170,6 +175,7 @@ void ServerLMSWidget::slot_startInitialization_step1()
void ServerLMSWidget::slot_setVersion(QString versionStr)
{
this->versionStr = versionStr;
ui->lblVersionText->setText(versionStr);
}
@@ -387,7 +393,7 @@ void ServerLMSWidget::startInitialization_step0()
Logger::instance().setLoggingType(LoggingType::WIDGET);
Logger::instance().setLogToFile(true);
connect(this,&ServerLMSWidget::sigUpdateControllerInitialize,updateController,&UpdateController::initialize/*,Qt::DirectConnection*/);
connect(this,&ServerLMSWidget::sigUpdateControllerInitialize,updateController,&UpdateController::initialize,Qt::DirectConnection);
connect(updateController,&UpdateController::sigInitializeFinished, this,&ServerLMSWidget::slot_startInitialization_step1/*,Qt::DirectConnection*/);
connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection);
connect(updateController,&UpdateController::sigErrorRequired,this,&ServerLMSWidget::setError);
@@ -479,4 +485,6 @@ void ServerLMSWidget::updateStateServer()
ui->btnStartServer->setEnabled(false);
}
}
ui->lblVersionText->setText(versionStr);
}

View File

@@ -29,8 +29,7 @@
#include "docsupdater.h"
#include "waitanimationwidget.h"
#include "specialmessagebox.h"
namespace Ui {
@@ -109,6 +108,14 @@ public:
void setError(int code)
{
if(code == 100)
{
QString textError = tr("No Client files found!") + "\n\n" +
tr("* check Application for the presence of a folder with a build \n"
"* check SharedData for a folder with the base version and the name base");
SpecMsgBox::CriticalClose(this, textError);
}
errorCode = code;
}
@@ -173,6 +180,8 @@ private:
QString language;
int errorCode;
QString versionStr;
bool flStartInitialization;
};

View File

@@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>1000</width>
<width>1200</width>
<height>600</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1200</width>
<height>600</height>
</size>
</property>
<property name="font">
<font>
<family>Tahoma</family>
@@ -45,14 +51,14 @@
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>55</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>80</width>
<height>40</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
@@ -86,14 +92,14 @@
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>55</height>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="baseSize">
<size>
<width>80</width>
<height>40</height>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="layoutDirection">
@@ -262,13 +268,13 @@
<widget class="QLabel" name="lblOnOffText">
<property name="minimumSize">
<size>
<width>150</width>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>150</width>
<width>100</width>
<height>16777215</height>
</size>
</property>

View File

@@ -18,6 +18,7 @@ DialogSettingsTray::DialogSettingsTray(ProviderDBLMS* providerDBLMS, QWidget *pa
ui->btnSave->setObjectName("btnSave");
ui->btnCheckDB->setObjectName("btnCheckDB");
ui->btnUpdateDocs->setObjectName("btnUpdateDocs");
ui->checkLocalhost->setObjectName("checkLocalhost");
/* Создаем строку для регулярного выражения */
QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";

View File

@@ -70,11 +70,11 @@
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_DB">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_HostName">
<layout class="QHBoxLayout" name="horizontalLayout_Local">
<item>
<widget class="QLabel" name="label_HostName">
<widget class="QLabel" name="label_Local">
<property name="text">
<string>Host name</string>
<string>Local</string>
</property>
</widget>
</item>
@@ -94,7 +94,18 @@
<item>
<widget class="QCheckBox" name="checkLocalhost">
<property name="text">
<string>Localhost</string>
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_HostName">
<item>
<widget class="QLabel" name="label_IP">
<property name="text">
<string>IP address</string>
</property>
</widget>
</item>
@@ -218,67 +229,11 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Check">
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnCheckDB">
<property name="minimumSize">
<size>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>Check</string>
</property>
<property name="icon">
<iconset resource="../ServerLMS.qrc">
<normaloff>:/resources/icons/checkDB.png</normaloff>:/resources/icons/checkDB.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_Save">
<item>
@@ -329,19 +284,19 @@
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_Additional">
<item>
<widget class="QToolButton" name="btnUpdateDocs">
<widget class="QToolButton" name="btnCheckDB">
<property name="minimumSize">
<size>
<width>80</width>
<width>58</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>Update Docs</string>
<string>Check DB</string>
</property>
<property name="icon">
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
<iconset resource="../ServerLMS.qrc">
<normaloff>:/resources/icons/checkDB.png</normaloff>:/resources/icons/checkDB.png</iconset>
</property>
<property name="iconSize">
<size>
@@ -367,6 +322,32 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="btnUpdateDocs">
<property name="minimumSize">
<size>
<width>80</width>
<height>58</height>
</size>
</property>
<property name="text">
<string>Update Docs</string>
</property>
<property name="icon">
<iconset resource="../../InstructorsAndTrainees/InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
</layout>

View File

@@ -4,7 +4,7 @@
<context>
<name>AssetsManager</name>
<message>
<location filename="../Systems/assetsmanager.cpp" line="290"/>
<location filename="../Systems/assetsmanager.cpp" line="292"/>
<source>LLC Constanta-Design</source>
<translation>ООО Константа-Дизайн</translation>
</message>
@@ -168,8 +168,8 @@
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="288"/>
<location filename="../settings/dialogsettingstray.cpp" line="340"/>
<location filename="../settings/dialogsettingstray.cpp" line="345"/>
<location filename="../settings/dialogsettingstray.cpp" line="338"/>
<location filename="../settings/dialogsettingstray.cpp" line="343"/>
<source>Error!</source>
<translation>Ошибка!</translation>
</message>
@@ -184,35 +184,35 @@
<translation>Авторизация суперпользователя PostgreSQL</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="340"/>
<location filename="../settings/dialogsettingstray.cpp" line="345"/>
<location filename="../settings/dialogsettingstray.cpp" line="338"/>
<location filename="../settings/dialogsettingstray.cpp" line="343"/>
<source>Error connecting to PostgreSQL!</source>
<translation>Ошибка соединения с PostgreSQL!</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="341"/>
<location filename="../settings/dialogsettingstray.cpp" line="346"/>
<location filename="../settings/dialogsettingstray.cpp" line="339"/>
<location filename="../settings/dialogsettingstray.cpp" line="344"/>
<source>Possible reasons:</source>
<translation>Возможные причины:</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="342"/>
<location filename="../settings/dialogsettingstray.cpp" line="347"/>
<location filename="../settings/dialogsettingstray.cpp" line="340"/>
<location filename="../settings/dialogsettingstray.cpp" line="345"/>
<source>*superuser PostgreSQL login or password is incorrect;</source>
<translation>*логин или пароль суперпользователя PostgreSQL некорректен;</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="343"/>
<location filename="../settings/dialogsettingstray.cpp" line="341"/>
<source>*Port is incorrect.</source>
<translation>*Порт некорректен.</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="348"/>
<location filename="../settings/dialogsettingstray.cpp" line="346"/>
<source>*Port is incorrect;</source>
<translation>*Порт некорректен;</translation>
</message>
<message>
<location filename="../settings/dialogsettingstray.cpp" line="349"/>
<location filename="../settings/dialogsettingstray.cpp" line="347"/>
<source>*file &apos;pg_hba.conf&apos; does not contain an entry for the IP address:</source>
<translation>*файл &apos;pg_hba.conf не содержит записи доступа для IP адреса:</translation>
</message>
@@ -225,123 +225,129 @@
<translation>Форма</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="188"/>
<location filename="../serverlmswidget.ui" line="204"/>
<source>Logger</source>
<translation>Логгер</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="153"/>
<location filename="../serverlmswidget.ui" line="169"/>
<source>Clients</source>
<translation>Клиенты</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="131"/>
<location filename="../serverlmswidget.ui" line="142"/>
<source>Settings</source>
<translation>Настройки</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="237"/>
<location filename="../serverlmswidget.ui" line="257"/>
<source>Server: </source>
<translation>Сервер: </translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="295"/>
<location filename="../serverlmswidget.ui" line="315"/>
<source>Data base: </source>
<translation>База данных: </translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="256"/>
<location filename="../serverlmswidget.ui" line="302"/>
<location filename="../serverlmswidget.ui" line="276"/>
<location filename="../serverlmswidget.ui" line="328"/>
<location filename="../serverlmswidget.ui" line="365"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="324"/>
<location filename="../serverlmswidget.ui" line="352"/>
<source>Version of materials: </source>
<translation>Версия материалов: </translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="389"/>
<source>Authorization</source>
<translation>Авторизация</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="51"/>
<location filename="../serverlmswidget.ui" line="62"/>
<source>Start</source>
<translation>Запустить</translation>
</message>
<message>
<location filename="../serverlmswidget.ui" line="92"/>
<location filename="../serverlmswidget.ui" line="103"/>
<source>Stop</source>
<translation>Остановить</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="171"/>
<location filename="../serverlmswidget.cpp" line="217"/>
<source>Server is started!</source>
<translation>Сервер запущен!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="184"/>
<location filename="../serverlmswidget.cpp" line="230"/>
<source>Server is stoped!</source>
<translation>Сервер остановлен!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="223"/>
<location filename="../serverlmswidget.cpp" line="272"/>
<location filename="../serverlmswidget.cpp" line="269"/>
<location filename="../serverlmswidget.cpp" line="332"/>
<source>Warning!</source>
<translation>Внимание!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="223"/>
<location filename="../serverlmswidget.cpp" line="269"/>
<source>Database settings have been changed.
The server will be restarted.</source>
<translation>Настройки Базы Данных были изменены.
Сервер будет перезапущен.</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="272"/>
<location filename="../serverlmswidget.cpp" line="332"/>
<source>The file could not be opened </source>
<translation>Файл не может быть открыт </translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="351"/>
<location filename="../serverlmswidget.cpp" line="355"/>
<location filename="../serverlmswidget.cpp" line="406"/>
<location filename="../serverlmswidget.cpp" line="410"/>
<source>Database connection error!</source>
<translation>Ошибка подключения Базы данных!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="194"/>
<location filename="../serverlmswidget.cpp" line="355"/>
<location filename="../serverlmswidget.cpp" line="240"/>
<location filename="../serverlmswidget.cpp" line="410"/>
<source>Error!</source>
<translation>Ошибка!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="115"/>
<location filename="../serverlmswidget.cpp" line="134"/>
<source>Error PostgreSQL!</source>
<translation>Ошибка PostgreSQL!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="194"/>
<location filename="../serverlmswidget.cpp" line="240"/>
<source>Settings file could not be opened:</source>
<translation>Файл настроек не открыт:</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="370"/>
<location filename="../serverlmswidget.cpp" line="427"/>
<source>Database connection OK!</source>
<translation>База данных подключена!</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="384"/>
<location filename="../serverlmswidget.cpp" line="441"/>
<source>started</source>
<translation>запущен</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="389"/>
<location filename="../serverlmswidget.cpp" line="446"/>
<source>stoped</source>
<translation>остановлен</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="409"/>
<location filename="../serverlmswidget.cpp" line="466"/>
<source>connected</source>
<translation>подключена</translation>
</message>
<message>
<location filename="../serverlmswidget.cpp" line="418"/>
<location filename="../serverlmswidget.cpp" line="475"/>
<source>not connected</source>
<translation>не подключена</translation>
</message>

View File

@@ -38,3 +38,4 @@ target_link_libraries(TrayServerLMS PRIVATE libServerLMS.dll)
target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees)
target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/tasks)
target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/widgets)
target_include_directories(TrayServerLMS PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../InstructorsAndTrainees/specialmessagebox)

View File

@@ -6,6 +6,6 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show(); //По-умолчанию свернуто в трее
w.show(); //Закоментировать, если нужно, чтобы по-умолчанию было свернуто в трее!
return a.exec();
}

View File

@@ -1,6 +1,8 @@
#include <QMessageBox>
#include <QTimer>
#include <QThread>
#include <QMenu>
#include "specialmessagebox.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
@@ -16,18 +18,13 @@ MainWindow::MainWindow(QWidget *parent) :
action_Exit(nullptr)
{
ui->setupUi(this);
//Скрываем ненужные элементы окна
ui->menubar->setVisible(false);
ui->statusbar->setVisible(false);
setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint);
serverLMSWidget = new ServerLMSWidget(this);
ui->verticalLayout_Main->addWidget(serverLMSWidget);
connect(serverLMSWidget, &ServerLMSWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged);
connect(serverLMSWidget, &ServerLMSWidget::signal_Tray_ShowMessage, this, &MainWindow::slot_Tray_ShowMessage);
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_ShowWindow, this, &MainWindow::slot_TrayMenu_ShowWindow);
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_HideWindow, this, &MainWindow::slot_TrayMenu_HideWindow);
@@ -206,23 +203,9 @@ void MainWindow::errorCheck()
{
slot_TrayMenu_ShowWindow();
QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Error!"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(tr("No Client files found!"));
msgBox.setInformativeText(tr("* check Application for the presence of a folder with a build \n"
"* check SharedData for a folder with the base version and the name base"));
msgBox.setStandardButtons(QMessageBox::Close);
msgBox.show();
int ret = msgBox.exec();
if (ret == QMessageBox::Close)
{
//выключение с задержкой, так как eventLoop инициализируется позже
QTimer::singleShot(1000,this,&MainWindow::slot_TrayMenu_Exit);
}
}
}
void MainWindow::updateTrayTitles()

View File

@@ -53,6 +53,7 @@ public slots:
//Слот вывода сообщения из трея
void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
//Слот отложенной инициализации
void slot_LazyInitialization();
private:
void exit();

View File

@@ -34,24 +34,6 @@
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="enabled">
<bool>false</bool>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1200</width>
<height>21</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</widget>
<resources>
<include location="TrayServerLMS.qrc"/>