Рефакт

This commit is contained in:
2025-10-27 18:46:50 +03:00
parent ce65daea2e
commit 39c11897f8
7 changed files with 83 additions and 23 deletions

View File

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