diff --git a/src/ui/form/controls/checkspincombo.cpp b/src/ui/form/controls/checkspincombo.cpp index aaa2fe4c..cd9ad84b 100644 --- a/src/ui/form/controls/checkspincombo.cpp +++ b/src/ui/form/controls/checkspincombo.cpp @@ -30,6 +30,7 @@ void CheckSpinCombo::setNames(const QStringList &v) void CheckSpinCombo::setupUi() { auto layout = new QHBoxLayout(); + layout->setMargin(0); m_checkBox = new QCheckBox(); diff --git a/src/ui/form/controls/controlutil.cpp b/src/ui/form/controls/controlutil.cpp index fa6b990a..876ff924 100644 --- a/src/ui/form/controls/controlutil.cpp +++ b/src/ui/form/controls/controlutil.cpp @@ -2,8 +2,11 @@ #include #include +#include #include #include +#include +#include QCheckBox *ControlUtil::createCheckBox(bool checked, const std::function &onToggled) @@ -57,3 +60,30 @@ QPushButton *ControlUtil::createLinkButton(const QString &iconPath, c->setToolTip(!toolTip.isEmpty() ? toolTip : linkPath); return c; } + +QMenu *ControlUtil::createMenuByWidgets(const QList &widgets, + QWidget *parent) +{ + auto menu = new QMenu(parent); + + auto layout = new QVBoxLayout(); + for (auto w : widgets) { + layout->addWidget(w); + } + + auto menuWidget = new QWidget(); + menuWidget->setLayout(layout); + + auto wa = new QWidgetAction(menu); + wa->setDefaultWidget(menuWidget); + menu->addAction(wa); + + return menu; +} + +QFrame *ControlUtil::createHSeparator() +{ + auto c = new QFrame(); + c->setFrameShape(QFrame::HLine); + return c; +} diff --git a/src/ui/form/controls/controlutil.h b/src/ui/form/controls/controlutil.h index 11e69f84..10eb4acc 100644 --- a/src/ui/form/controls/controlutil.h +++ b/src/ui/form/controls/controlutil.h @@ -7,6 +7,8 @@ QT_FORWARD_DECLARE_CLASS(QCheckBox) QT_FORWARD_DECLARE_CLASS(QComboBox) +QT_FORWARD_DECLARE_CLASS(QFrame) +QT_FORWARD_DECLARE_CLASS(QMenu) QT_FORWARD_DECLARE_CLASS(QPushButton) QT_FORWARD_DECLARE_CLASS(QToolButton) @@ -24,6 +26,9 @@ public: static QPushButton *createLinkButton(const QString &iconPath, const QString &linkPath = QString(), const QString &toolTip = QString()); + static QMenu *createMenuByWidgets(const QList &widgets, + QWidget *parent); + static QFrame *createHSeparator(); }; #endif // CONTROLUTIL_H diff --git a/src/ui/form/opt/pages/applicationspage.cpp b/src/ui/form/opt/pages/applicationspage.cpp index a28d2b2c..e179589c 100644 --- a/src/ui/form/opt/pages/applicationspage.cpp +++ b/src/ui/form/opt/pages/applicationspage.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include "../../../conf/appgroup.h" #include "../../../conf/firewallconf.h" @@ -74,6 +73,7 @@ void ApplicationsPage::onRetranslateUi() m_splitter->handle()->btMoveAllFrom2To1()->setToolTip(tr("Move All Lines to 'Block'")); m_splitter->handle()->btMoveSelectedFrom1To2()->setToolTip(tr("Move Selected Lines to 'Allow'")); m_splitter->handle()->btMoveSelectedFrom2To1()->setToolTip(tr("Move Selected Lines to 'Block'")); + m_splitter->handle()->btSelectFile()->setToolTip(tr("Select File")); retranslateAppsPlaceholderText(); } @@ -266,21 +266,13 @@ void ApplicationsPage::setupGroupOptions() setupGroupFragmentPacket(); // Menu - auto menu = new QMenu(m_btGroupOptions); - - auto waLimitIn = new QWidgetAction(this); - waLimitIn->setDefaultWidget(m_cscLimitIn); - menu->addAction(waLimitIn); - - auto waLimitOut = new QWidgetAction(this); - waLimitOut->setDefaultWidget(m_cscLimitOut); - menu->addAction(waLimitOut); - - menu->addSeparator(); - - auto waFragmentPacket = new QWidgetAction(this); - waFragmentPacket->setDefaultWidget(m_cbFragmentPacket); - menu->addAction(waFragmentPacket); + const QList menuWidgets = { + m_cscLimitIn, m_cscLimitOut, + ControlUtil::createHSeparator(), + m_cbFragmentPacket + }; + auto menu = ControlUtil::createMenuByWidgets( + menuWidgets, m_btGroupOptions); m_btGroupOptions->setMenu(menu); } @@ -492,6 +484,7 @@ void ApplicationsPage::setupSplitter() { m_splitter = new TextArea2Splitter(ctrl()); + m_splitter->setSelectFileEnabled(true); m_splitter->setSettingsPropName("optWindowAppsSplit"); Q_ASSERT(!m_splitter->handle());