mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
Рефакт
This commit is contained in:
@@ -15,5 +15,6 @@
|
|||||||
<file>resources/icons/rocket.png</file>
|
<file>resources/icons/rocket.png</file>
|
||||||
<file>resources/icons/stop.png</file>
|
<file>resources/icons/stop.png</file>
|
||||||
<file>resources/icons/settings.png</file>
|
<file>resources/icons/settings.png</file>
|
||||||
|
<file>resources/icons/circleGray.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
BIN
ServerLMS/resources/icons/circleGray.png
Normal file
BIN
ServerLMS/resources/icons/circleGray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
@@ -41,10 +41,6 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
|
|||||||
updateMyStyleSheet();
|
updateMyStyleSheet();
|
||||||
|
|
||||||
setLanguageInterfase();
|
setLanguageInterfase();
|
||||||
|
|
||||||
startInitialization();
|
|
||||||
|
|
||||||
tryConnectionToDB();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLMSWidget::~ServerLMSWidget()
|
ServerLMSWidget::~ServerLMSWidget()
|
||||||
@@ -95,10 +91,12 @@ void ServerLMSWidget::changeEvent(QEvent *event)
|
|||||||
dbSettings.dbHostName,
|
dbSettings.dbHostName,
|
||||||
QString::number(dbSettings.dbPort));
|
QString::number(dbSettings.dbPort));
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui->lblDBsettings->setText("");
|
ui->lblDBsettings->setText("");
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,17 +124,25 @@ void ServerLMSWidget::slot_AddMessageToLog(QString message)
|
|||||||
ui->loggerTextField->appendPlainText(message);
|
ui->loggerTextField->appendPlainText(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerLMSWidget::start()
|
||||||
|
{
|
||||||
|
startInitialization();
|
||||||
|
tryConnectionToDB();
|
||||||
|
}
|
||||||
|
|
||||||
void ServerLMSWidget::slot_BlockAutorization(bool block)
|
void ServerLMSWidget::slot_BlockAutorization(bool block)
|
||||||
{
|
{
|
||||||
if(block)
|
if(block)
|
||||||
{
|
{
|
||||||
server->blockAutorization();
|
server->blockAutorization();
|
||||||
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
|
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png")));
|
||||||
|
//emit signal_Tray_ShowMessage(tr("Authorization blocked!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->unBlockAutorization();
|
server->unBlockAutorization();
|
||||||
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
|
ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png")));
|
||||||
|
//emit signal_Tray_ShowMessage(tr("Authorization unblocked!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,6 +203,7 @@ void ServerLMSWidget::on_btnSettings_clicked()
|
|||||||
providerDBLMS->DisConnectionFromDB();
|
providerDBLMS->DisConnectionFromDB();
|
||||||
|
|
||||||
ui->lblDBsettings->setText("");
|
ui->lblDBsettings->setText("");
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
|
|
||||||
QMessageBox::warning(this, tr("Warning!"), tr("Database settings have been changed.\nThe server will be restarted."));
|
QMessageBox::warning(this, tr("Warning!"), tr("Database settings have been changed.\nThe server will be restarted."));
|
||||||
|
|
||||||
@@ -315,9 +322,12 @@ void ServerLMSWidget::tryConnectionToDB()
|
|||||||
if(! providerDBLMS->ConnectionToDB())
|
if(! providerDBLMS->ConnectionToDB())
|
||||||
{
|
{
|
||||||
ui->lblDBsettings->setText("");
|
ui->lblDBsettings->setText("");
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||||
ui->btnStopServer->setEnabled(false);
|
ui->btnStopServer->setEnabled(false);
|
||||||
ui->btnStartServer->setEnabled(false);
|
ui->btnStartServer->setEnabled(false);
|
||||||
QMessageBox::critical(this, tr("Error!"), tr("Database connection error"));
|
//QMessageBox::critical(this, tr("Error!"), tr("Database connection error!"));
|
||||||
|
|
||||||
|
emit signal_Tray_ShowMessage(tr("Database connection error!"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -330,6 +340,9 @@ void ServerLMSWidget::tryConnectionToDB()
|
|||||||
dbSettings.dbHostName,
|
dbSettings.dbHostName,
|
||||||
QString::number(dbSettings.dbPort));
|
QString::number(dbSettings.dbPort));
|
||||||
ui->lblDBsettings->setText(strDBsettings);
|
ui->lblDBsettings->setText(strDBsettings);
|
||||||
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
|
|
||||||
|
emit signal_Tray_ShowMessage(tr("Database connection OK!") + "\n" + strDBsettings);
|
||||||
|
|
||||||
on_btnStartServer_clicked();
|
on_btnStartServer_clicked();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,9 @@ signals:
|
|||||||
//сигнал смены языка
|
//сигнал смены языка
|
||||||
void signal_LanguageChanged(QString language);
|
void signal_LanguageChanged(QString language);
|
||||||
|
|
||||||
|
//сигнал вывода сообщения из трея
|
||||||
|
void signal_Tray_ShowMessage(QString textMsg);
|
||||||
|
|
||||||
void sigRecognize();
|
void sigRecognize();
|
||||||
void sigCalculateFullHash();
|
void sigCalculateFullHash();
|
||||||
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||||
@@ -101,6 +104,8 @@ public:
|
|||||||
|
|
||||||
void removeClient(int socketId);
|
void removeClient(int socketId);
|
||||||
|
|
||||||
|
void start();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_btnStartServer_clicked();
|
void on_btnStartServer_clicked();
|
||||||
void on_btnStopServer_clicked();
|
void on_btnStopServer_clicked();
|
||||||
|
|||||||
@@ -223,6 +223,28 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_DBsettings">
|
<layout class="QHBoxLayout" name="horizontalLayout_DBsettings">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="lblDBisConnected">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>32</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="pixmap">
|
||||||
|
<pixmap resource="../InstructorsAndTrainees/InstructorsAndTrainees.qrc">:/resources/icons/circleGray.png</pixmap>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_DataBase">
|
<widget class="QLabel" name="label_DataBase">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QThread>
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "./ui_mainwindow.h"
|
#include "./ui_mainwindow.h"
|
||||||
|
|
||||||
@@ -15,21 +16,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
serverLMSWidget = new ServerLMSWidget(this);
|
|
||||||
|
|
||||||
ui->verticalLayout_Main->addWidget(serverLMSWidget);
|
|
||||||
|
|
||||||
connect(serverLMSWidget, &ServerLMSWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged);
|
|
||||||
|
|
||||||
qtLanguageTranslator.load(QString("translations/TrayServerLMS_") + serverLMSWidget->getLanguage(), ".");
|
|
||||||
qApp->installTranslator(&qtLanguageTranslator);
|
|
||||||
|
|
||||||
//this->move(0, 0);
|
|
||||||
//this->showNormal();
|
|
||||||
//this->showMaximized();
|
|
||||||
|
|
||||||
errorCheck();
|
|
||||||
|
|
||||||
/* Инициализируем иконку трея, устанавливаем иконку,
|
/* Инициализируем иконку трея, устанавливаем иконку,
|
||||||
* а также задаем всплывающую подсказку
|
* а также задаем всплывающую подсказку
|
||||||
* */
|
* */
|
||||||
@@ -66,6 +52,28 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
||||||
this, SLOT(slot_IconActivated(QSystemTrayIcon::ActivationReason)));
|
this, SLOT(slot_IconActivated(QSystemTrayIcon::ActivationReason)));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
serverLMSWidget->start();
|
||||||
|
|
||||||
|
qtLanguageTranslator.load(QString("translations/TrayServerLMS_") + serverLMSWidget->getLanguage(), ".");
|
||||||
|
qApp->installTranslator(&qtLanguageTranslator);
|
||||||
|
|
||||||
|
//this->move(0, 0);
|
||||||
|
//this->showNormal();
|
||||||
|
//this->showMaximized();
|
||||||
|
|
||||||
|
errorCheck();
|
||||||
|
|
||||||
|
//QThread::sleep(2);
|
||||||
|
|
||||||
slot_Menu_HideWindow();
|
slot_Menu_HideWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,8 +186,7 @@ void MainWindow::slot_Menu_HideWindow()
|
|||||||
trayIcon->showMessage(tr("Server LMS"),
|
trayIcon->showMessage(tr("Server LMS"),
|
||||||
tr("The application is minimized to the tray. "
|
tr("The application is minimized to the tray. "
|
||||||
"To maximize the application window, click the application icon in the tray."),
|
"To maximize the application window, click the application icon in the tray."),
|
||||||
icon,
|
icon, 100);
|
||||||
2000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::slot_Menu_Exit()
|
void MainWindow::slot_Menu_Exit()
|
||||||
@@ -188,6 +195,14 @@ void MainWindow::slot_Menu_Exit()
|
|||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::slot_Tray_ShowMessage(QString textMsg)
|
||||||
|
{
|
||||||
|
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Warning);
|
||||||
|
trayIcon->showMessage(tr("Server LMS"),
|
||||||
|
textMsg,
|
||||||
|
icon, 100);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::slot_LanguageChanged(QString language)
|
void MainWindow::slot_LanguageChanged(QString language)
|
||||||
{
|
{
|
||||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/TrayServerLMS_")) + language, QStringLiteral("."));
|
qtLanguageTranslator.load(QString(QStringLiteral("translations/TrayServerLMS_")) + language, QStringLiteral("."));
|
||||||
|
|||||||
@@ -48,6 +48,10 @@ public slots:
|
|||||||
void slot_Menu_HideWindow();
|
void slot_Menu_HideWindow();
|
||||||
void slot_Menu_Exit();
|
void slot_Menu_Exit();
|
||||||
|
|
||||||
|
//Слот вывода сообщения из трея
|
||||||
|
void slot_Tray_ShowMessage(QString textMsg);
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//сигнал об изменении языка интерфейса
|
//сигнал об изменении языка интерфейса
|
||||||
void signal_LanguageChanged(QString language);
|
void signal_LanguageChanged(QString language);
|
||||||
|
|||||||
Reference in New Issue
Block a user