mirror of
https://github.com/tnodir/fort
synced 2024-11-15 04:45:59 +00:00
UI: TaskManager: Fix tray messages showing
This commit is contained in:
parent
8365b92115
commit
2edfd6d7a1
@ -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];
|
||||
|
@ -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 {
|
||||
|
@ -73,6 +73,5 @@ void AboutPage::setupNewVersionUpdate()
|
||||
|
||||
refreshNewVersion();
|
||||
|
||||
connect(taskManager()->taskInfoUpdateChecker(), &TaskInfoUpdateChecker::versionChanged, this,
|
||||
refreshNewVersion);
|
||||
connect(taskManager(), &TaskManager::appVersionUpdated, this, refreshNewVersion);
|
||||
}
|
||||
|
@ -303,13 +303,30 @@ 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);
|
||||
});
|
||||
|
||||
connect(taskManager, &TaskManager::zonesDownloaded, this, [&](const QStringList &zoneNames) {
|
||||
IoC<WindowManager>()->showTrayMessage(
|
||||
tr("Zone Addresses Updated: %1.").arg(zoneNames.join(", ")),
|
||||
WindowManager::MessageZones);
|
||||
});
|
||||
|
||||
connect(taskManager, &TaskManager::zonesUpdated, IoC<ConfManager>(),
|
||||
&ConfManager::updateDriverZones);
|
||||
|
||||
connect(taskManager, &TaskManager::taskDoubleClicked, this, [&](qint8 taskType) {
|
||||
if (taskType == TaskInfo::ZoneDownloader) {
|
||||
switch (taskType) {
|
||||
case TaskInfo::UpdateChecker: {
|
||||
IoC<WindowManager>()->showHomeWindowAbout();
|
||||
} break;
|
||||
case TaskInfo::ZoneDownloader: {
|
||||
IoC<WindowManager>()->showZonesWindow();
|
||||
} break;
|
||||
}
|
||||
});
|
||||
connect(taskManager->taskInfoZoneDownloader(), &TaskInfoZoneDownloader::zonesUpdated,
|
||||
IoC<ConfManager>(), &ConfManager::updateDriverZones);
|
||||
}
|
||||
|
||||
void FortManager::setupTranslationManager()
|
||||
|
@ -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();
|
||||
|
@ -59,6 +59,8 @@ public slots:
|
||||
void showHomeWindow();
|
||||
void closeHomeWindow();
|
||||
|
||||
void showHomeWindowAbout();
|
||||
|
||||
void showProgramsWindow();
|
||||
void closeProgramsWindow();
|
||||
|
||||
|
@ -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()
|
||||
|
@ -5,9 +5,7 @@
|
||||
|
||||
#include <fort_version.h>
|
||||
|
||||
#include <manager/windowmanager.h>
|
||||
#include <util/ioc/ioccontainer.h>
|
||||
|
||||
#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<WindowManager>()->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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -4,13 +4,13 @@
|
||||
|
||||
#include <conf/confmanager.h>
|
||||
#include <fortsettings.h>
|
||||
#include <manager/windowmanager.h>
|
||||
#include <model/zonelistmodel.h>
|
||||
#include <model/zonesourcewrapper.h>
|
||||
#include <model/zonetypewrapper.h>
|
||||
#include <util/fileutil.h>
|
||||
#include <util/ioc/ioccontainer.h>
|
||||
|
||||
#include "taskmanager.h"
|
||||
#include "taskzonedownloader.h"
|
||||
|
||||
TaskInfoZoneDownloader::TaskInfoZoneDownloader(TaskManager &taskManager) :
|
||||
@ -33,9 +33,8 @@ bool TaskInfoZoneDownloader::processResult(bool success)
|
||||
if (!success)
|
||||
return false;
|
||||
|
||||
IoC<WindowManager>()->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();
|
||||
|
||||
|
@ -18,10 +18,6 @@ public:
|
||||
TaskZoneDownloader *zoneDownloader() const;
|
||||
ZoneListModel *zoneListModel() const;
|
||||
|
||||
signals:
|
||||
void zonesUpdated(quint32 zonesMask, quint32 enabledMask, quint32 dataSize,
|
||||
const QList<QByteArray> &zonesData);
|
||||
|
||||
public slots:
|
||||
bool processResult(bool success) override;
|
||||
|
||||
|
@ -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<QByteArray> &zonesData);
|
||||
void zonesDownloaded(const QStringList &zoneNames);
|
||||
|
||||
public slots:
|
||||
void loadSettings();
|
||||
bool saveSettings();
|
||||
|
Loading…
Reference in New Issue
Block a user