This commit is contained in:
2025-12-17 17:17:34 +03:00
parent 3953527795
commit 360b740220
6 changed files with 41 additions and 69 deletions

View File

@@ -54,7 +54,7 @@
<string>Assign</string> <string>Assign</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/assignTask.png</normaloff>:/resources/icons/assignTask.png</iconset> <normaloff>:/resources/icons/assignTask.png</normaloff>:/resources/icons/assignTask.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -80,7 +80,7 @@
<string>Check</string> <string>Check</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/check.png</normaloff>:/resources/icons/check.png</iconset> <normaloff>:/resources/icons/check.png</normaloff>:/resources/icons/check.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -106,7 +106,7 @@
<string>Delete</string> <string>Delete</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources.qrc"> <iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/delete.png</normaloff>:/resources/icons/delete.png</iconset> <normaloff>:/resources/icons/delete.png</normaloff>:/resources/icons/delete.png</iconset>
</property> </property>
<property name="iconSize"> <property name="iconSize">
@@ -129,7 +129,7 @@
</layout> </layout>
</widget> </widget>
<resources> <resources>
<include location="../resources.qrc"/> <include location="../InstructorsAndTrainees.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>

View File

@@ -2,7 +2,6 @@
#include <QXmlStreamReader> #include <QXmlStreamReader>
#include <QXmlStreamAttribute> #include <QXmlStreamAttribute>
#include <QFile> #include <QFile>
#include <QMessageBox>
#include <QThread> #include <QThread>
#include <QErrorMessage> #include <QErrorMessage>
#include "serverlmswidget.h" #include "serverlmswidget.h"
@@ -141,7 +140,7 @@ void ServerLMSWidget::slot_AddMessageToLog(QString message)
void ServerLMSWidget::slot_ErrorPostgreSQL(QString text) void ServerLMSWidget::slot_ErrorPostgreSQL(QString text)
{ {
emit signal_Menu_ShowWindow(); emit signal_Menu_ShowWindow();
SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!")); SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!") + "\n" + text);
} }
void ServerLMSWidget::slot_UpdateDocs() void ServerLMSWidget::slot_UpdateDocs()
@@ -183,13 +182,13 @@ void ServerLMSWidget::slot_startInitialization_step1()
void ServerLMSWidget::slot_setVersion(QString versionStr) void ServerLMSWidget::slot_setVersion(QString versionStr)
{ {
this->versionStr = versionStr; this->versionStr = versionStr;
Logger::instance().log("Set Version: " + versionStr);
updateStateOnlyVersion(); updateStateOnlyVersion();
} }
void ServerLMSWidget::start() void ServerLMSWidget::start()
{ {
startInitialization_step0(); startInitialization_step0();
} }
void ServerLMSWidget::slot_BlockAutorization(bool block) void ServerLMSWidget::slot_BlockAutorization(bool block)
@@ -197,41 +196,14 @@ void ServerLMSWidget::slot_BlockAutorization(bool block)
if(block) if(block)
{ {
server->blockAutorization(); server->blockAutorization();
//ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png"))); Logger::instance().log("Autorization is blocked");
//emit signal_Tray_ShowMessage(tr("Authorization blocked!"));
} }
else else
{ {
server->unBlockAutorization(); server->unBlockAutorization();
//ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png"))); Logger::instance().log("Autorization is unblocked");
//emit signal_Tray_ShowMessage(tr("Authorization unblocked!"));
}
//updateStateServer();
//emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
if(server)
{
if(server->getStateServer() == EStateServer::started)
{
if(server->getStateBlockAutorization() == EStateBlockAutorization::unblocked)
{
ui->lblOnOffText->setText(tr("started"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
}
else
{
ui->lblOnOffText->setText(tr("started") + ", " + tr("locked"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
}
}
else
{
ui->lblOnOffText->setText(tr("stoped"));
ui->lblOnOff->setPixmap(QPixmap(QStringLiteral(":/resources/icons/stop.png")));
}
emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization());
} }
updateStateOnlyServer();
} }
void ServerLMSWidget::slot_LanguageChanged(QString language) void ServerLMSWidget::slot_LanguageChanged(QString language)
@@ -247,7 +219,6 @@ void ServerLMSWidget::on_btnStartServer_clicked()
if(server->startServer()) if(server->startServer())
{ {
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::restoreOverrideCursor();
ui->btnStartServer->setEnabled(false); ui->btnStartServer->setEnabled(false);
ui->btnStopServer->setEnabled(true); ui->btnStopServer->setEnabled(true);
@@ -256,6 +227,8 @@ void ServerLMSWidget::on_btnStartServer_clicked()
updateStateOnlyServer(); updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is started!")); emit signal_Tray_ShowMessage(tr("Server is started!"));
QApplication::restoreOverrideCursor();
} }
} }
@@ -263,6 +236,8 @@ void ServerLMSWidget::on_btnStopServer_clicked()
{ {
if(server->stopServer()) if(server->stopServer())
{ {
QApplication::setOverrideCursor(Qt::WaitCursor);
ui->btnStopServer->setEnabled(false); ui->btnStopServer->setEnabled(false);
ui->btnStartServer->setEnabled(true); ui->btnStartServer->setEnabled(true);
slot_BlockAutorization(true); slot_BlockAutorization(true);
@@ -270,6 +245,8 @@ void ServerLMSWidget::on_btnStopServer_clicked()
updateStateOnlyServer(); updateStateOnlyServer();
emit signal_Tray_ShowMessage(tr("Server is stoped!")); emit signal_Tray_ShowMessage(tr("Server is stoped!"));
QApplication::restoreOverrideCursor();
} }
} }
@@ -409,41 +386,43 @@ void ServerLMSWidget::startInitialization_step0()
processingSystem = new ProcessingSystem(providerDBLMS, updateController, docsUpdater); processingSystem = new ProcessingSystem(providerDBLMS, updateController, docsUpdater);
dataParser = new DataParser(assetsManager,processingSystem); dataParser = new DataParser(assetsManager, processingSystem);
commonClientHandler = new CommonClientHandler; commonClientHandler = new CommonClientHandler;
connect(this,&ServerLMSWidget::signal_DocsChanged,commonClientHandler, &CommonClientHandler::slot_DocsChanged); connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
connect(commonClientHandler,&CommonClientHandler::sigSetServerState,this,&ServerLMSWidget::slot_trySetServerState); connect(commonClientHandler, &CommonClientHandler::sigSetServerState, this, &ServerLMSWidget::slot_trySetServerState);
server = new MultiThreadServer(this,updateController,processingSystem,dataParser,6000); server = new MultiThreadServer(this, updateController, processingSystem, dataParser, 6000);
loggerThread->start(); loggerThread->start();
updateThread->start(); updateThread->start();
commonClientHandler->initialize(server->getClientsMap(),processingSystem,dataParser); commonClientHandler->initialize(server->getClientsMap(), processingSystem, dataParser);
processingSystem->initialize(server,dataParser,commonClientHandler,updateController,chatSystem); processingSystem->initialize(server, dataParser, commonClientHandler, updateController, chatSystem);
chatSystem->initialize(commonClientHandler,dataParser,server->getClientsMap()); chatSystem->initialize(commonClientHandler, dataParser, server->getClientsMap());
Logger::instance().moveToThread(loggerThread); Logger::instance().moveToThread(loggerThread);
Logger::instance().setLoggingType(LoggingType::WIDGET); Logger::instance().setLoggingType(LoggingType::WIDGET);
Logger::instance().setLogToFile(true); Logger::instance().setLogToFile(true);
connect(this,&ServerLMSWidget::sigUpdateControllerInitialize,updateController,&UpdateController::initialize/*,Qt::DirectConnection*/); connect(this, &ServerLMSWidget::sigUpdateControllerInitialize, updateController, &UpdateController::initialize);
connect(updateController,&UpdateController::sigInitializeFinished, this,&ServerLMSWidget::slot_startInitialization_step1/*,Qt::DirectConnection*/); connect(updateController, &UpdateController::sigInitializeFinished, this, &ServerLMSWidget::slot_startInitialization_step1);
connect(this,&ServerLMSWidget::sigCalculateFullHash,updateController,&UpdateController::calculateFullHash,Qt::AutoConnection); connect(this, &ServerLMSWidget::sigCalculateFullHash, updateController, &UpdateController::calculateFullHash, Qt::AutoConnection);
connect(updateController,&UpdateController::sigErrorRequired,this,&ServerLMSWidget::setError); connect(updateController, &UpdateController::sigErrorRequired, this, &ServerLMSWidget::setError);
connect(updateController,&UpdateController::sigUpdateDocs,this,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection); connect(updateController, &UpdateController::sigUpdateDocs, this, &ServerLMSWidget::slot_UpdateDocs, Qt::AutoConnection);
connect(&Logger::instance(),&Logger::sigLogToWidget,this, &ServerLMSWidget::slot_AddMessageToLog,Qt::QueuedConnection); connect(&Logger::instance(), &Logger::sigLogToWidget, this, &ServerLMSWidget::slot_AddMessageToLog, Qt::QueuedConnection);
connect(assetsManager,&AssetsManager::signal_setVersion, this, &ServerLMSWidget::slot_setVersion); connect(assetsManager, &AssetsManager::signal_setVersion, this, &ServerLMSWidget::slot_setVersion);
emit sigUpdateControllerInitialize(commonClientHandler,dataParser,assetsManager); emit sigUpdateControllerInitialize(commonClientHandler, dataParser, assetsManager);
} }
void ServerLMSWidget::tryConnectionToDB() void ServerLMSWidget::tryConnectionToDB()
{ {
if(! providerDBLMS->ConnectionToDB()) if(! providerDBLMS->ConnectionToDB())
{ {
Logger::instance().log("Database connection error!");
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical); emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
emit signal_Menu_ShowWindow(); emit signal_Menu_ShowWindow();

View File

@@ -82,7 +82,6 @@ signals:
void sigRecognize(); void sigRecognize();
void sigCalculateFullHash(); void sigCalculateFullHash();
void sigUpdateControllerInitialize(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager); void sigUpdateControllerInitialize(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
QTcpSocket* sigGetSocket();
void signal_DocsChanged(); void signal_DocsChanged();
void signal_hasError(int code); void signal_hasError(int code);
@@ -103,6 +102,8 @@ public slots:
void slot_setVersion(QString versionStr); void slot_setVersion(QString versionStr);
void slot_trySetServerState(PacketType packetType);
public: public:
QString getLanguage() QString getLanguage()
{ {
@@ -143,8 +144,7 @@ public:
private slots: private slots:
void on_btnStartServer_clicked(); void on_btnStartServer_clicked();
void on_btnStopServer_clicked(); void on_btnStopServer_clicked();
void on_btnSettings_clicked(); void on_btnSettings_clicked();
void slot_trySetServerState(PacketType packetType);
private: private:
void setLanguageInterfase(); void setLanguageInterfase();

View File

@@ -1,6 +1,6 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>resources/IcoGUIRRJ.ico</file>
<file>resources/PngGUIRRJ.png</file> <file>resources/PngGUIRRJ.png</file>
<file>resources/IcoGUIRRJ.ico</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -1,4 +1,3 @@
#include <QMessageBox>
#include <QTimer> #include <QTimer>
#include <QThread> #include <QThread>
#include <QMenu> #include <QMenu>
@@ -68,7 +67,7 @@ MainWindow::MainWindow(QWidget *parent) :
slot_Tray_ShowMessage(tr("Starting the server...")); slot_Tray_ShowMessage(tr("Starting the server..."));
QTimer::singleShot(1000,this,&MainWindow::slot_LazyInitialization); QTimer::singleShot(1000, this, &MainWindow::slot_LazyInitialization);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@@ -153,11 +152,6 @@ void MainWindow::slot_TrayMenu_HideWindow()
this->hide(); this->hide();
action_ShowWindow->setEnabled(true); action_ShowWindow->setEnabled(true);
action_HideWindow->setEnabled(false); action_HideWindow->setEnabled(false);
/*
slot_Tray_ShowMessage(tr("The application is minimized to the tray.\n"
"To maximize the application window, click the application icon in the tray."));
*/
} }
void MainWindow::slot_TrayMenu_Exit() void MainWindow::slot_TrayMenu_Exit()
@@ -169,9 +163,7 @@ void MainWindow::slot_TrayMenu_Exit()
void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg) void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg)
{ {
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(iconMsg); QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(iconMsg);
trayIcon->showMessage(tr("Server MPS"), trayIcon->showMessage(tr("Server MPS"), textMsg, icon, 100);
textMsg,
icon, 100);
} }
void MainWindow::slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization) void MainWindow::slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization)
@@ -230,7 +222,7 @@ void MainWindow::errorCheck()
slot_TrayMenu_ShowWindow(); slot_TrayMenu_ShowWindow();
//выключение с задержкой, так как eventLoop инициализируется позже //выключение с задержкой, так как eventLoop инициализируется позже
QTimer::singleShot(1000,this,&MainWindow::slot_TrayMenu_Exit); QTimer::singleShot(1000, this, &MainWindow::slot_TrayMenu_Exit);
} }
} }

View File

@@ -52,13 +52,14 @@ public slots:
//Слот вывода сообщения из трея //Слот вывода сообщения из трея
void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information); void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
//Слот изменения иконки трея //Слот изменения иконки трея о статусе Сервера
void slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization); void slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization);
//Слот отложенной инициализации //Слот отложенной инициализации
void slot_LazyInitialization(); void slot_LazyInitialization();
void slot_hasError(int code); void slot_hasError(int code);
private: private:
void exit(); void exit();
void errorCheck(); void errorCheck();