Рефакт интерфейса

This commit is contained in:
2025-10-28 16:43:18 +03:00
parent 39c11897f8
commit c11871e8f4
5 changed files with 58 additions and 26 deletions

View File

@@ -50,8 +50,9 @@ MainWindow::MainWindow(QWidget *parent) :
* данного нажатия
* */
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(slot_IconActivated(QSystemTrayIcon::ActivationReason)));
this, SLOT(slot_Activated(QSystemTrayIcon::ActivationReason)));
slot_Tray_ShowMessage(tr("Starting the server..."));
serverLMSWidget = new ServerLMSWidget(this);
@@ -66,14 +67,8 @@ MainWindow::MainWindow(QWidget *parent) :
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();
}
@@ -94,7 +89,7 @@ void MainWindow::closeEvent(QCloseEvent * event)
/* Метод, который обрабатывает нажатие на иконку приложения в трее
* */
void MainWindow::slot_IconActivated(QSystemTrayIcon::ActivationReason reason)
void MainWindow::slot_Activated(QSystemTrayIcon::ActivationReason reason)
{
switch (reason){
case QSystemTrayIcon::Trigger:
@@ -115,6 +110,14 @@ void MainWindow::slot_IconActivated(QSystemTrayIcon::ActivationReason reason)
}
}
void MainWindow::slot_MessageClicked()
{
if(!this->isVisible())
{
slot_Menu_ShowWindow();
}
}
void MainWindow::exit()
{
@@ -150,6 +153,8 @@ void MainWindow::errorCheck()
{
if(serverLMSWidget->hasError() == 100)
{
slot_Menu_ShowWindow();
QMessageBox msgBox;
msgBox.setWindowTitle(tr("Error!"));
@@ -164,7 +169,7 @@ void MainWindow::errorCheck()
if (ret == QMessageBox::Close)
{
//выключение с задержкой, так как eventLoop инициализируется позже
QTimer::singleShot(1000,this,&MainWindow::exit);
QTimer::singleShot(1000,this,&MainWindow::slot_Menu_Exit);
}
}
}
@@ -182,11 +187,8 @@ void MainWindow::slot_Menu_HideWindow()
action_ShowWindow->setEnabled(true);
action_HideWindow->setEnabled(false);
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Information);
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, 100);
slot_Tray_ShowMessage(tr("The application is minimized to the tray.\n"
"To maximize the application window, click the application icon in the tray."));
}
void MainWindow::slot_Menu_Exit()
@@ -195,9 +197,9 @@ void MainWindow::slot_Menu_Exit()
this->close();
}
void MainWindow::slot_Tray_ShowMessage(QString textMsg)
void MainWindow::slot_Tray_ShowMessage(QString textMsg, QSystemTrayIcon::MessageIcon iconMsg)
{
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(QSystemTrayIcon::Warning);
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::MessageIcon(iconMsg);
trayIcon->showMessage(tr("Server LMS"),
textMsg,
icon, 100);