diff --git a/src/ui/control/control.cpp b/src/ui/control/control.cpp index a05d9df1..bb56b50c 100644 --- a/src/ui/control/control.cpp +++ b/src/ui/control/control.cpp @@ -64,6 +64,8 @@ const char *const commandString(Command cmd) CASE_STRING(Rpc_TaskManager_abortTask) CASE_STRING(Rpc_TaskManager_taskStarted) CASE_STRING(Rpc_TaskManager_taskFinished) + CASE_STRING(Rpc_TaskManager_appVersionDownloaded) + CASE_STRING(Rpc_TaskManager_zonesDownloaded) default: return nullptr; @@ -147,6 +149,8 @@ RpcManager managerByCommand(Command cmd) Rpc_TaskManager, // Rpc_TaskManager_abortTask, Rpc_TaskManager, // Rpc_TaskManager_taskStarted, Rpc_TaskManager, // Rpc_TaskManager_taskFinished, + Rpc_TaskManager, // Rpc_TaskManager_appVersionDownloaded, + Rpc_TaskManager, // Rpc_TaskManager_zonesDownloaded, }; return g_commandManagers[cmd]; @@ -209,6 +213,8 @@ bool commandRequiresValidation(Command cmd) true, // Rpc_TaskManager_abortTask, 0, // Rpc_TaskManager_taskStarted, 0, // Rpc_TaskManager_taskFinished, + 0, // Rpc_TaskManager_appVersionDownloaded, + 0, // Rpc_TaskManager_zonesDownloaded, }; return g_commandValidations[cmd]; diff --git a/src/ui/control/control.h b/src/ui/control/control.h index e1a9b605..3572add9 100644 --- a/src/ui/control/control.h +++ b/src/ui/control/control.h @@ -64,6 +64,8 @@ enum Command : qint8 { Rpc_TaskManager_abortTask, Rpc_TaskManager_taskStarted, Rpc_TaskManager_taskFinished, + Rpc_TaskManager_appVersionDownloaded, + Rpc_TaskManager_zonesDownloaded, }; enum RpcManager : qint8 { diff --git a/src/ui/form/home/pages/aboutpage.cpp b/src/ui/form/home/pages/aboutpage.cpp index 68234760..8c8b0865 100644 --- a/src/ui/form/home/pages/aboutpage.cpp +++ b/src/ui/form/home/pages/aboutpage.cpp @@ -73,6 +73,5 @@ void AboutPage::setupNewVersionUpdate() refreshNewVersion(); - connect(taskManager()->taskInfoUpdateChecker(), &TaskInfoUpdateChecker::versionChanged, this, - refreshNewVersion); + connect(taskManager(), &TaskManager::appVersionUpdated, this, refreshNewVersion); } diff --git a/src/ui/fortmanager.cpp b/src/ui/fortmanager.cpp index 1453d7c3..889166d9 100644 --- a/src/ui/fortmanager.cpp +++ b/src/ui/fortmanager.cpp @@ -303,13 +303,30 @@ void FortManager::setupTaskManager() { auto taskManager = IoC(); + connect(taskManager, &TaskManager::appVersionDownloaded, this, [&](const QString &version) { + IoC()->showTrayMessage( + tr("New version v%1 available!").arg(version), WindowManager::MessageNewVersion); + }); + + connect(taskManager, &TaskManager::zonesDownloaded, this, [&](const QStringList &zoneNames) { + IoC()->showTrayMessage( + tr("Zone Addresses Updated: %1.").arg(zoneNames.join(", ")), + WindowManager::MessageZones); + }); + + connect(taskManager, &TaskManager::zonesUpdated, IoC(), + &ConfManager::updateDriverZones); + connect(taskManager, &TaskManager::taskDoubleClicked, this, [&](qint8 taskType) { - if (taskType == TaskInfo::ZoneDownloader) { + switch (taskType) { + case TaskInfo::UpdateChecker: { + IoC()->showHomeWindowAbout(); + } break; + case TaskInfo::ZoneDownloader: { IoC()->showZonesWindow(); + } break; } }); - connect(taskManager->taskInfoZoneDownloader(), &TaskInfoZoneDownloader::zonesUpdated, - IoC(), &ConfManager::updateDriverZones); } void FortManager::setupTranslationManager() diff --git a/src/ui/manager/windowmanager.cpp b/src/ui/manager/windowmanager.cpp index 086a3166..7a5bcdb5 100644 --- a/src/ui/manager/windowmanager.cpp +++ b/src/ui/manager/windowmanager.cpp @@ -290,6 +290,12 @@ void WindowManager::closeHomeWindow() m_homeWindow = nullptr; } +void WindowManager::showHomeWindowAbout() +{ + showHomeWindow(); + homeWindow()->selectAboutTab(); +} + void WindowManager::showProgramsWindow() { if (!widgetVisibleByCheckPassword(m_progWindow)) @@ -620,8 +626,7 @@ void WindowManager::onTrayMessageClicked() { switch (m_lastMessageType) { case MessageNewVersion: { - showHomeWindow(); - homeWindow()->selectAboutTab(); + showHomeWindowAbout(); } break; case MessageZones: { showZonesWindow(); diff --git a/src/ui/manager/windowmanager.h b/src/ui/manager/windowmanager.h index 58e5f78a..5456c225 100644 --- a/src/ui/manager/windowmanager.h +++ b/src/ui/manager/windowmanager.h @@ -59,6 +59,8 @@ public slots: void showHomeWindow(); void closeHomeWindow(); + void showHomeWindowAbout(); + void showProgramsWindow(); void closeProgramsWindow(); diff --git a/src/ui/rpc/rpcmanager.cpp b/src/ui/rpc/rpcmanager.cpp index 1f3a1001..41ac11a2 100644 --- a/src/ui/rpc/rpcmanager.cpp +++ b/src/ui/rpc/rpcmanager.cpp @@ -487,6 +487,12 @@ bool processTaskManagerRpc(const ProcessCommandArgs &p, QVariantList & /*resArgs return processTaskManager_taskStarted(taskManager, p); case Control::Rpc_TaskManager_taskFinished: return processTaskManager_taskFinished(taskManager, p); + case Control::Rpc_TaskManager_appVersionDownloaded: + emit taskManager->appVersionDownloaded(p.args[0].toString()); + return true; + case Control::Rpc_TaskManager_zonesDownloaded: + emit taskManager->zonesDownloaded(p.args[0].toStringList()); + return true; default: return false; } @@ -614,6 +620,13 @@ void RpcManager::setupTaskManagerSignals() connect(taskManager, &TaskManager::taskFinished, this, [&](qint8 taskType) { invokeOnClients(Control::Rpc_TaskManager_taskFinished, { taskType }); }); + + connect(taskManager, &TaskManager::appVersionDownloaded, this, [&](const QString &version) { + invokeOnClients(Control::Rpc_TaskManager_appVersionDownloaded, { version }); + }); + connect(taskManager, &TaskManager::zonesDownloaded, this, [&](const QStringList &zoneNames) { + invokeOnClients(Control::Rpc_TaskManager_zonesDownloaded, { zoneNames }); + }); } void RpcManager::setupClient() diff --git a/src/ui/task/taskinfoupdatechecker.cpp b/src/ui/task/taskinfoupdatechecker.cpp index 04973bc1..084910ba 100644 --- a/src/ui/task/taskinfoupdatechecker.cpp +++ b/src/ui/task/taskinfoupdatechecker.cpp @@ -5,9 +5,7 @@ #include -#include -#include - +#include "taskmanager.h" #include "taskupdatechecker.h" #define TASK_INFO_VERSION 2 @@ -63,7 +61,7 @@ void TaskInfoUpdateChecker::setData(const QByteArray &data) stream >> m_version >> m_downloadUrl >> m_releaseText; - emit versionChanged(); + emitAppVersionUpdated(); } TaskUpdateChecker *TaskInfoUpdateChecker::updateChecker() const @@ -85,12 +83,16 @@ bool TaskInfoUpdateChecker::processResult(bool success) m_downloadUrl = worker->downloadUrl(); m_releaseText = worker->releaseText(); - emit versionChanged(); + emitAppVersionUpdated(); if (isNewVersion()) { - IoC()->showTrayMessage( - tr("New version v%1 available!").arg(m_version), WindowManager::MessageNewVersion); + emit taskManager()->appVersionDownloaded(m_version); } return true; } + +void TaskInfoUpdateChecker::emitAppVersionUpdated() +{ + emit taskManager()->appVersionUpdated(m_version); +} diff --git a/src/ui/task/taskinfoupdatechecker.h b/src/ui/task/taskinfoupdatechecker.h index 3e4210c3..f1a2cebd 100644 --- a/src/ui/task/taskinfoupdatechecker.h +++ b/src/ui/task/taskinfoupdatechecker.h @@ -8,9 +8,6 @@ class TaskUpdateChecker; class TaskInfoUpdateChecker : public TaskInfo { Q_OBJECT - Q_PROPERTY(QString version READ version NOTIFY versionChanged) - Q_PROPERTY(QString downloadUrl READ downloadUrl NOTIFY versionChanged) - Q_PROPERTY(QString releaseText READ releaseText NOTIFY versionChanged) public: explicit TaskInfoUpdateChecker(TaskManager &taskManager); @@ -25,12 +22,12 @@ public: TaskUpdateChecker *updateChecker() const; -signals: - void versionChanged(); - public slots: bool processResult(bool success) override; +private: + void emitAppVersionUpdated(); + private: QString m_version; QString m_downloadUrl; diff --git a/src/ui/task/taskinfozonedownloader.cpp b/src/ui/task/taskinfozonedownloader.cpp index 3c5e7945..2d7c107d 100644 --- a/src/ui/task/taskinfozonedownloader.cpp +++ b/src/ui/task/taskinfozonedownloader.cpp @@ -4,13 +4,13 @@ #include #include -#include #include #include #include #include #include +#include "taskmanager.h" #include "taskzonedownloader.h" TaskInfoZoneDownloader::TaskInfoZoneDownloader(TaskManager &taskManager) : @@ -33,9 +33,8 @@ bool TaskInfoZoneDownloader::processResult(bool success) if (!success) return false; - IoC()->showTrayMessage( - tr("Zone Addresses Updated: %1.").arg(m_zoneNames.join(", ")), - WindowManager::MessageZones); + emit taskManager()->zonesDownloaded(m_zoneNames); + return true; } @@ -192,7 +191,7 @@ void TaskInfoZoneDownloader::addSubResult(TaskZoneDownloader *worker, bool succe void TaskInfoZoneDownloader::emitZonesUpdated() { - emit zonesUpdated(m_dataZonesMask, m_enabledMask, m_dataSize, m_zonesData); + emit taskManager()->zonesUpdated(m_dataZonesMask, m_enabledMask, m_dataSize, m_zonesData); removeOrphanCacheFiles(); diff --git a/src/ui/task/taskinfozonedownloader.h b/src/ui/task/taskinfozonedownloader.h index 8e6b6e5c..c4d4e275 100644 --- a/src/ui/task/taskinfozonedownloader.h +++ b/src/ui/task/taskinfozonedownloader.h @@ -18,10 +18,6 @@ public: TaskZoneDownloader *zoneDownloader() const; ZoneListModel *zoneListModel() const; -signals: - void zonesUpdated(quint32 zonesMask, quint32 enabledMask, quint32 dataSize, - const QList &zonesData); - public slots: bool processResult(bool success) override; diff --git a/src/ui/task/taskmanager.h b/src/ui/task/taskmanager.h index 343c8082..ee2d992f 100644 --- a/src/ui/task/taskmanager.h +++ b/src/ui/task/taskmanager.h @@ -32,6 +32,13 @@ signals: void taskDoubleClicked(qint8 taskType); + void appVersionUpdated(const QString &version); + void appVersionDownloaded(const QString &version); + + void zonesUpdated(quint32 zonesMask, quint32 enabledMask, quint32 dataSize, + const QList &zonesData); + void zonesDownloaded(const QStringList &zoneNames); + public slots: void loadSettings(); bool saveSettings();