mirror of
https://github.com/tnodir/fort
synced 2024-11-15 08:56:22 +00:00
UI: AppsPage: Add block & allow apps.
This commit is contained in:
parent
4b4248e23b
commit
c780e65ef8
@ -71,32 +71,15 @@ void AddressesPage::setupUi()
|
||||
|
||||
setupAddressesUseAllEnabled();
|
||||
|
||||
setupAddressGroup();
|
||||
|
||||
// Splitter
|
||||
setupSplitter();
|
||||
layout->addWidget(m_splitter, 1);
|
||||
|
||||
setupAddressGroup();
|
||||
|
||||
this->setLayout(layout);
|
||||
}
|
||||
|
||||
void AddressesPage::setupSplitter()
|
||||
{
|
||||
m_splitter = new TextArea2Splitter(ctrl());
|
||||
|
||||
m_splitter->setSettingsPropName("optWindowAddrSplit");
|
||||
|
||||
Q_ASSERT(!m_splitter->handle());
|
||||
|
||||
m_splitter->addWidget(m_includeAddresses);
|
||||
m_splitter->addWidget(m_excludeAddresses);
|
||||
|
||||
Q_ASSERT(m_splitter->handle());
|
||||
|
||||
m_splitter->handle()->setTextArea1(m_includeAddresses->editIpText());
|
||||
m_splitter->handle()->setTextArea2(m_excludeAddresses->editIpText());
|
||||
}
|
||||
|
||||
void AddressesPage::setupIncludeAddresses()
|
||||
{
|
||||
m_includeAddresses = new AddressesColumn();
|
||||
@ -173,6 +156,23 @@ void AddressesPage::retranslateAddressesPlaceholderText()
|
||||
m_excludeAddresses->editIpText()->setPlaceholderText(placeholderText);
|
||||
}
|
||||
|
||||
void AddressesPage::setupSplitter()
|
||||
{
|
||||
m_splitter = new TextArea2Splitter(ctrl());
|
||||
|
||||
m_splitter->setSettingsPropName("optWindowAddrSplit");
|
||||
|
||||
Q_ASSERT(!m_splitter->handle());
|
||||
|
||||
m_splitter->addWidget(m_includeAddresses);
|
||||
m_splitter->addWidget(m_excludeAddresses);
|
||||
|
||||
Q_ASSERT(m_splitter->handle());
|
||||
|
||||
m_splitter->handle()->setTextArea1(m_includeAddresses->editIpText());
|
||||
m_splitter->handle()->setTextArea2(m_excludeAddresses->editIpText());
|
||||
}
|
||||
|
||||
void AddressesPage::refreshGroup()
|
||||
{
|
||||
m_includeAddresses->cbUseAll()->setChecked(addressGroup()->includeAll());
|
||||
|
@ -25,11 +25,11 @@ protected slots:
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
void setupSplitter();
|
||||
void setupIncludeAddresses();
|
||||
void setupExcludeAddresses();
|
||||
void setupAddressesUseAllEnabled();
|
||||
void retranslateAddressesPlaceholderText();
|
||||
void setupSplitter();
|
||||
void refreshGroup();
|
||||
void setupAddressGroup();
|
||||
|
||||
|
@ -2,8 +2,10 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QTimeEdit>
|
||||
@ -17,7 +19,10 @@
|
||||
#include "../../controls/checktimeperiod.h"
|
||||
#include "../../controls/controlutil.h"
|
||||
#include "../../controls/tabbar.h"
|
||||
#include "../controls/textarea2splitter.h"
|
||||
#include "../controls/textarea2splitterhandle.h"
|
||||
#include "../optionscontroller.h"
|
||||
#include "apps/appscolumn.h"
|
||||
|
||||
namespace {
|
||||
|
||||
@ -61,6 +66,16 @@ void ApplicationsPage::onRetranslateUi()
|
||||
|
||||
m_cbGroupEnabled->setText(tr("Enabled"));
|
||||
m_ctpGroupPeriod->checkBox()->setText(tr("time period:"));
|
||||
|
||||
m_blockApps->labelTitle()->setText(tr("Block"));
|
||||
m_allowApps->labelTitle()->setText(tr("Allow"));
|
||||
|
||||
m_splitter->handle()->btMoveAllFrom1To2()->setToolTip(tr("Move All Lines to 'Allow'"));
|
||||
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'"));
|
||||
|
||||
retranslateAppsPlaceholderText();
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupUi()
|
||||
@ -79,9 +94,15 @@ void ApplicationsPage::setupUi()
|
||||
auto groupHeader = setupGroupHeader();
|
||||
layout->addLayout(groupHeader);
|
||||
|
||||
setupAppGroup();
|
||||
// App Columns
|
||||
setupBlockApps();
|
||||
setupAllowApps();
|
||||
|
||||
layout->addStretch();
|
||||
// Splitter
|
||||
setupSplitter();
|
||||
layout->addWidget(m_splitter, 1);
|
||||
|
||||
setupAppGroup();
|
||||
|
||||
this->setLayout(layout);
|
||||
}
|
||||
@ -423,6 +444,67 @@ void ApplicationsPage::setupGroupPeriodEnabled()
|
||||
connect(m_cbGroupEnabled, &QCheckBox::toggled, this, refreshPeriodEnabled);
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupBlockApps()
|
||||
{
|
||||
m_blockApps = new AppsColumn();
|
||||
|
||||
connect(m_blockApps->editText(), &QPlainTextEdit::textChanged, [&] {
|
||||
const auto text = m_blockApps->editText()->toPlainText();
|
||||
|
||||
if (appGroup()->blockText() == text)
|
||||
return;
|
||||
|
||||
appGroup()->setBlockText(text);
|
||||
|
||||
ctrl()->setConfEdited(true);
|
||||
});
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupAllowApps()
|
||||
{
|
||||
m_allowApps = new AppsColumn();
|
||||
|
||||
connect(m_allowApps->editText(), &QPlainTextEdit::textChanged, [&] {
|
||||
const auto text = m_allowApps->editText()->toPlainText();
|
||||
|
||||
if (appGroup()->allowText() == text)
|
||||
return;
|
||||
|
||||
appGroup()->setAllowText(text);
|
||||
|
||||
ctrl()->setConfEdited(true);
|
||||
});
|
||||
}
|
||||
|
||||
void ApplicationsPage::retranslateAppsPlaceholderText()
|
||||
{
|
||||
const auto placeholderText = tr("# Examples:") + '\n'
|
||||
+ QLatin1String(
|
||||
"System\n"
|
||||
"C:\\Program Files (x86)\\Microsoft\\Skype for Desktop\\Skype.exe\n")
|
||||
+ '\n' + tr("# All programs in the sub-path:")
|
||||
+ QLatin1String("\nC:\\Git\\**");
|
||||
|
||||
m_allowApps->editText()->setPlaceholderText(placeholderText);
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupSplitter()
|
||||
{
|
||||
m_splitter = new TextArea2Splitter(ctrl());
|
||||
|
||||
m_splitter->setSettingsPropName("optWindowAppsSplit");
|
||||
|
||||
Q_ASSERT(!m_splitter->handle());
|
||||
|
||||
m_splitter->addWidget(m_blockApps);
|
||||
m_splitter->addWidget(m_allowApps);
|
||||
|
||||
Q_ASSERT(m_splitter->handle());
|
||||
|
||||
m_splitter->handle()->setTextArea1(m_blockApps->editText());
|
||||
m_splitter->handle()->setTextArea2(m_allowApps->editText());
|
||||
}
|
||||
|
||||
void ApplicationsPage::refreshGroup()
|
||||
{
|
||||
m_cscLimitIn->checkBox()->setChecked(appGroup()->limitInEnabled());
|
||||
@ -440,6 +522,9 @@ void ApplicationsPage::refreshGroup()
|
||||
appGroup()->periodFrom()));
|
||||
m_ctpGroupPeriod->timeEdit2()->setTime(CheckTimePeriod::toTime(
|
||||
appGroup()->periodTo()));
|
||||
|
||||
m_blockApps->editText()->setPlainText(appGroup()->blockText());
|
||||
m_allowApps->editText()->setPlainText(appGroup()->allowText());
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupAppGroup()
|
||||
|
@ -4,9 +4,11 @@
|
||||
#include "basepage.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(AppGroup)
|
||||
QT_FORWARD_DECLARE_CLASS(TabBar)
|
||||
QT_FORWARD_DECLARE_CLASS(AppsColumn)
|
||||
QT_FORWARD_DECLARE_CLASS(CheckSpinCombo)
|
||||
QT_FORWARD_DECLARE_CLASS(CheckTimePeriod)
|
||||
QT_FORWARD_DECLARE_CLASS(TabBar)
|
||||
QT_FORWARD_DECLARE_CLASS(TextArea2Splitter)
|
||||
|
||||
class ApplicationsPage : public BasePage
|
||||
{
|
||||
@ -44,6 +46,10 @@ private:
|
||||
void setupGroupEnabled();
|
||||
void setupGroupPeriod();
|
||||
void setupGroupPeriodEnabled();
|
||||
void setupBlockApps();
|
||||
void setupAllowApps();
|
||||
void retranslateAppsPlaceholderText();
|
||||
void setupSplitter();
|
||||
void refreshGroup();
|
||||
void setupAppGroup();
|
||||
|
||||
@ -68,6 +74,9 @@ private:
|
||||
QCheckBox *m_cbFragmentPacket = nullptr;
|
||||
QCheckBox *m_cbGroupEnabled = nullptr;
|
||||
CheckTimePeriod *m_ctpGroupPeriod = nullptr;
|
||||
AppsColumn *m_blockApps = nullptr;
|
||||
AppsColumn *m_allowApps = nullptr;
|
||||
TextArea2Splitter *m_splitter = nullptr;
|
||||
};
|
||||
|
||||
#endif // APPLICATIONSPAGE_H
|
||||
|
@ -1,6 +1,37 @@
|
||||
#include "appscolumn.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPlainTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
AppsColumn::AppsColumn(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUi();
|
||||
}
|
||||
|
||||
void AppsColumn::setupUi()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setMargin(0);
|
||||
|
||||
// Header
|
||||
auto headerLayout = new QHBoxLayout();
|
||||
layout->addLayout(headerLayout);
|
||||
|
||||
m_labelTitle = new QLabel();
|
||||
{
|
||||
QFont font;
|
||||
font.setWeight(QFont::DemiBold);
|
||||
m_labelTitle->setFont(font);
|
||||
}
|
||||
|
||||
headerLayout->addWidget(m_labelTitle);
|
||||
headerLayout->addStretch(1);
|
||||
|
||||
// Text Area
|
||||
m_editText = new QPlainTextEdit();
|
||||
layout->addWidget(m_editText);
|
||||
|
||||
this->setLayout(layout);
|
||||
}
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
QT_FORWARD_DECLARE_CLASS(QPlainTextEdit)
|
||||
|
||||
class AppsColumn : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -10,6 +13,15 @@ class AppsColumn : public QWidget
|
||||
public:
|
||||
explicit AppsColumn(QWidget *parent = nullptr);
|
||||
|
||||
QLabel *labelTitle() const { return m_labelTitle; }
|
||||
QPlainTextEdit *editText() const { return m_editText; }
|
||||
|
||||
private:
|
||||
void setupUi();
|
||||
|
||||
private:
|
||||
QLabel *m_labelTitle = nullptr;
|
||||
QPlainTextEdit *m_editText = nullptr;
|
||||
};
|
||||
|
||||
#endif // APPSCOLUMN_H
|
||||
|
Loading…
Reference in New Issue
Block a user