mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:25:20 +00:00
UI: AppsPage: Add select file button; Tweak options menu.
This commit is contained in:
parent
c780e65ef8
commit
10938a8b9d
@ -30,6 +30,7 @@ void CheckSpinCombo::setNames(const QStringList &v)
|
||||
void CheckSpinCombo::setupUi()
|
||||
{
|
||||
auto layout = new QHBoxLayout();
|
||||
layout->setMargin(0);
|
||||
|
||||
m_checkBox = new QCheckBox();
|
||||
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QMenu>
|
||||
#include <QPushButton>
|
||||
#include <QToolButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidgetAction>
|
||||
|
||||
QCheckBox *ControlUtil::createCheckBox(bool checked,
|
||||
const std::function<void (bool)> &onToggled)
|
||||
@ -57,3 +60,30 @@ QPushButton *ControlUtil::createLinkButton(const QString &iconPath,
|
||||
c->setToolTip(!toolTip.isEmpty() ? toolTip : linkPath);
|
||||
return c;
|
||||
}
|
||||
|
||||
QMenu *ControlUtil::createMenuByWidgets(const QList<QWidget *> &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;
|
||||
}
|
||||
|
@ -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<QWidget *> &widgets,
|
||||
QWidget *parent);
|
||||
static QFrame *createHSeparator();
|
||||
};
|
||||
|
||||
#endif // CONTROLUTIL_H
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <QSpinBox>
|
||||
#include <QTimeEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidgetAction>
|
||||
|
||||
#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<QWidget *> 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());
|
||||
|
Loading…
Reference in New Issue
Block a user