diff --git a/LibServer/serverlmswidget.cpp b/LibServer/serverlmswidget.cpp index ffcedd3..6d1a9a5 100644 --- a/LibServer/serverlmswidget.cpp +++ b/LibServer/serverlmswidget.cpp @@ -200,6 +200,8 @@ void ServerLMSWidget::slot_BlockAutorization(bool block) ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/open.png"))); //emit signal_Tray_ShowMessage(tr("Authorization unblocked!")); } + //updateStateServer(); + emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization()); } void ServerLMSWidget::slot_LanguageChanged(QString language) @@ -221,9 +223,10 @@ void ServerLMSWidget::on_btnStartServer_clicked() ui->btnStopServer->setEnabled(true); slot_BlockAutorization(false); + updateStateServer(); + emit signal_Tray_ShowMessage(tr("Server is started!")); } - updateStateServer(); } void ServerLMSWidget::on_btnStopServer_clicked() @@ -234,9 +237,10 @@ void ServerLMSWidget::on_btnStopServer_clicked() ui->btnStartServer->setEnabled(true); slot_BlockAutorization(true); + updateStateServer(); + emit signal_Tray_ShowMessage(tr("Server is stoped!")); } - updateStateServer(); } void ServerLMSWidget::on_btnSettings_clicked() @@ -462,6 +466,8 @@ void ServerLMSWidget::updateStateServer() { ui->lblBlockAuth->setPixmap(QPixmap(QStringLiteral(":/resources/icons/lock.png"))); } + + emit signal_updateStateServer(server->getStateServer(), server->getStateBlockAutorization()); } if(providerDBLMS) diff --git a/LibServer/serverlmswidget.h b/LibServer/serverlmswidget.h index f6a5573..54ee0bb 100644 --- a/LibServer/serverlmswidget.h +++ b/LibServer/serverlmswidget.h @@ -87,6 +87,8 @@ signals: void signal_DocsChanged(); void signal_hasError(int code); + void signal_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization); + public slots: void slot_LanguageChanged(QString language); void slot_UpdateListClients(); diff --git a/ProgramServerMPS/ProgramServerMPS.qrc b/ProgramServerMPS/ProgramServerMPS.qrc index a5f38ce..67e27b2 100644 --- a/ProgramServerMPS/ProgramServerMPS.qrc +++ b/ProgramServerMPS/ProgramServerMPS.qrc @@ -2,5 +2,8 @@ resources/PngServerRRJ.png resources/IcoServerRRJ.ico + resources/PngServerRRJ_lock.png + resources/PngServerRRJ_start.png + resources/PngServerRRJ_stop.png diff --git a/ProgramServerMPS/mainwindow.cpp b/ProgramServerMPS/mainwindow.cpp index 2a661f0..0b34228 100644 --- a/ProgramServerMPS/mainwindow.cpp +++ b/ProgramServerMPS/mainwindow.cpp @@ -30,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) : connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_ShowWindow, this, &MainWindow::slot_TrayMenu_ShowWindow); connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_HideWindow, this, &MainWindow::slot_TrayMenu_HideWindow); + connect(serverLMSWidget, &ServerLMSWidget::signal_updateStateServer, this, &MainWindow::slot_updateStateServer); + qtLanguageTranslator.load(QString("translations/RRJServer_") + serverLMSWidget->getLanguage(), "."); qApp->installTranslator(&qtLanguageTranslator); @@ -38,7 +40,7 @@ MainWindow::MainWindow(QWidget *parent) : * */ trayIcon = new QSystemTrayIcon(this); //trayIcon->setIcon(this->style()->standardIcon(QStyle::SP_ComputerIcon)); - trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ.png")); + trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ_stop.png")); /* После чего создаем контекстное меню для иконки трея*/ trayMenu = new QMenu(this); @@ -172,6 +174,25 @@ void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::Message icon, 100); } +void MainWindow::slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization) +{ + if(stateServer == EStateServer::started) + { + if(stateBlockAutorization == EStateBlockAutorization::unblocked) + { + trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ_start.png")); + } + else + { + trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ_lock.png")); + } + } + else + { + trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ_stop.png")); + } +} + void MainWindow::slot_LazyInitialization() { serverLMSWidget->start(); diff --git a/ProgramServerMPS/mainwindow.h b/ProgramServerMPS/mainwindow.h index 775f8a3..de3cecc 100644 --- a/ProgramServerMPS/mainwindow.h +++ b/ProgramServerMPS/mainwindow.h @@ -52,6 +52,8 @@ public slots: //Слот вывода сообщения из трея void slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg = QSystemTrayIcon::Information); + //Слот изменения иконки трея + void slot_updateStateServer(EStateServer stateServer, EStateBlockAutorization stateBlockAutorization); //Слот отложенной инициализации void slot_LazyInitialization(); diff --git a/ProgramServerMPS/resources/PngServerRRJ_lock.png b/ProgramServerMPS/resources/PngServerRRJ_lock.png new file mode 100644 index 0000000..65dae95 Binary files /dev/null and b/ProgramServerMPS/resources/PngServerRRJ_lock.png differ diff --git a/ProgramServerMPS/resources/PngServerRRJ_start.png b/ProgramServerMPS/resources/PngServerRRJ_start.png new file mode 100644 index 0000000..1aa735e Binary files /dev/null and b/ProgramServerMPS/resources/PngServerRRJ_start.png differ diff --git a/ProgramServerMPS/resources/PngServerRRJ_stop.png b/ProgramServerMPS/resources/PngServerRRJ_stop.png new file mode 100644 index 0000000..5521a3e Binary files /dev/null and b/ProgramServerMPS/resources/PngServerRRJ_stop.png differ