UI: ProgramEditDialog: Focus on checked action

This commit is contained in:
Nodir Temirkhodjaev 2024-02-02 11:44:45 +03:00
parent 30d816a42a
commit 58981d1062
2 changed files with 21 additions and 3 deletions

View File

@ -115,6 +115,8 @@ void ProgramEditDialog::initialize(const AppRow &appRow, const QVector<qint64> &
m_scScheduleIn->spinBox()->setValue(30);
m_dteScheduleAt->setDateTime(appRow.scheduleTime);
m_dteScheduleAt->setMinimumDateTime(DateUtil::now());
initializeFocus();
}
void ProgramEditDialog::initializePathNameFields()
@ -124,8 +126,6 @@ void ProgramEditDialog::initializePathNameFields()
initializePathField(isSingleSelection, isPathEditable);
initializeNameField(isSingleSelection, isPathEditable);
initializeFocus();
}
void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathEditable)
@ -167,7 +167,7 @@ void ProgramEditDialog::initializeNameField(bool isSingleSelection, bool isPathE
void ProgramEditDialog::initializeFocus()
{
if (!isEmpty()) {
m_rbAllowApp->setFocus();
m_btgActions->checkedButton()->setFocus();
} else if (isWildcard()) {
m_editWildcard->setFocus();
} else {
@ -294,6 +294,8 @@ void ProgramEditDialog::setupUi()
// Allow/Block/etc Actions Layout
auto actionsLayout = setupActionsLayout();
setupActionsGroup();
// Advanced Options
setupAdvancedOptions();
@ -435,13 +437,16 @@ void ProgramEditDialog::setupComboAppGroups()
QLayout *ProgramEditDialog::setupActionsLayout()
{
// Allow
m_rbAllowApp = new QRadioButton();
m_rbAllowApp->setIcon(IconCache::icon(":/icons/accept.png"));
m_rbAllowApp->setChecked(true);
// Block
m_rbBlockApp = new QRadioButton();
m_rbBlockApp->setIcon(IconCache::icon(":/icons/deny.png"));
// Kill Process
m_rbKillProcess = new QRadioButton();
m_rbKillProcess->setIcon(IconCache::icon(":/icons/scull.png"));
@ -454,6 +459,16 @@ QLayout *ProgramEditDialog::setupActionsLayout()
return layout;
}
void ProgramEditDialog::setupActionsGroup()
{
m_btgActions = new QButtonGroup(this);
m_btgActions->setExclusive(true);
m_btgActions->addButton(m_rbAllowApp);
m_btgActions->addButton(m_rbBlockApp);
m_btgActions->addButton(m_rbKillProcess);
}
void ProgramEditDialog::setupAdvancedOptions()
{
// Use Group Perm.

View File

@ -4,6 +4,7 @@
#include <model/applistmodel.h>
#include <util/window/widgetwindow.h>
QT_FORWARD_DECLARE_CLASS(QButtonGroup)
QT_FORWARD_DECLARE_CLASS(QCheckBox)
QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QDateTimeEdit)
@ -72,6 +73,7 @@ private:
QLayout *setupNotesLayout();
void setupComboAppGroups();
QLayout *setupActionsLayout();
void setupActionsGroup();
void setupAdvancedOptions();
QLayout *setupChildLayout();
QLayout *setupLogLayout();
@ -113,6 +115,7 @@ private:
QRadioButton *m_rbAllowApp = nullptr;
QRadioButton *m_rbBlockApp = nullptr;
QRadioButton *m_rbKillProcess = nullptr;
QButtonGroup *m_btgActions = nullptr;
QCheckBox *m_cbUseGroupPerm = nullptr;
QCheckBox *m_cbApplyChild = nullptr;
QCheckBox *m_cbKillChild = nullptr;