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

View File

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