UI: Programs: Add "Convert to Wildcard" menu item

This commit is contained in:
Nodir Temirkhodjaev 2024-06-27 10:49:42 +05:00
parent 8c212295c7
commit 8ea50d809e
2 changed files with 27 additions and 1 deletions

View File

@ -132,6 +132,7 @@ void ProgramsWindow::retranslateUi()
m_actKillApp->setText(tr("Kill Process")); m_actKillApp->setText(tr("Kill Process"));
m_actAddApp->setText(tr("Add")); m_actAddApp->setText(tr("Add"));
m_actAddWildcard->setText(tr("Add Wildcard")); m_actAddWildcard->setText(tr("Add Wildcard"));
m_actToWildcard->setText(tr("Convert to Wildcard"));
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"));
@ -269,6 +270,8 @@ void ProgramsWindow::setupEditMenu()
m_actAddWildcard = editMenu->addAction(IconCache::icon(":/icons/coding.png"), QString()); m_actAddWildcard = editMenu->addAction(IconCache::icon(":/icons/coding.png"), QString());
m_actAddWildcard->setShortcut(QKeyCombination(Qt::CTRL, Qt::Key_N)); m_actAddWildcard->setShortcut(QKeyCombination(Qt::CTRL, Qt::Key_N));
m_actToWildcard = editMenu->addAction(IconCache::icon(":/icons/coding.png"), QString());
m_actEditApp = editMenu->addAction(IconCache::icon(":/icons/pencil.png"), QString()); m_actEditApp = editMenu->addAction(IconCache::icon(":/icons/pencil.png"), QString());
m_actEditApp->setShortcut(Qt::Key_Enter); m_actEditApp->setShortcut(Qt::Key_Enter);
@ -291,6 +294,7 @@ void ProgramsWindow::setupEditMenu()
[&] { updateSelectedApps(/*blocked=*/true, /*killProcess=*/true); }); [&] { updateSelectedApps(/*blocked=*/true, /*killProcess=*/true); });
connect(m_actAddApp, &QAction::triggered, this, &ProgramsWindow::addNewProgram); connect(m_actAddApp, &QAction::triggered, this, &ProgramsWindow::addNewProgram);
connect(m_actAddWildcard, &QAction::triggered, this, &ProgramsWindow::addNewWildcard); connect(m_actAddWildcard, &QAction::triggered, this, &ProgramsWindow::addNewWildcard);
connect(m_actToWildcard, &QAction::triggered, this, &ProgramsWindow::convertToWildcard);
connect(m_actEditApp, &QAction::triggered, this, &ProgramsWindow::editSelectedPrograms); connect(m_actEditApp, &QAction::triggered, this, &ProgramsWindow::editSelectedPrograms);
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,
@ -431,6 +435,7 @@ void ProgramsWindow::setupTableAppsChanged()
m_actAllowApp->setEnabled(appSelected); m_actAllowApp->setEnabled(appSelected);
m_actBlockApp->setEnabled(appSelected); m_actBlockApp->setEnabled(appSelected);
m_actKillApp->setEnabled(appSelected); m_actKillApp->setEnabled(appSelected);
m_actToWildcard->setEnabled(appSelected);
m_actEditApp->setEnabled(appSelected); m_actEditApp->setEnabled(appSelected);
m_actRemoveApp->setEnabled(appSelected); m_actRemoveApp->setEnabled(appSelected);
m_btAllowApp->setEnabled(appSelected); m_btAllowApp->setEnabled(appSelected);
@ -490,9 +495,28 @@ void ProgramsWindow::addNewWildcard()
openAppEditForm(appRow); openAppEditForm(appRow);
} }
void ProgramsWindow::convertToWildcard()
{
const AppRow appRow = appListCurrentRow();
if (appRow.isNull())
return;
if (appRow.isWildcard)
return;
windowManager()->showConfirmBox(
[=, this] {
App app = appRow;
app.isWildcard = true;
ctrl()->addOrUpdateApp(app);
},
tr("Are you sure to convert selected program to wildcard?"));
}
void ProgramsWindow::editSelectedPrograms() void ProgramsWindow::editSelectedPrograms()
{ {
const QVector<qint64> appIdList = selectedAppIdList(); const auto appIdList = selectedAppIdList();
if (appIdList.isEmpty()) if (appIdList.isEmpty())
return; return;

View File

@ -74,6 +74,7 @@ private:
void addNewProgram(); void addNewProgram();
void addNewWildcard(); void addNewWildcard();
void convertToWildcard();
void editSelectedPrograms(); void editSelectedPrograms();
void openAppEditForm(const AppRow &appRow, const QVector<qint64> &appIdList = {}); void openAppEditForm(const AppRow &appRow, const QVector<qint64> &appIdList = {});
@ -99,6 +100,7 @@ private:
QAction *m_actKillApp = nullptr; QAction *m_actKillApp = nullptr;
QAction *m_actAddApp = nullptr; QAction *m_actAddApp = nullptr;
QAction *m_actAddWildcard = nullptr; QAction *m_actAddWildcard = nullptr;
QAction *m_actToWildcard = nullptr;
QAction *m_actEditApp = nullptr; QAction *m_actEditApp = nullptr;
QAction *m_actRemoveApp = nullptr; QAction *m_actRemoveApp = nullptr;
QAction *m_actReviewAlerts = nullptr; QAction *m_actReviewAlerts = nullptr;