Разные иконки в трее

This commit is contained in:
2025-12-17 13:08:38 +03:00
parent d1df6a2a05
commit b7c246b3f6
8 changed files with 37 additions and 3 deletions

View File

@@ -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)

View File

@@ -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();

View File

@@ -2,5 +2,8 @@
<qresource prefix="/">
<file>resources/PngServerRRJ.png</file>
<file>resources/IcoServerRRJ.ico</file>
<file>resources/PngServerRRJ_lock.png</file>
<file>resources/PngServerRRJ_start.png</file>
<file>resources/PngServerRRJ_stop.png</file>
</qresource>
</RCC>

View File

@@ -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();

View File

@@ -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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB