mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Рефакт
This commit is contained in:
@@ -15,5 +15,6 @@
|
||||
<file>resources/icons/rocket.png</file>
|
||||
<file>resources/icons/stop.png</file>
|
||||
<file>resources/icons/settings.png</file>
|
||||
<file>resources/icons/circleGray.png</file>
|
||||
</qresource>
|
||||
</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();
|
||||
|
||||
setLanguageInterfase();
|
||||
|
||||
startInitialization();
|
||||
|
||||
tryConnectionToDB();
|
||||
}
|
||||
|
||||
ServerLMSWidget::~ServerLMSWidget()
|
||||
@@ -95,10 +91,12 @@ void ServerLMSWidget::changeEvent(QEvent *event)
|
||||
dbSettings.dbHostName,
|
||||
QString::number(dbSettings.dbPort));
|
||||
ui->lblDBsettings->setText(strDBsettings);
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
void ServerLMSWidget::start()
|
||||
{
|
||||
startInitialization();
|
||||
tryConnectionToDB();
|
||||
}
|
||||
|
||||
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!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
server->unBlockAutorization();
|
||||
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();
|
||||
|
||||
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."));
|
||||
|
||||
@@ -315,9 +322,12 @@ void ServerLMSWidget::tryConnectionToDB()
|
||||
if(! providerDBLMS->ConnectionToDB())
|
||||
{
|
||||
ui->lblDBsettings->setText("");
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
ui->btnStopServer->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
|
||||
{
|
||||
@@ -330,6 +340,9 @@ void ServerLMSWidget::tryConnectionToDB()
|
||||
dbSettings.dbHostName,
|
||||
QString::number(dbSettings.dbPort));
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -62,6 +62,9 @@ signals:
|
||||
//сигнал смены языка
|
||||
void signal_LanguageChanged(QString language);
|
||||
|
||||
//сигнал вывода сообщения из трея
|
||||
void signal_Tray_ShowMessage(QString textMsg);
|
||||
|
||||
void sigRecognize();
|
||||
void sigCalculateFullHash();
|
||||
void sigUpdateController(CommonClientHandler* commonClientHandler,DataParser *dataParser,AssetsManager *assetManager);
|
||||
@@ -101,6 +104,8 @@ public:
|
||||
|
||||
void removeClient(int socketId);
|
||||
|
||||
void start();
|
||||
|
||||
private slots:
|
||||
void on_btnStartServer_clicked();
|
||||
void on_btnStopServer_clicked();
|
||||
|
||||
@@ -223,6 +223,28 @@
|
||||
</item>
|
||||
<item>
|
||||
<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>
|
||||
<widget class="QLabel" name="label_DataBase">
|
||||
<property name="sizePolicy">
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
#include "mainwindow.h"
|
||||
#include "./ui_mainwindow.h"
|
||||
|
||||
@@ -15,21 +16,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
{
|
||||
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)),
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -178,8 +186,7 @@ void MainWindow::slot_Menu_HideWindow()
|
||||
trayIcon->showMessage(tr("Server LMS"),
|
||||
tr("The application is minimized to the tray. "
|
||||
"To maximize the application window, click the application icon in the tray."),
|
||||
icon,
|
||||
2000);
|
||||
icon, 100);
|
||||
}
|
||||
|
||||
void MainWindow::slot_Menu_Exit()
|
||||
@@ -188,6 +195,14 @@ void MainWindow::slot_Menu_Exit()
|
||||
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)
|
||||
{
|
||||
qtLanguageTranslator.load(QString(QStringLiteral("translations/TrayServerLMS_")) + language, QStringLiteral("."));
|
||||
|
||||
@@ -48,6 +48,10 @@ public slots:
|
||||
void slot_Menu_HideWindow();
|
||||
void slot_Menu_Exit();
|
||||
|
||||
//Слот вывода сообщения из трея
|
||||
void slot_Tray_ShowMessage(QString textMsg);
|
||||
|
||||
|
||||
signals:
|
||||
//сигнал об изменении языка интерфейса
|
||||
void signal_LanguageChanged(QString language);
|
||||
|
||||
Reference in New Issue
Block a user