mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
Запуск refact
This commit is contained in:
@@ -21,34 +21,34 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowMinimizeButtonHint);
|
||||
|
||||
serverLMSWidget = new ServerLMSWidget(this);
|
||||
ui->verticalLayout_Main->addWidget(serverLMSWidget);
|
||||
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_InitializeFinished, this, &MainWindow::slot_InitializeFinished);
|
||||
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_hasError, this, &MainWindow::slot_hasError);
|
||||
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_LanguageChanged, this, &MainWindow::slot_LanguageChanged);
|
||||
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_updateStateServer, this, &MainWindow::slot_updateStateServer);
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Tray_ShowMessage, this, &MainWindow::slot_Tray_ShowMessage);
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_ShowWindow, this, &MainWindow::slot_TrayMenu_ShowWindow);
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_HideWindow, this, &MainWindow::slot_TrayMenu_HideWindow);
|
||||
|
||||
qtLanguageTranslator.load(QString("translations/RRJServer_") + serverLMSWidget->getLanguage(), ".");
|
||||
qApp->installTranslator(&qtLanguageTranslator);
|
||||
|
||||
/* Инициализируем иконку трея, устанавливаем иконку,
|
||||
* а также задаем всплывающую подсказку
|
||||
* */
|
||||
/* Инициализируем иконку трея, устанавливаем иконку*/
|
||||
trayIcon = new QSystemTrayIcon(this);
|
||||
//trayIcon->setIcon(this->style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||
trayIcon->setIcon(QPixmap(":/resources/PngServerRRJ_stop.png"));
|
||||
|
||||
/* После чего создаем контекстное меню для иконки трея*/
|
||||
/* Подключаем сигнал нажатия на иконку*/
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::slot_TrayIconActivated);
|
||||
/* Подключаем сигнал нажатия на всплывающее сообщение*/
|
||||
connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &MainWindow::slot_TrayMessageClicked);
|
||||
|
||||
/* Создаем контекстное меню для иконки трея*/
|
||||
trayMenu = new QMenu(this);
|
||||
action_ShowWindow = new QAction(this);
|
||||
action_HideWindow = new QAction(this);
|
||||
action_Exit = new QAction(this);
|
||||
|
||||
/* подключаем сигналы нажатий на пункты меню к соответсвующим слотам.
|
||||
* */
|
||||
/* Подключаем сигналы нажатий на пункты меню к соответсвующим слотам.*/
|
||||
connect(action_ShowWindow, &QAction::triggered, this, &MainWindow::slot_TrayMenu_ShowWindow);
|
||||
connect(action_HideWindow, &QAction::triggered, this, &MainWindow::slot_TrayMenu_HideWindow);
|
||||
connect(action_Exit, &QAction::triggered, this, &MainWindow::slot_TrayMenu_Exit);
|
||||
@@ -65,8 +65,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
trayIcon->setContextMenu(trayMenu);
|
||||
trayIcon->show();
|
||||
|
||||
slot_Tray_ShowMessage(tr("Starting the server..."));
|
||||
//slot_Tray_ShowMessage(tr("Starting the server..."));
|
||||
|
||||
ui->verticalLayout_Main->addWidget(serverLMSWidget);
|
||||
|
||||
//Отложенная инициализация (для serverLMSWidget)
|
||||
QTimer::singleShot(1000, this, &MainWindow::slot_LazyInitialization);
|
||||
}
|
||||
|
||||
@@ -81,8 +84,6 @@ MainWindow::~MainWindow()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/* Метод, который обрабатывает событие закрытия окна приложения
|
||||
* */
|
||||
void MainWindow::closeEvent(QCloseEvent * event)
|
||||
{
|
||||
/* Если окно видимо, то завершение приложения
|
||||
@@ -93,7 +94,9 @@ void MainWindow::closeEvent(QCloseEvent * event)
|
||||
event->ignore();
|
||||
|
||||
if(flInitServerLMSWidget)
|
||||
{//Не даем свернуть окно, пока не прошла инициализация serverLMSWidget
|
||||
slot_TrayMenu_HideWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +112,6 @@ void MainWindow::changeEvent(QEvent *event)
|
||||
}
|
||||
}
|
||||
|
||||
/* Метод, который обрабатывает нажатие на иконку приложения в трее
|
||||
* */
|
||||
void MainWindow::slot_TrayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
switch (reason){
|
||||
@@ -132,8 +133,6 @@ void MainWindow::slot_TrayIconActivated(QSystemTrayIcon::ActivationReason reason
|
||||
}
|
||||
}
|
||||
|
||||
/* Метод, который обрабатывает нажатие на сообщение из трея
|
||||
* */
|
||||
void MainWindow::slot_TrayMessageClicked()
|
||||
{
|
||||
if(!this->isVisible())
|
||||
@@ -194,24 +193,17 @@ void MainWindow::slot_LazyInitialization()
|
||||
|
||||
void MainWindow::slot_hasError(int code)
|
||||
{
|
||||
errorCheck();
|
||||
if(code == 100)
|
||||
{
|
||||
slot_TrayMenu_ShowWindow();
|
||||
|
||||
//выключение с задержкой
|
||||
QTimer::singleShot(1000, this, &MainWindow::slot_TrayMenu_Exit);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::slot_InitializeFinished()
|
||||
{
|
||||
/* Также подключаем сигнал нажатия на иконку к обработчику
|
||||
* данного нажатия
|
||||
* */
|
||||
connect(trayIcon, &QSystemTrayIcon::activated, this, &MainWindow::slot_TrayIconActivated);
|
||||
/* Также подключаем сигнал нажатия на всплывающее сообщение к обработчику
|
||||
* данного нажатия
|
||||
* */
|
||||
connect(trayIcon, &QSystemTrayIcon::messageClicked, this, &MainWindow::slot_TrayMessageClicked);
|
||||
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Tray_ShowMessage, this, &MainWindow::slot_Tray_ShowMessage);
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_ShowWindow, this, &MainWindow::slot_TrayMenu_ShowWindow);
|
||||
connect(serverLMSWidget, &ServerLMSWidget::signal_Menu_HideWindow, this, &MainWindow::slot_TrayMenu_HideWindow);
|
||||
|
||||
flInitServerLMSWidget = true;
|
||||
}
|
||||
|
||||
@@ -221,21 +213,6 @@ void MainWindow::slot_LanguageChanged(QString language)
|
||||
qApp->installTranslator(&qtLanguageTranslator);
|
||||
}
|
||||
|
||||
void MainWindow::exit()
|
||||
{
|
||||
QApplication::exit(0);
|
||||
}
|
||||
|
||||
void MainWindow::errorCheck()
|
||||
{
|
||||
if(serverLMSWidget->hasError() == 100)
|
||||
{
|
||||
slot_TrayMenu_ShowWindow();
|
||||
|
||||
//выключение с задержкой, так как eventLoop инициализируется позже
|
||||
QTimer::singleShot(1000, this, &MainWindow::slot_TrayMenu_Exit);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateTrayTitles()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user