mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:15:39 +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_abortTask)
|
||||||
CASE_STRING(Rpc_TaskManager_taskStarted)
|
CASE_STRING(Rpc_TaskManager_taskStarted)
|
||||||
CASE_STRING(Rpc_TaskManager_taskFinished)
|
CASE_STRING(Rpc_TaskManager_taskFinished)
|
||||||
|
CASE_STRING(Rpc_TaskManager_appVersionDownloaded)
|
||||||
|
CASE_STRING(Rpc_TaskManager_zonesDownloaded)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -147,6 +149,8 @@ RpcManager managerByCommand(Command cmd)
|
|||||||
Rpc_TaskManager, // Rpc_TaskManager_abortTask,
|
Rpc_TaskManager, // Rpc_TaskManager_abortTask,
|
||||||
Rpc_TaskManager, // Rpc_TaskManager_taskStarted,
|
Rpc_TaskManager, // Rpc_TaskManager_taskStarted,
|
||||||
Rpc_TaskManager, // Rpc_TaskManager_taskFinished,
|
Rpc_TaskManager, // Rpc_TaskManager_taskFinished,
|
||||||
|
Rpc_TaskManager, // Rpc_TaskManager_appVersionDownloaded,
|
||||||
|
Rpc_TaskManager, // Rpc_TaskManager_zonesDownloaded,
|
||||||
};
|
};
|
||||||
|
|
||||||
return g_commandManagers[cmd];
|
return g_commandManagers[cmd];
|
||||||
@ -209,6 +213,8 @@ bool commandRequiresValidation(Command cmd)
|
|||||||
true, // Rpc_TaskManager_abortTask,
|
true, // Rpc_TaskManager_abortTask,
|
||||||
0, // Rpc_TaskManager_taskStarted,
|
0, // Rpc_TaskManager_taskStarted,
|
||||||
0, // Rpc_TaskManager_taskFinished,
|
0, // Rpc_TaskManager_taskFinished,
|
||||||
|
0, // Rpc_TaskManager_appVersionDownloaded,
|
||||||
|
0, // Rpc_TaskManager_zonesDownloaded,
|
||||||
};
|
};
|
||||||
|
|
||||||
return g_commandValidations[cmd];
|
return g_commandValidations[cmd];
|
||||||
|
@ -64,6 +64,8 @@ enum Command : qint8 {
|
|||||||
Rpc_TaskManager_abortTask,
|
Rpc_TaskManager_abortTask,
|
||||||
Rpc_TaskManager_taskStarted,
|
Rpc_TaskManager_taskStarted,
|
||||||
Rpc_TaskManager_taskFinished,
|
Rpc_TaskManager_taskFinished,
|
||||||
|
Rpc_TaskManager_appVersionDownloaded,
|
||||||
|
Rpc_TaskManager_zonesDownloaded,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum RpcManager : qint8 {
|
enum RpcManager : qint8 {
|
||||||
|
@ -73,6 +73,5 @@ void AboutPage::setupNewVersionUpdate()
|
|||||||
|
|
||||||
refreshNewVersion();
|
refreshNewVersion();
|
||||||
|
|
||||||
connect(taskManager()->taskInfoUpdateChecker(), &TaskInfoUpdateChecker::versionChanged, this,
|
connect(taskManager(), &TaskManager::appVersionUpdated, this, refreshNewVersion);
|
||||||
refreshNewVersion);
|
|
||||||
}
|
}
|
||||||
|
@ -303,13 +303,30 @@ void FortManager::setupTaskManager()
|
|||||||
{
|
{
|
||||||
auto taskManager = IoC<TaskManager>();
|
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) {
|
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();
|
IoC<WindowManager>()->showZonesWindow();
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(taskManager->taskInfoZoneDownloader(), &TaskInfoZoneDownloader::zonesUpdated,
|
|
||||||
IoC<ConfManager>(), &ConfManager::updateDriverZones);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FortManager::setupTranslationManager()
|
void FortManager::setupTranslationManager()
|
||||||
|
@ -290,6 +290,12 @@ void WindowManager::closeHomeWindow()
|
|||||||
m_homeWindow = nullptr;
|
m_homeWindow = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WindowManager::showHomeWindowAbout()
|
||||||
|
{
|
||||||
|
showHomeWindow();
|
||||||
|
homeWindow()->selectAboutTab();
|
||||||
|
}
|
||||||
|
|
||||||
void WindowManager::showProgramsWindow()
|
void WindowManager::showProgramsWindow()
|
||||||
{
|
{
|
||||||
if (!widgetVisibleByCheckPassword(m_progWindow))
|
if (!widgetVisibleByCheckPassword(m_progWindow))
|
||||||
@ -620,8 +626,7 @@ void WindowManager::onTrayMessageClicked()
|
|||||||
{
|
{
|
||||||
switch (m_lastMessageType) {
|
switch (m_lastMessageType) {
|
||||||
case MessageNewVersion: {
|
case MessageNewVersion: {
|
||||||
showHomeWindow();
|
showHomeWindowAbout();
|
||||||
homeWindow()->selectAboutTab();
|
|
||||||
} break;
|
} break;
|
||||||
case MessageZones: {
|
case MessageZones: {
|
||||||
showZonesWindow();
|
showZonesWindow();
|
||||||
|
@ -59,6 +59,8 @@ public slots:
|
|||||||
void showHomeWindow();
|
void showHomeWindow();
|
||||||
void closeHomeWindow();
|
void closeHomeWindow();
|
||||||
|
|
||||||
|
void showHomeWindowAbout();
|
||||||
|
|
||||||
void showProgramsWindow();
|
void showProgramsWindow();
|
||||||
void closeProgramsWindow();
|
void closeProgramsWindow();
|
||||||
|
|
||||||
|
@ -487,6 +487,12 @@ bool processTaskManagerRpc(const ProcessCommandArgs &p, QVariantList & /*resArgs
|
|||||||
return processTaskManager_taskStarted(taskManager, p);
|
return processTaskManager_taskStarted(taskManager, p);
|
||||||
case Control::Rpc_TaskManager_taskFinished:
|
case Control::Rpc_TaskManager_taskFinished:
|
||||||
return processTaskManager_taskFinished(taskManager, p);
|
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:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -614,6 +620,13 @@ void RpcManager::setupTaskManagerSignals()
|
|||||||
connect(taskManager, &TaskManager::taskFinished, this, [&](qint8 taskType) {
|
connect(taskManager, &TaskManager::taskFinished, this, [&](qint8 taskType) {
|
||||||
invokeOnClients(Control::Rpc_TaskManager_taskFinished, { 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()
|
void RpcManager::setupClient()
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
|
|
||||||
#include <fort_version.h>
|
#include <fort_version.h>
|
||||||
|
|
||||||
#include <manager/windowmanager.h>
|
#include "taskmanager.h"
|
||||||
#include <util/ioc/ioccontainer.h>
|
|
||||||
|
|
||||||
#include "taskupdatechecker.h"
|
#include "taskupdatechecker.h"
|
||||||
|
|
||||||
#define TASK_INFO_VERSION 2
|
#define TASK_INFO_VERSION 2
|
||||||
@ -63,7 +61,7 @@ void TaskInfoUpdateChecker::setData(const QByteArray &data)
|
|||||||
|
|
||||||
stream >> m_version >> m_downloadUrl >> m_releaseText;
|
stream >> m_version >> m_downloadUrl >> m_releaseText;
|
||||||
|
|
||||||
emit versionChanged();
|
emitAppVersionUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskUpdateChecker *TaskInfoUpdateChecker::updateChecker() const
|
TaskUpdateChecker *TaskInfoUpdateChecker::updateChecker() const
|
||||||
@ -85,12 +83,16 @@ bool TaskInfoUpdateChecker::processResult(bool success)
|
|||||||
m_downloadUrl = worker->downloadUrl();
|
m_downloadUrl = worker->downloadUrl();
|
||||||
m_releaseText = worker->releaseText();
|
m_releaseText = worker->releaseText();
|
||||||
|
|
||||||
emit versionChanged();
|
emitAppVersionUpdated();
|
||||||
|
|
||||||
if (isNewVersion()) {
|
if (isNewVersion()) {
|
||||||
IoC<WindowManager>()->showTrayMessage(
|
emit taskManager()->appVersionDownloaded(m_version);
|
||||||
tr("New version v%1 available!").arg(m_version), WindowManager::MessageNewVersion);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TaskInfoUpdateChecker::emitAppVersionUpdated()
|
||||||
|
{
|
||||||
|
emit taskManager()->appVersionUpdated(m_version);
|
||||||
|
}
|
||||||
|
@ -8,9 +8,6 @@ class TaskUpdateChecker;
|
|||||||
class TaskInfoUpdateChecker : public TaskInfo
|
class TaskInfoUpdateChecker : public TaskInfo
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
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:
|
public:
|
||||||
explicit TaskInfoUpdateChecker(TaskManager &taskManager);
|
explicit TaskInfoUpdateChecker(TaskManager &taskManager);
|
||||||
@ -25,12 +22,12 @@ public:
|
|||||||
|
|
||||||
TaskUpdateChecker *updateChecker() const;
|
TaskUpdateChecker *updateChecker() const;
|
||||||
|
|
||||||
signals:
|
|
||||||
void versionChanged();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool processResult(bool success) override;
|
bool processResult(bool success) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void emitAppVersionUpdated();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_version;
|
QString m_version;
|
||||||
QString m_downloadUrl;
|
QString m_downloadUrl;
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
#include <conf/confmanager.h>
|
#include <conf/confmanager.h>
|
||||||
#include <fortsettings.h>
|
#include <fortsettings.h>
|
||||||
#include <manager/windowmanager.h>
|
|
||||||
#include <model/zonelistmodel.h>
|
#include <model/zonelistmodel.h>
|
||||||
#include <model/zonesourcewrapper.h>
|
#include <model/zonesourcewrapper.h>
|
||||||
#include <model/zonetypewrapper.h>
|
#include <model/zonetypewrapper.h>
|
||||||
#include <util/fileutil.h>
|
#include <util/fileutil.h>
|
||||||
#include <util/ioc/ioccontainer.h>
|
#include <util/ioc/ioccontainer.h>
|
||||||
|
|
||||||
|
#include "taskmanager.h"
|
||||||
#include "taskzonedownloader.h"
|
#include "taskzonedownloader.h"
|
||||||
|
|
||||||
TaskInfoZoneDownloader::TaskInfoZoneDownloader(TaskManager &taskManager) :
|
TaskInfoZoneDownloader::TaskInfoZoneDownloader(TaskManager &taskManager) :
|
||||||
@ -33,9 +33,8 @@ bool TaskInfoZoneDownloader::processResult(bool success)
|
|||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
IoC<WindowManager>()->showTrayMessage(
|
emit taskManager()->zonesDownloaded(m_zoneNames);
|
||||||
tr("Zone Addresses Updated: %1.").arg(m_zoneNames.join(", ")),
|
|
||||||
WindowManager::MessageZones);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +191,7 @@ void TaskInfoZoneDownloader::addSubResult(TaskZoneDownloader *worker, bool succe
|
|||||||
|
|
||||||
void TaskInfoZoneDownloader::emitZonesUpdated()
|
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();
|
removeOrphanCacheFiles();
|
||||||
|
|
||||||
|
@ -18,10 +18,6 @@ public:
|
|||||||
TaskZoneDownloader *zoneDownloader() const;
|
TaskZoneDownloader *zoneDownloader() const;
|
||||||
ZoneListModel *zoneListModel() const;
|
ZoneListModel *zoneListModel() const;
|
||||||
|
|
||||||
signals:
|
|
||||||
void zonesUpdated(quint32 zonesMask, quint32 enabledMask, quint32 dataSize,
|
|
||||||
const QList<QByteArray> &zonesData);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool processResult(bool success) override;
|
bool processResult(bool success) override;
|
||||||
|
|
||||||
|
@ -32,6 +32,13 @@ signals:
|
|||||||
|
|
||||||
void taskDoubleClicked(qint8 taskType);
|
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:
|
public slots:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
bool saveSettings();
|
bool saveSettings();
|
||||||
|
Loading…
Reference in New Issue
Block a user