UI: RuleEditDialog: Tweak Zones layout

This commit is contained in:
Nodir Temirkhodjaev 2024-02-25 10:27:33 +03:00
parent 4a81cf3885
commit 3dbf4138bb
2 changed files with 8 additions and 14 deletions

View File

@ -83,7 +83,6 @@ void RuleEditDialog::retranslateUi()
m_cbExclusive->setText(tr("Exclusive"));
m_btZones->retranslateUi();
m_btOptions->setToolTip(tr("Advanced Options"));
m_btOk->setText(tr("OK"));
m_btCancel->setText(tr("Cancel"));
@ -121,7 +120,7 @@ QLayout *RuleEditDialog::setupMainLayout()
m_editRuleText = new PlainTextEdit();
// Advanced Options
setupAdvancedOptions();
auto zonesLayout = setupZonesLayout();
// OK/Cancel
auto buttonsLayout = setupButtons();
@ -132,6 +131,7 @@ QLayout *RuleEditDialog::setupMainLayout()
layout->addStretch();
layout->addLayout(actionsLayout);
layout->addWidget(ControlUtil::createHSeparator());
layout->addLayout(zonesLayout);
layout->addWidget(m_editRuleText);
layout->addStretch();
layout->addWidget(ControlUtil::createHSeparator());
@ -186,7 +186,7 @@ QLayout *RuleEditDialog::setupActionsLayout()
return layout;
}
void RuleEditDialog::setupAdvancedOptions()
QLayout *RuleEditDialog::setupZonesLayout()
{
// Exclusive
m_cbExclusive = new QCheckBox();
@ -196,16 +196,10 @@ void RuleEditDialog::setupAdvancedOptions()
m_btZones->setIsTristate(true);
m_btZones->setMaxZoneCount(16); // sync with driver's FORT_APP_ENTRY
auto layout = new QVBoxLayout();
layout->addWidget(m_cbExclusive);
layout->addWidget(ControlUtil::createHSeparator());
layout->addWidget(m_btZones);
auto layout = ControlUtil::createHLayoutByWidgets(
{ m_cbExclusive, ControlUtil::createVSeparator(), m_btZones, /*stretch*/ nullptr });
auto menu = ControlUtil::createMenuByLayout(layout, this);
m_btOptions = ControlUtil::createButton(":/icons/widgets.png");
m_btOptions->setShortcut(QKeyCombination(Qt::CTRL, Qt::Key_O));
m_btOptions->setMenu(menu);
return layout;
}
QLayout *RuleEditDialog::setupButtons()
@ -223,7 +217,6 @@ QLayout *RuleEditDialog::setupButtons()
connect(m_btCancel, &QAbstractButton::clicked, this, &QWidget::close);
auto layout = new QHBoxLayout();
layout->addWidget(m_btOptions);
layout->addWidget(m_btOk, 1, Qt::AlignRight);
layout->addWidget(m_btCancel);

View File

@ -42,6 +42,7 @@ private:
QLayout *setupMainLayout();
QLayout *setupFormLayout();
QLayout *setupActionsLayout();
QLayout *setupZonesLayout();
void setupAdvancedOptions();
QLayout *setupButtons();
@ -61,9 +62,9 @@ private:
QCheckBox *m_cbEnabled = nullptr;
QRadioButton *m_rbAllow = nullptr;
QRadioButton *m_rbBlock = nullptr;
PlainTextEdit *m_editRuleText = nullptr;
QCheckBox *m_cbExclusive = nullptr;
ZonesSelector *m_btZones = nullptr;
PlainTextEdit *m_editRuleText = nullptr;
QPushButton *m_btOptions = nullptr;
QPushButton *m_btOk = nullptr;
QPushButton *m_btCancel = nullptr;