UI: WindowManager: Minor refactor

This commit is contained in:
Nodir Temirkhodjaev 2023-12-29 13:40:31 +03:00
parent 3113e355eb
commit e91f63ce66
4 changed files with 15 additions and 15 deletions

View File

@ -535,7 +535,7 @@ void TrayIcon::sendAlertMessage()
if (!(m_alerted && iniUser()->progNotifyMessage()))
return;
windowManager()->showTrayMessage(tr("New program detected!"), WindowManager::MessageAlert);
windowManager()->showTrayMessage(tr("New program detected!"), WindowManager::TrayMessageAlert);
}
void TrayIcon::updateAlertTimer()

View File

@ -360,14 +360,14 @@ void FortManager::setupTaskManager()
auto taskManager = IoC<TaskManager>();
connect(taskManager, &TaskManager::appVersionDownloaded, this, [&](const QString &version) {
IoC<WindowManager>()->showTrayMessage(
tr("New version v%1 available!").arg(version), WindowManager::MessageNewVersion);
IoC<WindowManager>()->showTrayMessage(tr("New version v%1 available!").arg(version),
WindowManager::TrayMessageNewVersion);
});
connect(taskManager, &TaskManager::zonesDownloaded, this, [&](const QStringList &zoneNames) {
IoC<WindowManager>()->showTrayMessage(
tr("Zone Addresses Updated: %1.").arg(zoneNames.join(", ")),
WindowManager::MessageZones);
WindowManager::TrayMessageZones);
});
connect(taskManager, &TaskManager::zonesUpdated, IoC<ConfZoneManager>(),

View File

@ -268,7 +268,7 @@ void WindowManager::showTrayMessage(const QString &message, WindowManager::TrayM
if (!m_trayIcon)
return;
m_lastMessageType = type;
m_lastTrayMessageType = type;
m_trayIcon->showMessage(QGuiApplication::applicationDisplayName(), message);
}
@ -646,14 +646,14 @@ bool WindowManager::showPasswordDialog(QString &password, int *unlockType)
void WindowManager::onTrayMessageClicked()
{
switch (m_lastMessageType) {
case MessageNewVersion: {
switch (m_lastTrayMessageType) {
case TrayMessageNewVersion: {
showHomeWindowAbout();
} break;
case MessageZones: {
case TrayMessageZones: {
showZonesWindow();
} break;
case MessageAlert: {
case TrayMessageAlert: {
showProgramsWindow();
} break;
default:

View File

@ -26,10 +26,10 @@ class WindowManager : public QObject, public IocService
public:
enum TrayMessageType : qint8 {
MessageOptions,
MessageNewVersion,
MessageZones,
MessageAlert,
TrayMessageOptions,
TrayMessageNewVersion,
TrayMessageZones,
TrayMessageAlert,
};
Q_ENUM(TrayMessageType)
@ -65,7 +65,7 @@ public slots:
void showTrayIcon();
void closeTrayIcon();
void showTrayMessage(
const QString &message, WindowManager::TrayMessageType type = MessageOptions);
const QString &message, WindowManager::TrayMessageType type = TrayMessageOptions);
void showHomeWindow();
void closeHomeWindow();
@ -154,7 +154,7 @@ private:
quint32 m_openedWindows = 0;
TrayMessageType m_lastMessageType = MessageOptions;
TrayMessageType m_lastTrayMessageType = TrayMessageOptions;
TrayIcon *m_trayIcon = nullptr;