mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
refact
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
<string>Assign</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/assignTask.png</normaloff>:/resources/icons/assignTask.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
@@ -80,7 +80,7 @@
|
||||
<string>Check</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/check.png</normaloff>:/resources/icons/check.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
@@ -106,7 +106,7 @@
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/delete.png</normaloff>:/resources/icons/delete.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
@@ -129,7 +129,7 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
<include location="../InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamAttribute>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#include <QErrorMessage>
|
||||
#include "serverlmswidget.h"
|
||||
@@ -141,7 +140,7 @@ void ServerLMSWidget::slot_AddMessageToLog(QString message)
|
||||
void ServerLMSWidget::slot_ErrorPostgreSQL(QString text)
|
||||
{
|
||||
emit signal_Menu_ShowWindow();
|
||||
SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!"));
|
||||
SpecMsgBox::CriticalClose(this, tr("Error PostgreSQL!") + "\n" + text);
|
||||
}
|
||||
|
||||
void ServerLMSWidget::slot_UpdateDocs()
|
||||
@@ -183,13 +182,13 @@ void ServerLMSWidget::slot_startInitialization_step1()
|
||||
void ServerLMSWidget::slot_setVersion(QString versionStr)
|
||||
{
|
||||
this->versionStr = versionStr;
|
||||
Logger::instance().log("Set Version: " + versionStr);
|
||||
updateStateOnlyVersion();
|
||||
}
|
||||
|
||||
void ServerLMSWidget::start()
|
||||
{
|
||||
startInitialization_step0();
|
||||
|
||||
}
|
||||
|
||||
void ServerLMSWidget::slot_BlockAutorization(bool block)
|
||||
@@ -197,41 +196,14 @@ void ServerLMSWidget::slot_BlockAutorization(bool block)
|
||||
if(block)
|
||||
{
|
||||
server->blockAutorization();
|
||||
//ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
|
||||
//emit signal_Tray_ShowMessage(tr("Authorization blocked!"));
|
||||
Logger::instance().log("Autorization is blocked");
|
||||
}
|
||||
else
|
||||
{
|
||||
server->unBlockAutorization();
|
||||
//ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
|
||||
//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());
|
||||
Logger::instance().log("Autorization is unblocked");
|
||||
}
|
||||
updateStateOnlyServer();
|
||||
}
|
||||
|
||||
void ServerLMSWidget::slot_LanguageChanged(QString language)
|
||||
@@ -247,7 +219,6 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
||||
if(server->startServer())
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
QApplication::restoreOverrideCursor();
|
||||
|
||||
ui->btnStartServer->setEnabled(false);
|
||||
ui->btnStopServer->setEnabled(true);
|
||||
@@ -256,6 +227,8 @@ void ServerLMSWidget::on_btnStartServer_clicked()
|
||||
updateStateOnlyServer();
|
||||
|
||||
emit signal_Tray_ShowMessage(tr("Server is started!"));
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +236,8 @@ void ServerLMSWidget::on_btnStopServer_clicked()
|
||||
{
|
||||
if(server->stopServer())
|
||||
{
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
ui->btnStopServer->setEnabled(false);
|
||||
ui->btnStartServer->setEnabled(true);
|
||||
slot_BlockAutorization(true);
|
||||
@@ -270,6 +245,8 @@ void ServerLMSWidget::on_btnStopServer_clicked()
|
||||
updateStateOnlyServer();
|
||||
|
||||
emit signal_Tray_ShowMessage(tr("Server is stoped!"));
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -409,41 +386,43 @@ void ServerLMSWidget::startInitialization_step0()
|
||||
|
||||
processingSystem = new ProcessingSystem(providerDBLMS, updateController, docsUpdater);
|
||||
|
||||
dataParser = new DataParser(assetsManager,processingSystem);
|
||||
dataParser = new DataParser(assetsManager, processingSystem);
|
||||
|
||||
commonClientHandler = new CommonClientHandler;
|
||||
connect(this,&ServerLMSWidget::signal_DocsChanged,commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
||||
connect(commonClientHandler,&CommonClientHandler::sigSetServerState,this,&ServerLMSWidget::slot_trySetServerState);
|
||||
connect(this, &ServerLMSWidget::signal_DocsChanged, commonClientHandler, &CommonClientHandler::slot_DocsChanged);
|
||||
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();
|
||||
updateThread->start();
|
||||
|
||||
commonClientHandler->initialize(server->getClientsMap(),processingSystem,dataParser);
|
||||
processingSystem->initialize(server,dataParser,commonClientHandler,updateController,chatSystem);
|
||||
chatSystem->initialize(commonClientHandler,dataParser,server->getClientsMap());
|
||||
commonClientHandler->initialize(server->getClientsMap(), processingSystem, dataParser);
|
||||
processingSystem->initialize(server, dataParser, commonClientHandler, updateController, chatSystem);
|
||||
chatSystem->initialize(commonClientHandler, dataParser, server->getClientsMap());
|
||||
|
||||
Logger::instance().moveToThread(loggerThread);
|
||||
Logger::instance().setLoggingType(LoggingType::WIDGET);
|
||||
Logger::instance().setLogToFile(true);
|
||||
|
||||
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);
|
||||
connect(updateController,&UpdateController::sigUpdateDocs,this,&ServerLMSWidget::slot_UpdateDocs,Qt::AutoConnection);
|
||||
connect(&Logger::instance(),&Logger::sigLogToWidget,this, &ServerLMSWidget::slot_AddMessageToLog,Qt::QueuedConnection);
|
||||
connect(this, &ServerLMSWidget::sigUpdateControllerInitialize, updateController, &UpdateController::initialize);
|
||||
connect(updateController, &UpdateController::sigInitializeFinished, this, &ServerLMSWidget::slot_startInitialization_step1);
|
||||
connect(this, &ServerLMSWidget::sigCalculateFullHash, updateController, &UpdateController::calculateFullHash, Qt::AutoConnection);
|
||||
connect(updateController, &UpdateController::sigErrorRequired, this, &ServerLMSWidget::setError);
|
||||
connect(updateController, &UpdateController::sigUpdateDocs, this, &ServerLMSWidget::slot_UpdateDocs, Qt::AutoConnection);
|
||||
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()
|
||||
{
|
||||
if(! providerDBLMS->ConnectionToDB())
|
||||
{
|
||||
Logger::instance().log("Database connection error!");
|
||||
|
||||
emit signal_Tray_ShowMessage(tr("Database connection error!"), QSystemTrayIcon::Critical);
|
||||
|
||||
emit signal_Menu_ShowWindow();
|
||||
|
||||
@@ -82,7 +82,6 @@ signals:
|
||||
void sigRecognize();
|
||||
void sigCalculateFullHash();
|
||||
void sigUpdateControllerInitialize(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||
QTcpSocket* sigGetSocket();
|
||||
|
||||
void signal_DocsChanged();
|
||||
void signal_hasError(int code);
|
||||
@@ -103,6 +102,8 @@ public slots:
|
||||
|
||||
void slot_setVersion(QString versionStr);
|
||||
|
||||
void slot_trySetServerState(PacketType packetType);
|
||||
|
||||
public:
|
||||
QString getLanguage()
|
||||
{
|
||||
@@ -144,7 +145,6 @@ private slots:
|
||||
void on_btnStartServer_clicked();
|
||||
void on_btnStopServer_clicked();
|
||||
void on_btnSettings_clicked();
|
||||
void slot_trySetServerState(PacketType packetType);
|
||||
|
||||
private:
|
||||
void setLanguageInterfase();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>resources/IcoGUIRRJ.ico</file>
|
||||
<file>resources/PngGUIRRJ.png</file>
|
||||
<file>resources/IcoGUIRRJ.ico</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
#include <QMenu>
|
||||
@@ -68,7 +67,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
|
||||
slot_Tray_ShowMessage(tr("Starting the server..."));
|
||||
|
||||
QTimer::singleShot(1000,this,&MainWindow::slot_LazyInitialization);
|
||||
QTimer::singleShot(1000, this, &MainWindow::slot_LazyInitialization);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@@ -153,11 +152,6 @@ void MainWindow::slot_TrayMenu_HideWindow()
|
||||
this->hide();
|
||||
action_ShowWindow->setEnabled(true);
|
||||
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()
|
||||
@@ -169,9 +163,7 @@ void MainWindow::slot_TrayMenu_Exit()
|
||||
void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg)
|
||||
{
|
||||
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(iconMsg);
|
||||
trayIcon->showMessage(tr("Server MPS"),
|
||||
textMsg,
|
||||
icon, 100);
|
||||
trayIcon->showMessage(tr("Server MPS"), textMsg, icon, 100);
|
||||
}
|
||||
|
||||
void MainWindow::slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization)
|
||||
@@ -230,7 +222,7 @@ void MainWindow::errorCheck()
|
||||
slot_TrayMenu_ShowWindow();
|
||||
|
||||
//выключение с задержкой, так как eventLoop инициализируется позже
|
||||
QTimer::singleShot(1000,this,&MainWindow::slot_TrayMenu_Exit);
|
||||
QTimer::singleShot(1000, this, &MainWindow::slot_TrayMenu_Exit);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,13 +52,14 @@ public slots:
|
||||
|
||||
//Слот вывода сообщения из трея
|
||||
void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information);
|
||||
//Слот изменения иконки трея
|
||||
//Слот изменения иконки трея о статусе Сервера
|
||||
void slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization);
|
||||
|
||||
//Слот отложенной инициализации
|
||||
void slot_LazyInitialization();
|
||||
|
||||
void slot_hasError(int code);
|
||||
|
||||
private:
|
||||
void exit();
|
||||
void errorCheck();
|
||||
|
||||
Reference in New Issue
Block a user