mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:17:28 +00:00
UI: ProgramEditDialog: Reorganize for advanced mode
This commit is contained in:
parent
a8c86bfbe1
commit
3733819936
@ -90,19 +90,21 @@ void ProgramEditDialog::initialize(const AppRow &appRow, const QVector<qint64> &
|
|||||||
initializePathNameFields();
|
initializePathNameFields();
|
||||||
|
|
||||||
m_comboAppGroup->setCurrentIndex(appRow.groupIndex);
|
m_comboAppGroup->setCurrentIndex(appRow.groupIndex);
|
||||||
m_cbUseGroupPerm->setChecked(appRow.useGroupPerm);
|
|
||||||
m_cbApplyChild->setChecked(appRow.applyChild);
|
|
||||||
m_cbKillChild->setChecked(appRow.killChild);
|
|
||||||
|
|
||||||
m_cbLanOnly->setChecked(appRow.lanOnly);
|
|
||||||
m_cbParked->setChecked(appRow.parked);
|
|
||||||
m_cbParked->setEnabled(!isWildcard());
|
|
||||||
m_cbLogBlocked->setChecked(appRow.logBlocked);
|
|
||||||
m_cbLogConn->setChecked(appRow.logConn);
|
|
||||||
m_rbAllowApp->setChecked(!appRow.blocked);
|
m_rbAllowApp->setChecked(!appRow.blocked);
|
||||||
m_rbBlockApp->setChecked(appRow.blocked);
|
m_rbBlockApp->setChecked(appRow.blocked);
|
||||||
m_rbKillProcess->setChecked(appRow.killProcess);
|
m_rbKillProcess->setChecked(appRow.killProcess);
|
||||||
|
|
||||||
|
m_cbUseGroupPerm->setChecked(appRow.useGroupPerm);
|
||||||
|
m_cbApplyChild->setChecked(appRow.applyChild);
|
||||||
|
m_cbKillChild->setChecked(appRow.killChild);
|
||||||
|
|
||||||
|
m_cbParked->setChecked(appRow.parked);
|
||||||
|
m_cbParked->setEnabled(!isWildcard());
|
||||||
|
m_cbLogBlocked->setChecked(appRow.logBlocked);
|
||||||
|
m_cbLogConn->setChecked(appRow.logConn);
|
||||||
|
|
||||||
|
m_cbLanOnly->setChecked(appRow.lanOnly);
|
||||||
m_btZones->setZones(appRow.acceptZones);
|
m_btZones->setZones(appRow.acceptZones);
|
||||||
m_btZones->setUncheckedZones(appRow.rejectZones);
|
m_btZones->setUncheckedZones(appRow.rejectZones);
|
||||||
|
|
||||||
@ -122,6 +124,8 @@ void ProgramEditDialog::initializePathNameFields()
|
|||||||
|
|
||||||
initializePathField(isSingleSelection, isPathEditable);
|
initializePathField(isSingleSelection, isPathEditable);
|
||||||
initializeNameField(isSingleSelection, isPathEditable);
|
initializeNameField(isSingleSelection, isPathEditable);
|
||||||
|
|
||||||
|
initializeFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathEditable)
|
void ProgramEditDialog::initializePathField(bool isSingleSelection, bool isPathEditable)
|
||||||
@ -160,11 +164,11 @@ void ProgramEditDialog::initializeNameField(bool isSingleSelection, bool isPathE
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramEditDialog::activate()
|
void ProgramEditDialog::initializeFocus()
|
||||||
{
|
{
|
||||||
WidgetWindow::showWidget(this);
|
if (!isEmpty()) {
|
||||||
|
m_rbAllowApp->setFocus();
|
||||||
if (isWildcard()) {
|
} else if (isWildcard()) {
|
||||||
m_editWildcard->setFocus();
|
m_editWildcard->setFocus();
|
||||||
} else {
|
} else {
|
||||||
m_editPath->selectAll();
|
m_editPath->selectAll();
|
||||||
@ -199,22 +203,22 @@ void ProgramEditDialog::retranslateUi()
|
|||||||
m_btGetName->setToolTip(tr("Get Program Name"));
|
m_btGetName->setToolTip(tr("Get Program Name"));
|
||||||
|
|
||||||
m_editNotes->setPlaceholderText(tr("Notes"));
|
m_editNotes->setPlaceholderText(tr("Notes"));
|
||||||
|
|
||||||
m_labelAppGroup->setText(tr("Application Group:"));
|
m_labelAppGroup->setText(tr("Application Group:"));
|
||||||
|
|
||||||
|
m_rbAllowApp->setText(tr("Allow"));
|
||||||
|
m_rbBlockApp->setText(tr("Block"));
|
||||||
|
m_rbKillProcess->setText(tr("Kill Process"));
|
||||||
|
|
||||||
m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State"));
|
m_cbUseGroupPerm->setText(tr("Use Application Group's Enabled State"));
|
||||||
m_cbApplyChild->setText(tr("Apply same rules to child processes"));
|
m_cbApplyChild->setText(tr("Apply same rules to child processes"));
|
||||||
m_cbKillChild->setText(tr("Kill child processes"));
|
m_cbKillChild->setText(tr("Kill child processes"));
|
||||||
|
|
||||||
m_cbParked->setText(tr("Parked"));
|
m_cbParked->setText(tr("Parked"));
|
||||||
m_cbParked->setToolTip(tr("Don't purge as obsolete"));
|
m_cbParked->setToolTip(tr("Don't purge as obsolete"));
|
||||||
m_cbLanOnly->setText(tr("Block Internet Traffic"));
|
|
||||||
m_cbLogBlocked->setText(tr("Collect blocked connections"));
|
m_cbLogBlocked->setText(tr("Collect blocked connections"));
|
||||||
m_cbLogConn->setText(tr("Collect connection statistics"));
|
m_cbLogConn->setText(tr("Collect connection statistics"));
|
||||||
|
|
||||||
m_rbAllowApp->setText(tr("Allow"));
|
m_cbLanOnly->setText(tr("Block Internet Traffic"));
|
||||||
m_rbBlockApp->setText(tr("Block"));
|
|
||||||
m_rbKillProcess->setText(tr("Kill Process"));
|
|
||||||
|
|
||||||
m_btZones->retranslateUi();
|
m_btZones->retranslateUi();
|
||||||
|
|
||||||
m_cbSchedule->setText(tr("Schedule"));
|
m_cbSchedule->setText(tr("Schedule"));
|
||||||
@ -286,14 +290,14 @@ void ProgramEditDialog::setupUi()
|
|||||||
// Form Layout
|
// Form Layout
|
||||||
auto appLayout = setupAppLayout();
|
auto appLayout = setupAppLayout();
|
||||||
|
|
||||||
// Log
|
|
||||||
auto logLayout = setupLogLayout();
|
|
||||||
|
|
||||||
// Allow/Block/etc Actions Layout
|
// Allow/Block/etc Actions Layout
|
||||||
auto actionsLayout = setupActionsLayout();
|
auto actionsLayout = setupActionsLayout();
|
||||||
|
|
||||||
// Options
|
// Advanced Options
|
||||||
auto optionsLayout = setupOptionsLayout();
|
setupFrameAdvanced();
|
||||||
|
|
||||||
|
// Schedule
|
||||||
|
auto scheduleLayout = setupScheduleLayout();
|
||||||
|
|
||||||
// OK/Cancel
|
// OK/Cancel
|
||||||
auto buttonsLayout = setupButtonsLayout();
|
auto buttonsLayout = setupButtonsLayout();
|
||||||
@ -302,12 +306,12 @@ void ProgramEditDialog::setupUi()
|
|||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
layout->addLayout(appLayout);
|
layout->addLayout(appLayout);
|
||||||
layout->addWidget(ControlUtil::createSeparator());
|
layout->addWidget(ControlUtil::createSeparator());
|
||||||
layout->addLayout(logLayout);
|
|
||||||
layout->addWidget(ControlUtil::createSeparator());
|
|
||||||
layout->addLayout(actionsLayout);
|
layout->addLayout(actionsLayout);
|
||||||
layout->addWidget(ControlUtil::createSeparator());
|
|
||||||
layout->addLayout(optionsLayout);
|
|
||||||
layout->addStretch();
|
layout->addStretch();
|
||||||
|
layout->addWidget(m_frameAdvanced);
|
||||||
|
layout->addStretch();
|
||||||
|
layout->addWidget(ControlUtil::createSeparator());
|
||||||
|
layout->addLayout(scheduleLayout);
|
||||||
layout->addWidget(ControlUtil::createSeparator());
|
layout->addWidget(ControlUtil::createSeparator());
|
||||||
layout->addLayout(buttonsLayout);
|
layout->addLayout(buttonsLayout);
|
||||||
|
|
||||||
@ -353,22 +357,6 @@ QLayout *ProgramEditDialog::setupAppLayout()
|
|||||||
layout->addRow("Application Group:", m_comboAppGroup);
|
layout->addRow("Application Group:", m_comboAppGroup);
|
||||||
m_labelAppGroup = qobject_cast<QLabel *>(layout->labelForField(m_comboAppGroup));
|
m_labelAppGroup = qobject_cast<QLabel *>(layout->labelForField(m_comboAppGroup));
|
||||||
|
|
||||||
// Use Group Perm.
|
|
||||||
m_cbUseGroupPerm = new QCheckBox();
|
|
||||||
|
|
||||||
layout->addRow(QString(), m_cbUseGroupPerm);
|
|
||||||
|
|
||||||
// Apply Child
|
|
||||||
m_cbApplyChild = new QCheckBox();
|
|
||||||
|
|
||||||
layout->addRow(QString(), m_cbApplyChild);
|
|
||||||
|
|
||||||
// Kill Child
|
|
||||||
m_cbKillChild = new QCheckBox();
|
|
||||||
connect(m_cbKillChild, &QCheckBox::clicked, this, &ProgramEditDialog::warnDangerousOption);
|
|
||||||
|
|
||||||
layout->addRow(QString(), m_cbKillChild);
|
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,24 +433,6 @@ void ProgramEditDialog::setupComboAppGroups()
|
|||||||
connect(confManager(), &ConfManager::confChanged, this, refreshComboAppGroups);
|
connect(confManager(), &ConfManager::confChanged, this, refreshComboAppGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout *ProgramEditDialog::setupLogLayout()
|
|
||||||
{
|
|
||||||
// Parked
|
|
||||||
m_cbParked = new QCheckBox();
|
|
||||||
|
|
||||||
// Log Blocked
|
|
||||||
m_cbLogBlocked = new QCheckBox();
|
|
||||||
|
|
||||||
// Log Conn
|
|
||||||
m_cbLogConn = new QCheckBox();
|
|
||||||
m_cbLogConn->setVisible(false); // TODO: Collect allowed connections
|
|
||||||
|
|
||||||
auto layout = ControlUtil::createHLayoutByWidgets({ m_cbParked, ControlUtil::createVSeparator(),
|
|
||||||
m_cbLogBlocked, m_cbLogConn, /*stretch*/ nullptr });
|
|
||||||
|
|
||||||
return layout;
|
|
||||||
}
|
|
||||||
|
|
||||||
QLayout *ProgramEditDialog::setupActionsLayout()
|
QLayout *ProgramEditDialog::setupActionsLayout()
|
||||||
{
|
{
|
||||||
m_rbAllowApp = new QRadioButton();
|
m_rbAllowApp = new QRadioButton();
|
||||||
@ -484,17 +454,63 @@ QLayout *ProgramEditDialog::setupActionsLayout()
|
|||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout *ProgramEditDialog::setupOptionsLayout()
|
void ProgramEditDialog::setupFrameAdvanced()
|
||||||
{
|
{
|
||||||
|
// Use Group Perm.
|
||||||
|
m_cbUseGroupPerm = new QCheckBox();
|
||||||
|
|
||||||
|
// Child Options
|
||||||
|
auto childLayout = setupChildLayout();
|
||||||
|
|
||||||
|
// Log
|
||||||
|
auto logLayout = setupLogLayout();
|
||||||
|
|
||||||
// Zones
|
// Zones
|
||||||
auto zonesLayout = setupZonesLayout();
|
auto zonesLayout = setupZonesLayout();
|
||||||
|
|
||||||
// Schedule
|
|
||||||
auto scheduleLayout = setupScheduleLayout();
|
|
||||||
|
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->addWidget(ControlUtil::createHSeparator());
|
||||||
|
layout->addWidget(m_cbUseGroupPerm);
|
||||||
|
layout->addLayout(childLayout);
|
||||||
|
layout->addWidget(ControlUtil::createHSeparator());
|
||||||
|
layout->addLayout(logLayout);
|
||||||
|
layout->addWidget(ControlUtil::createHSeparator());
|
||||||
layout->addLayout(zonesLayout);
|
layout->addLayout(zonesLayout);
|
||||||
layout->addLayout(scheduleLayout);
|
|
||||||
|
m_frameAdvanced = new QFrame();
|
||||||
|
m_frameAdvanced->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
QLayout *ProgramEditDialog::setupChildLayout()
|
||||||
|
{
|
||||||
|
// Apply Child
|
||||||
|
m_cbApplyChild = new QCheckBox();
|
||||||
|
|
||||||
|
// Kill Child
|
||||||
|
m_cbKillChild = new QCheckBox();
|
||||||
|
connect(m_cbKillChild, &QCheckBox::clicked, this, &ProgramEditDialog::warnDangerousOption);
|
||||||
|
|
||||||
|
auto layout = ControlUtil::createHLayoutByWidgets(
|
||||||
|
{ m_cbApplyChild, ControlUtil::createVSeparator(), m_cbKillChild });
|
||||||
|
|
||||||
|
return layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLayout *ProgramEditDialog::setupLogLayout()
|
||||||
|
{
|
||||||
|
// Parked
|
||||||
|
m_cbParked = new QCheckBox();
|
||||||
|
|
||||||
|
// Log Blocked
|
||||||
|
m_cbLogBlocked = new QCheckBox();
|
||||||
|
|
||||||
|
// Log Conn
|
||||||
|
m_cbLogConn = new QCheckBox();
|
||||||
|
m_cbLogConn->setVisible(false); // TODO: Collect allowed connections
|
||||||
|
|
||||||
|
auto layout = ControlUtil::createHLayoutByWidgets({ m_cbParked, ControlUtil::createVSeparator(),
|
||||||
|
m_cbLogBlocked, m_cbLogConn, /*stretch*/ nullptr });
|
||||||
|
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
@ -597,8 +613,10 @@ void ProgramEditDialog::setupAdvancedMode()
|
|||||||
m_btAdvancedMode->setCheckable(true);
|
m_btAdvancedMode->setCheckable(true);
|
||||||
m_btAdvancedMode->setChecked(true);
|
m_btAdvancedMode->setChecked(true);
|
||||||
|
|
||||||
connect(m_btAdvancedMode, &QToolButton::toggled, this,
|
connect(m_btAdvancedMode, &QToolButton::toggled, this, [&](bool checked) {
|
||||||
[&](bool checked) { m_rbKillProcess->setVisible(checked); });
|
m_rbKillProcess->setVisible(checked);
|
||||||
|
m_frameAdvanced->setVisible(checked);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProgramEditDialog::fillEditName()
|
void ProgramEditDialog::fillEditName()
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||||
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
||||||
QT_FORWARD_DECLARE_CLASS(QDateTimeEdit)
|
QT_FORWARD_DECLARE_CLASS(QDateTimeEdit)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QFrame)
|
||||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||||
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
QT_FORWARD_DECLARE_CLASS(QLineEdit)
|
||||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||||
@ -43,8 +44,6 @@ public:
|
|||||||
|
|
||||||
void initialize(const AppRow &appRow, const QVector<qint64> &appIdList = {});
|
void initialize(const AppRow &appRow, const QVector<qint64> &appIdList = {});
|
||||||
|
|
||||||
void activate();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void closeOnSave();
|
virtual void closeOnSave();
|
||||||
|
|
||||||
@ -55,6 +54,8 @@ private:
|
|||||||
void initializePathField(bool isSingleSelection, bool isPathEditable);
|
void initializePathField(bool isSingleSelection, bool isPathEditable);
|
||||||
void initializeNameField(bool isSingleSelection, bool isPathEditable);
|
void initializeNameField(bool isSingleSelection, bool isPathEditable);
|
||||||
|
|
||||||
|
void initializeFocus();
|
||||||
|
|
||||||
void setupController();
|
void setupController();
|
||||||
|
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
@ -70,9 +71,10 @@ private:
|
|||||||
QLayout *setupAppNameLayout();
|
QLayout *setupAppNameLayout();
|
||||||
QLayout *setupNotesLayout();
|
QLayout *setupNotesLayout();
|
||||||
void setupComboAppGroups();
|
void setupComboAppGroups();
|
||||||
QLayout *setupLogLayout();
|
|
||||||
QLayout *setupActionsLayout();
|
QLayout *setupActionsLayout();
|
||||||
QLayout *setupOptionsLayout();
|
void setupFrameAdvanced();
|
||||||
|
QLayout *setupChildLayout();
|
||||||
|
QLayout *setupLogLayout();
|
||||||
QLayout *setupZonesLayout();
|
QLayout *setupZonesLayout();
|
||||||
QLayout *setupScheduleLayout();
|
QLayout *setupScheduleLayout();
|
||||||
void setupCbSchedule();
|
void setupCbSchedule();
|
||||||
@ -109,16 +111,17 @@ private:
|
|||||||
PlainTextEdit *m_editNotes = nullptr;
|
PlainTextEdit *m_editNotes = nullptr;
|
||||||
QLabel *m_labelAppGroup = nullptr;
|
QLabel *m_labelAppGroup = nullptr;
|
||||||
QComboBox *m_comboAppGroup = nullptr;
|
QComboBox *m_comboAppGroup = nullptr;
|
||||||
|
QRadioButton *m_rbAllowApp = nullptr;
|
||||||
|
QRadioButton *m_rbBlockApp = nullptr;
|
||||||
|
QRadioButton *m_rbKillProcess = nullptr;
|
||||||
|
QFrame *m_frameAdvanced = nullptr;
|
||||||
QCheckBox *m_cbUseGroupPerm = nullptr;
|
QCheckBox *m_cbUseGroupPerm = nullptr;
|
||||||
QCheckBox *m_cbApplyChild = nullptr;
|
QCheckBox *m_cbApplyChild = nullptr;
|
||||||
QCheckBox *m_cbKillChild = nullptr;
|
QCheckBox *m_cbKillChild = nullptr;
|
||||||
QCheckBox *m_cbParked = nullptr;
|
QCheckBox *m_cbParked = nullptr;
|
||||||
QCheckBox *m_cbLanOnly = nullptr;
|
|
||||||
QCheckBox *m_cbLogBlocked = nullptr;
|
QCheckBox *m_cbLogBlocked = nullptr;
|
||||||
QCheckBox *m_cbLogConn = nullptr;
|
QCheckBox *m_cbLogConn = nullptr;
|
||||||
QRadioButton *m_rbAllowApp = nullptr;
|
QCheckBox *m_cbLanOnly = nullptr;
|
||||||
QRadioButton *m_rbBlockApp = nullptr;
|
|
||||||
QRadioButton *m_rbKillProcess = nullptr;
|
|
||||||
ZonesSelector *m_btZones = nullptr;
|
ZonesSelector *m_btZones = nullptr;
|
||||||
QCheckBox *m_cbSchedule = nullptr;
|
QCheckBox *m_cbSchedule = nullptr;
|
||||||
QComboBox *m_comboScheduleAction = nullptr;
|
QComboBox *m_comboScheduleAction = nullptr;
|
||||||
|
@ -452,14 +452,15 @@ void ProgramsWindow::openAppEditForm(const AppRow &appRow, const QVector<qint64>
|
|||||||
|
|
||||||
m_formAppEdit->initialize(appRow, appIdList);
|
m_formAppEdit->initialize(appRow, appIdList);
|
||||||
|
|
||||||
m_formAppEdit->activate();
|
WidgetWindow::showWidget(m_formAppEdit);
|
||||||
|
|
||||||
m_formAppEdit->centerTo(this);
|
m_formAppEdit->centerTo(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProgramsWindow::checkAppEditFormOpened() const
|
bool ProgramsWindow::checkAppEditFormOpened() const
|
||||||
{
|
{
|
||||||
if (m_formAppEdit && m_formAppEdit->isVisible()) {
|
if (m_formAppEdit && m_formAppEdit->isVisible()) {
|
||||||
m_formAppEdit->activate();
|
WidgetWindow::showWidget(m_formAppEdit);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user