mirror of
https://github.com/tnodir/fort
synced 2024-11-15 07:57:24 +00:00
UI: Programs: Add "Clear Alerts" button
This commit is contained in:
parent
2644e4e4df
commit
8798e91d8b
@ -116,6 +116,8 @@ const char *const sqlInsertAppAlert = "INSERT INTO app_alert(app_id) VALUES(?1);
|
|||||||
|
|
||||||
const char *const sqlDeleteAppAlert = "DELETE FROM app_alert WHERE app_id = ?1;";
|
const char *const sqlDeleteAppAlert = "DELETE FROM app_alert WHERE app_id = ?1;";
|
||||||
|
|
||||||
|
const char *const sqlDeleteAppAlerts = "DELETE FROM app_alert;";
|
||||||
|
|
||||||
const char *const sqlUpdateAppBlocked = "UPDATE app SET blocked = ?2, kill_process = ?3"
|
const char *const sqlUpdateAppBlocked = "UPDATE app SET blocked = ?2, kill_process = ?3"
|
||||||
" WHERE app_id = ?1;";
|
" WHERE app_id = ?1;";
|
||||||
|
|
||||||
@ -395,6 +397,17 @@ bool ConfAppManager::deleteApps(const QVector<qint64> &appIdList)
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfAppManager::clearAlerts()
|
||||||
|
{
|
||||||
|
const bool ok = DbQuery(sqliteDb()).sql(sqlDeleteAppAlerts).executeOk();
|
||||||
|
|
||||||
|
if (ok) {
|
||||||
|
emitAppsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ok;
|
||||||
|
}
|
||||||
|
|
||||||
bool ConfAppManager::deleteApp(qint64 appId, bool &isWildcard)
|
bool ConfAppManager::deleteApp(qint64 appId, bool &isWildcard)
|
||||||
{
|
{
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
|
@ -42,6 +42,7 @@ public:
|
|||||||
virtual bool updateApp(App &app);
|
virtual bool updateApp(App &app);
|
||||||
virtual bool updateAppName(qint64 appId, const QString &appName);
|
virtual bool updateAppName(qint64 appId, const QString &appName);
|
||||||
virtual bool deleteApps(const QVector<qint64> &appIdList);
|
virtual bool deleteApps(const QVector<qint64> &appIdList);
|
||||||
|
virtual bool clearAlerts();
|
||||||
virtual bool purgeApps();
|
virtual bool purgeApps();
|
||||||
virtual bool updateAppsBlocked(
|
virtual bool updateAppsBlocked(
|
||||||
const QVector<qint64> &appIdList, bool blocked, bool killProcess);
|
const QVector<qint64> &appIdList, bool blocked, bool killProcess);
|
||||||
|
@ -38,6 +38,7 @@ static const QHash<Command, const char *> g_commandNames = {
|
|||||||
CASE_STRING(Rpc_ConfAppManager_updateApp),
|
CASE_STRING(Rpc_ConfAppManager_updateApp),
|
||||||
CASE_STRING(Rpc_ConfAppManager_updateAppName),
|
CASE_STRING(Rpc_ConfAppManager_updateAppName),
|
||||||
CASE_STRING(Rpc_ConfAppManager_deleteApps),
|
CASE_STRING(Rpc_ConfAppManager_deleteApps),
|
||||||
|
CASE_STRING(Rpc_ConfAppManager_clearAlerts),
|
||||||
CASE_STRING(Rpc_ConfAppManager_purgeApps),
|
CASE_STRING(Rpc_ConfAppManager_purgeApps),
|
||||||
CASE_STRING(Rpc_ConfAppManager_updateAppsBlocked),
|
CASE_STRING(Rpc_ConfAppManager_updateAppsBlocked),
|
||||||
CASE_STRING(Rpc_ConfAppManager_appAlerted),
|
CASE_STRING(Rpc_ConfAppManager_appAlerted),
|
||||||
@ -145,6 +146,7 @@ static const RpcManager g_commandManagers[] = {
|
|||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateApp,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateApp,
|
||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateAppName,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateAppName,
|
||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_deleteApps,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_deleteApps,
|
||||||
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_clearAlerts,
|
||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_purgeApps,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_purgeApps,
|
||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateAppsBlocked,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_updateAppsBlocked,
|
||||||
Rpc_ConfAppManager, // Rpc_ConfAppManager_appEndTimesUpdated,
|
Rpc_ConfAppManager, // Rpc_ConfAppManager_appEndTimesUpdated,
|
||||||
@ -232,6 +234,7 @@ static const qint8 g_commandValidations[] = {
|
|||||||
true, // Rpc_ConfAppManager_updateApp,
|
true, // Rpc_ConfAppManager_updateApp,
|
||||||
true, // Rpc_ConfAppManager_updateAppName,
|
true, // Rpc_ConfAppManager_updateAppName,
|
||||||
true, // Rpc_ConfAppManager_deleteApps,
|
true, // Rpc_ConfAppManager_deleteApps,
|
||||||
|
true, // Rpc_ConfAppManager_clearAlerts,
|
||||||
true, // Rpc_ConfAppManager_purgeApps,
|
true, // Rpc_ConfAppManager_purgeApps,
|
||||||
true, // Rpc_ConfAppManager_updateAppsBlocked,
|
true, // Rpc_ConfAppManager_updateAppsBlocked,
|
||||||
0, // Rpc_ConfAppManager_appEndTimesUpdated,
|
0, // Rpc_ConfAppManager_appEndTimesUpdated,
|
||||||
|
@ -40,6 +40,7 @@ enum Command : qint8 {
|
|||||||
Rpc_ConfAppManager_updateApp,
|
Rpc_ConfAppManager_updateApp,
|
||||||
Rpc_ConfAppManager_updateAppName,
|
Rpc_ConfAppManager_updateAppName,
|
||||||
Rpc_ConfAppManager_deleteApps,
|
Rpc_ConfAppManager_deleteApps,
|
||||||
|
Rpc_ConfAppManager_clearAlerts,
|
||||||
Rpc_ConfAppManager_purgeApps,
|
Rpc_ConfAppManager_purgeApps,
|
||||||
Rpc_ConfAppManager_updateAppsBlocked,
|
Rpc_ConfAppManager_updateAppsBlocked,
|
||||||
Rpc_ConfAppManager_appEndTimesUpdated,
|
Rpc_ConfAppManager_appEndTimesUpdated,
|
||||||
|
@ -63,6 +63,11 @@ void ProgramsController::deleteApps(const QVector<qint64> &appIdList)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramsController::clearAlerts()
|
||||||
|
{
|
||||||
|
confAppManager()->clearAlerts();
|
||||||
|
}
|
||||||
|
|
||||||
void ProgramsController::purgeApps()
|
void ProgramsController::purgeApps()
|
||||||
{
|
{
|
||||||
taskManager()->runTask(TaskInfo::AppPurger);
|
taskManager()->runTask(TaskInfo::AppPurger);
|
||||||
|
@ -25,6 +25,7 @@ public slots:
|
|||||||
bool updateAppName(qint64 appId, const QString &appName);
|
bool updateAppName(qint64 appId, const QString &appName);
|
||||||
void updateAppsBlocked(const QVector<qint64> &appIdList, bool blocked, bool killProcess);
|
void updateAppsBlocked(const QVector<qint64> &appIdList, bool blocked, bool killProcess);
|
||||||
void deleteApps(const QVector<qint64> &appIdList);
|
void deleteApps(const QVector<qint64> &appIdList);
|
||||||
|
void clearAlerts();
|
||||||
void purgeApps();
|
void purgeApps();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -130,6 +130,7 @@ void ProgramsWindow::retranslateUi()
|
|||||||
m_actEditApp->setText(tr("Edit"));
|
m_actEditApp->setText(tr("Edit"));
|
||||||
m_actRemoveApp->setText(tr("Remove"));
|
m_actRemoveApp->setText(tr("Remove"));
|
||||||
m_actReviewAlerts->setText(tr("Review Alerts"));
|
m_actReviewAlerts->setText(tr("Review Alerts"));
|
||||||
|
m_actClearAlerts->setText(tr("Clear Alerts"));
|
||||||
m_actPurgeApps->setText(tr("Purge Obsolete"));
|
m_actPurgeApps->setText(tr("Purge Obsolete"));
|
||||||
m_actFindApps->setText(tr("Find"));
|
m_actFindApps->setText(tr("Find"));
|
||||||
|
|
||||||
@ -276,6 +277,10 @@ void ProgramsWindow::setupEditMenu()
|
|||||||
editMenu->addSeparator();
|
editMenu->addSeparator();
|
||||||
|
|
||||||
m_actReviewAlerts = editMenu->addAction(IconCache::icon(":/icons/error.png"), QString());
|
m_actReviewAlerts = editMenu->addAction(IconCache::icon(":/icons/error.png"), QString());
|
||||||
|
m_actClearAlerts = editMenu->addAction(QString());
|
||||||
|
|
||||||
|
editMenu->addSeparator();
|
||||||
|
|
||||||
m_actPurgeApps = editMenu->addAction(IconCache::icon(":/icons/recycle.png"), QString());
|
m_actPurgeApps = editMenu->addAction(IconCache::icon(":/icons/recycle.png"), QString());
|
||||||
|
|
||||||
m_actFindApps = editMenu->addAction(IconCache::icon(":/icons/magnifier.png"), QString());
|
m_actFindApps = editMenu->addAction(IconCache::icon(":/icons/magnifier.png"), QString());
|
||||||
@ -294,6 +299,7 @@ void ProgramsWindow::setupEditMenu()
|
|||||||
connect(m_actRemoveApp, &QAction::triggered, this, &ProgramsWindow::deleteSelectedApps);
|
connect(m_actRemoveApp, &QAction::triggered, this, &ProgramsWindow::deleteSelectedApps);
|
||||||
connect(m_actReviewAlerts, &QAction::triggered, this,
|
connect(m_actReviewAlerts, &QAction::triggered, this,
|
||||||
[&] { windowManager()->showProgramAlertWindow(); });
|
[&] { windowManager()->showProgramAlertWindow(); });
|
||||||
|
connect(m_actClearAlerts, &QAction::triggered, this, &ProgramsWindow::clearAlerts);
|
||||||
connect(m_actPurgeApps, &QAction::triggered, this, [&] {
|
connect(m_actPurgeApps, &QAction::triggered, this, [&] {
|
||||||
windowManager()->showConfirmBox([&] { ctrl()->purgeApps(); },
|
windowManager()->showConfirmBox([&] { ctrl()->purgeApps(); },
|
||||||
tr("Are you sure to remove all non-existent programs?"));
|
tr("Are you sure to remove all non-existent programs?"));
|
||||||
@ -578,6 +584,12 @@ void ProgramsWindow::deleteSelectedApps()
|
|||||||
+ "\n\n" + appNames.join('\n'));
|
+ "\n\n" + appNames.join('\n'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgramsWindow::clearAlerts()
|
||||||
|
{
|
||||||
|
windowManager()->showConfirmBox(
|
||||||
|
[=, this] { ctrl()->clearAlerts(); }, tr("Are you sure to clear alerts?"));
|
||||||
|
}
|
||||||
|
|
||||||
int ProgramsWindow::appListCurrentIndex() const
|
int ProgramsWindow::appListCurrentIndex() const
|
||||||
{
|
{
|
||||||
return m_appListView->currentRow();
|
return m_appListView->currentRow();
|
||||||
|
@ -76,6 +76,8 @@ private:
|
|||||||
void updateSelectedApps(bool blocked, bool killProcess = false);
|
void updateSelectedApps(bool blocked, bool killProcess = false);
|
||||||
void deleteSelectedApps();
|
void deleteSelectedApps();
|
||||||
|
|
||||||
|
void clearAlerts();
|
||||||
|
|
||||||
int appListCurrentIndex() const;
|
int appListCurrentIndex() const;
|
||||||
AppRow appListCurrentRow() const;
|
AppRow appListCurrentRow() const;
|
||||||
QString appListCurrentPath() const;
|
QString appListCurrentPath() const;
|
||||||
@ -96,6 +98,7 @@ private:
|
|||||||
QAction *m_actEditApp = nullptr;
|
QAction *m_actEditApp = nullptr;
|
||||||
QAction *m_actRemoveApp = nullptr;
|
QAction *m_actRemoveApp = nullptr;
|
||||||
QAction *m_actReviewAlerts = nullptr;
|
QAction *m_actReviewAlerts = nullptr;
|
||||||
|
QAction *m_actClearAlerts = nullptr;
|
||||||
QAction *m_actPurgeApps = nullptr;
|
QAction *m_actPurgeApps = nullptr;
|
||||||
QAction *m_actFindApps = nullptr;
|
QAction *m_actFindApps = nullptr;
|
||||||
QPushButton *m_btEdit = nullptr;
|
QPushButton *m_btEdit = nullptr;
|
||||||
|
@ -55,6 +55,12 @@ bool processConfAppManager_deleteApps(
|
|||||||
return confAppManager->deleteApps(appIdList);
|
return confAppManager->deleteApps(appIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool processConfAppManager_clearAlerts(ConfAppManager *confAppManager,
|
||||||
|
const ProcessCommandArgs & /*p*/, QVariantList & /*resArgs*/)
|
||||||
|
{
|
||||||
|
return confAppManager->clearAlerts();
|
||||||
|
}
|
||||||
|
|
||||||
bool processConfAppManager_purgeApps(ConfAppManager *confAppManager,
|
bool processConfAppManager_purgeApps(ConfAppManager *confAppManager,
|
||||||
const ProcessCommandArgs & /*p*/, QVariantList & /*resArgs*/)
|
const ProcessCommandArgs & /*p*/, QVariantList & /*resArgs*/)
|
||||||
{
|
{
|
||||||
@ -81,6 +87,7 @@ static const processConfAppManager_func processConfAppManager_funcList[] = {
|
|||||||
&processConfAppManager_updateApp, // Rpc_ConfAppManager_updateApp,
|
&processConfAppManager_updateApp, // Rpc_ConfAppManager_updateApp,
|
||||||
&processConfAppManager_updateAppName, // Rpc_ConfAppManager_updateAppName,
|
&processConfAppManager_updateAppName, // Rpc_ConfAppManager_updateAppName,
|
||||||
&processConfAppManager_deleteApps, // Rpc_ConfAppManager_deleteApps,
|
&processConfAppManager_deleteApps, // Rpc_ConfAppManager_deleteApps,
|
||||||
|
&processConfAppManager_clearAlerts, // Rpc_ConfAppManager_clearAlerts,
|
||||||
&processConfAppManager_purgeApps, // Rpc_ConfAppManager_purgeApps,
|
&processConfAppManager_purgeApps, // Rpc_ConfAppManager_purgeApps,
|
||||||
&processConfAppManager_updateAppsBlocked, // Rpc_ConfAppManager_updateAppsBlocked,
|
&processConfAppManager_updateAppsBlocked, // Rpc_ConfAppManager_updateAppsBlocked,
|
||||||
};
|
};
|
||||||
@ -140,6 +147,11 @@ bool ConfAppManagerRpc::deleteApps(const QVector<qint64> &appIdList)
|
|||||||
return IoC<RpcManager>()->doOnServer(Control::Rpc_ConfAppManager_deleteApps, args);
|
return IoC<RpcManager>()->doOnServer(Control::Rpc_ConfAppManager_deleteApps, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfAppManagerRpc::clearAlerts()
|
||||||
|
{
|
||||||
|
return IoC<RpcManager>()->doOnServer(Control::Rpc_ConfAppManager_clearAlerts);
|
||||||
|
}
|
||||||
|
|
||||||
bool ConfAppManagerRpc::purgeApps()
|
bool ConfAppManagerRpc::purgeApps()
|
||||||
{
|
{
|
||||||
return IoC<RpcManager>()->doOnServer(Control::Rpc_ConfAppManager_purgeApps);
|
return IoC<RpcManager>()->doOnServer(Control::Rpc_ConfAppManager_purgeApps);
|
||||||
|
@ -21,6 +21,7 @@ public:
|
|||||||
bool updateApp(App &app) override;
|
bool updateApp(App &app) override;
|
||||||
bool updateAppName(qint64 appId, const QString &appName) override;
|
bool updateAppName(qint64 appId, const QString &appName) override;
|
||||||
bool deleteApps(const QVector<qint64> &appIdList) override;
|
bool deleteApps(const QVector<qint64> &appIdList) override;
|
||||||
|
bool clearAlerts() override;
|
||||||
bool purgeApps() override;
|
bool purgeApps() override;
|
||||||
bool updateAppsBlocked(
|
bool updateAppsBlocked(
|
||||||
const QVector<qint64> &appIdList, bool blocked, bool killProcess) override;
|
const QVector<qint64> &appIdList, bool blocked, bool killProcess) override;
|
||||||
|
Loading…
Reference in New Issue
Block a user