mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:25:40 +00:00
UI: Move program's "Block Internet Traffic" flag
This commit is contained in:
parent
1d8333c396
commit
59bd6992cd
@ -66,8 +66,8 @@ void pageAppGroupCheckEdited(ApplicationsPage *page, AppGroup *appGroup, bool is
|
||||
}
|
||||
|
||||
void pageAppGroupSetChecked(ApplicationsPage *page,
|
||||
const std::function<void(AppGroup &appGroup, bool v)> &setBoolFunc,
|
||||
bool v, bool isFlag = false)
|
||||
const std::function<void(AppGroup &appGroup, bool v)> &setBoolFunc, bool v,
|
||||
bool isFlag = false)
|
||||
{
|
||||
AppGroup *appGroup = page->appGroup();
|
||||
|
||||
@ -77,8 +77,7 @@ void pageAppGroupSetChecked(ApplicationsPage *page,
|
||||
}
|
||||
|
||||
void pageAppGroupSetUInt16(ApplicationsPage *page,
|
||||
const std::function<void(AppGroup &appGroup, quint16 v)> &setUInt16Func,
|
||||
quint16 v)
|
||||
const std::function<void(AppGroup &appGroup, quint16 v)> &setUInt16Func, quint16 v)
|
||||
{
|
||||
AppGroup *appGroup = page->appGroup();
|
||||
|
||||
@ -88,8 +87,7 @@ void pageAppGroupSetUInt16(ApplicationsPage *page,
|
||||
}
|
||||
|
||||
void pageAppGroupSetUInt32(ApplicationsPage *page,
|
||||
const std::function<void(AppGroup &appGroup, quint32 v)> &setUInt32Func,
|
||||
quint32 v)
|
||||
const std::function<void(AppGroup &appGroup, quint32 v)> &setUInt32Func, quint32 v)
|
||||
{
|
||||
AppGroup *appGroup = page->appGroup();
|
||||
|
||||
@ -418,10 +416,9 @@ void ApplicationsPage::setupGroupOptions()
|
||||
setupGroupLimitBufferSize();
|
||||
|
||||
// Menu
|
||||
const QList<QWidget *> menuWidgets = { m_cbApplyChild, m_cbLanOnly,
|
||||
ControlUtil::createSeparator(), m_cbLogBlocked, m_cbLogConn, ControlUtil::createSeparator(),
|
||||
m_cscLimitIn, m_cscLimitOut, m_limitLatency, m_limitPacketLoss, m_limitBufferSizeIn,
|
||||
m_limitBufferSizeOut };
|
||||
const QList<QWidget *> menuWidgets = { m_cbApplyChild, ControlUtil::createSeparator(),
|
||||
m_cbLogBlocked, m_cbLogConn, ControlUtil::createSeparator(), m_cscLimitIn, m_cscLimitOut,
|
||||
m_limitLatency, m_limitPacketLoss, m_limitBufferSizeIn, m_limitBufferSizeOut };
|
||||
auto layout = ControlUtil::createLayoutByWidgets(menuWidgets);
|
||||
|
||||
auto menu = ControlUtil::createMenuByLayout(layout, this);
|
||||
@ -432,24 +429,20 @@ void ApplicationsPage::setupGroupOptions()
|
||||
|
||||
void ApplicationsPage::setupGroupOptionFlags()
|
||||
{
|
||||
m_cbApplyChild = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||
pageAppGroupSetChecked(this, &AppGroup::setApplyChild, checked);
|
||||
});
|
||||
m_cbApplyChild = ControlUtil::createCheckBox(false,
|
||||
[&](bool checked) { pageAppGroupSetChecked(this, &AppGroup::setApplyChild, checked); });
|
||||
|
||||
m_cbLanOnly = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||
pageAppGroupSetChecked(this, &AppGroup::setLanOnly, checked);
|
||||
});
|
||||
m_cbLanOnly = ControlUtil::createCheckBox(false,
|
||||
[&](bool checked) { pageAppGroupSetChecked(this, &AppGroup::setLanOnly, checked); });
|
||||
}
|
||||
|
||||
void ApplicationsPage::setupGroupLog()
|
||||
{
|
||||
m_cbLogBlocked = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||
pageAppGroupSetChecked(this, &AppGroup::setLogBlocked, checked);
|
||||
});
|
||||
m_cbLogBlocked = ControlUtil::createCheckBox(false,
|
||||
[&](bool checked) { pageAppGroupSetChecked(this, &AppGroup::setLogBlocked, checked); });
|
||||
|
||||
m_cbLogConn = ControlUtil::createCheckBox(false, [&](bool checked) {
|
||||
pageAppGroupSetChecked(this, &AppGroup::setLogConn, checked);
|
||||
});
|
||||
m_cbLogConn = ControlUtil::createCheckBox(false,
|
||||
[&](bool checked) { pageAppGroupSetChecked(this, &AppGroup::setLogConn, checked); });
|
||||
|
||||
m_cbLogConn->setVisible(false); // TODO: Collect allowed connections
|
||||
}
|
||||
@ -537,6 +530,8 @@ void ApplicationsPage::setupAllowApps()
|
||||
m_allowApps = new AppsColumn();
|
||||
m_allowApps->icon()->setPixmap(IconCache::file(":/icons/accept.png"));
|
||||
|
||||
m_allowApps->headerLayout()->addWidget(m_cbLanOnly);
|
||||
|
||||
connect(m_allowApps->editText(), &QPlainTextEdit::textChanged, this, [&] {
|
||||
const auto text = m_allowApps->editText()->toPlainText();
|
||||
|
||||
|
@ -17,9 +17,9 @@ void AppsColumn::setupUi()
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
// Header
|
||||
auto headerLayout = new QHBoxLayout();
|
||||
headerLayout->setSpacing(2);
|
||||
layout->addLayout(headerLayout);
|
||||
m_headerLayout = new QHBoxLayout();
|
||||
m_headerLayout->setSpacing(2);
|
||||
layout->addLayout(m_headerLayout);
|
||||
|
||||
m_icon = ControlUtil::createLabel();
|
||||
m_icon->setScaledContents(true);
|
||||
@ -28,8 +28,8 @@ void AppsColumn::setupUi()
|
||||
m_labelTitle = ControlUtil::createLabel();
|
||||
m_labelTitle->setFont(ControlUtil::fontDemiBold());
|
||||
|
||||
headerLayout->addWidget(m_icon);
|
||||
headerLayout->addWidget(m_labelTitle, 1);
|
||||
m_headerLayout->addWidget(m_icon);
|
||||
m_headerLayout->addWidget(m_labelTitle, 1);
|
||||
|
||||
// Text Area
|
||||
m_editText = new PlainTextEdit();
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QHBoxLayout)
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
|
||||
class PlainTextEdit;
|
||||
@ -14,6 +15,7 @@ class AppsColumn : public QWidget
|
||||
public:
|
||||
explicit AppsColumn(QWidget *parent = nullptr);
|
||||
|
||||
QHBoxLayout *headerLayout() const { return m_headerLayout; }
|
||||
QLabel *icon() const { return m_icon; }
|
||||
QLabel *labelTitle() const { return m_labelTitle; }
|
||||
PlainTextEdit *editText() const { return m_editText; }
|
||||
@ -22,6 +24,7 @@ private:
|
||||
void setupUi();
|
||||
|
||||
private:
|
||||
QHBoxLayout *m_headerLayout = nullptr;
|
||||
QLabel *m_icon = nullptr;
|
||||
QLabel *m_labelTitle = nullptr;
|
||||
PlainTextEdit *m_editText = nullptr;
|
||||
|
@ -166,11 +166,11 @@ void ProgramEditDialog::setupUi()
|
||||
// Allow/Block
|
||||
auto allowLayout = setupAllowLayout();
|
||||
|
||||
// Block at specified date & time
|
||||
auto blockAtLayout = setupCheckDateTimeEdit();
|
||||
// Extra Allow/Block Options
|
||||
auto extraLayout = setupExtraLayout();
|
||||
|
||||
// Eclusive End Time CheckBoxes Group
|
||||
setupAllowEclusiveGroup();
|
||||
// Allow/Block Connections
|
||||
setupAllowConnections();
|
||||
|
||||
// OK/Cancel
|
||||
auto buttonsLayout = new QHBoxLayout();
|
||||
@ -195,9 +195,8 @@ void ProgramEditDialog::setupUi()
|
||||
layout->addLayout(logLayout);
|
||||
layout->addWidget(ControlUtil::createSeparator());
|
||||
layout->addLayout(allowLayout);
|
||||
layout->addWidget(m_cscBlockAppIn);
|
||||
layout->addLayout(blockAtLayout);
|
||||
layout->addWidget(m_cbBlockAppNone);
|
||||
layout->addWidget(ControlUtil::createSeparator());
|
||||
layout->addLayout(extraLayout);
|
||||
layout->addStretch();
|
||||
layout->addWidget(ControlUtil::createSeparator());
|
||||
layout->addLayout(buttonsLayout);
|
||||
@ -247,11 +246,6 @@ QLayout *ProgramEditDialog::setupAppLayout()
|
||||
|
||||
layout->addRow(QString(), m_cbApplyChild);
|
||||
|
||||
// LAN Only
|
||||
m_cbLanOnly = new QCheckBox();
|
||||
|
||||
layout->addRow(QString(), m_cbLanOnly);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
@ -322,19 +316,16 @@ void ProgramEditDialog::setupComboAppGroups()
|
||||
|
||||
QLayout *ProgramEditDialog::setupLogLayout()
|
||||
{
|
||||
auto layout = new QFormLayout();
|
||||
|
||||
// Log Blocked
|
||||
m_cbLogBlocked = new QCheckBox();
|
||||
|
||||
layout->addRow(QString(), m_cbLogBlocked);
|
||||
|
||||
// Log Conn
|
||||
m_cbLogConn = new QCheckBox();
|
||||
|
||||
m_cbLogConn->setVisible(false); // TODO: Collect allowed connections
|
||||
|
||||
layout->addRow(QString(), m_cbLogConn);
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->addWidget(m_cbLogBlocked);
|
||||
layout->addWidget(m_cbLogConn);
|
||||
|
||||
return layout;
|
||||
}
|
||||
@ -358,30 +349,36 @@ QLayout *ProgramEditDialog::setupAllowLayout()
|
||||
allowLayout->addWidget(m_rbBlockApp, 1, Qt::AlignHCenter);
|
||||
allowLayout->addWidget(m_rbKillProcess, 1, Qt::AlignLeft);
|
||||
|
||||
return allowLayout;
|
||||
}
|
||||
|
||||
QLayout *ProgramEditDialog::setupExtraLayout()
|
||||
{
|
||||
// LAN Only
|
||||
m_cbLanOnly = new QCheckBox();
|
||||
|
||||
// Block after N hours
|
||||
m_cscBlockAppIn = new CheckSpinCombo();
|
||||
m_cscBlockAppIn->spinBox()->setRange(1, 24 * 30 * 12); // ~Year
|
||||
m_cscBlockAppIn->setValues(appBlockInHourValues);
|
||||
m_cscBlockAppIn->setNamesByValues();
|
||||
|
||||
// Block at specified date & time
|
||||
auto blockAtLayout = setupCheckDateTimeEdit();
|
||||
|
||||
// Allow Forever
|
||||
m_cbBlockAppNone = new QCheckBox();
|
||||
|
||||
connect(m_rbAllowApp, &QRadioButton::toggled, this, [&](bool checked) {
|
||||
m_cbBlockAppNone->setEnabled(checked);
|
||||
m_cscBlockAppIn->setEnabled(checked);
|
||||
m_cbBlockAppAt->setEnabled(checked);
|
||||
m_dteBlockAppAt->setEnabled(checked);
|
||||
});
|
||||
// Eclusive End Time CheckBoxes Group
|
||||
setupAllowEclusiveGroup();
|
||||
|
||||
connect(m_rbKillProcess, &QRadioButton::clicked, this, [&] {
|
||||
IoC<WindowManager>()->showInfoBox(
|
||||
tr("Attention: The 'Kill Process' option is very dangerous!!!\n\n"
|
||||
"Be careful when killing a system services or other important programs!\n"
|
||||
"It can cause a Windows malfunction or totally unusable."));
|
||||
});
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->addWidget(m_cbLanOnly);
|
||||
layout->addWidget(m_cscBlockAppIn);
|
||||
layout->addLayout(blockAtLayout);
|
||||
layout->addWidget(m_cbBlockAppNone);
|
||||
|
||||
return allowLayout;
|
||||
return layout;
|
||||
}
|
||||
|
||||
QLayout *ProgramEditDialog::setupCheckDateTimeEdit()
|
||||
@ -403,6 +400,24 @@ void ProgramEditDialog::setupAllowEclusiveGroup()
|
||||
group->addButton(m_cbBlockAppNone);
|
||||
}
|
||||
|
||||
void ProgramEditDialog::setupAllowConnections()
|
||||
{
|
||||
connect(m_rbAllowApp, &QRadioButton::toggled, this, [&](bool checked) {
|
||||
m_cbLanOnly->setEnabled(checked);
|
||||
m_cbBlockAppNone->setEnabled(checked);
|
||||
m_cscBlockAppIn->setEnabled(checked);
|
||||
m_cbBlockAppAt->setEnabled(checked);
|
||||
m_dteBlockAppAt->setEnabled(checked);
|
||||
});
|
||||
|
||||
connect(m_rbKillProcess, &QRadioButton::clicked, this, [&] {
|
||||
IoC<WindowManager>()->showInfoBox(
|
||||
tr("Attention: The 'Kill Process' option is very dangerous!!!\n\n"
|
||||
"Be careful when killing a system services or other important programs!\n"
|
||||
"It can cause a Windows malfunction or totally unusable."));
|
||||
});
|
||||
}
|
||||
|
||||
bool ProgramEditDialog::save()
|
||||
{
|
||||
const int appIdsCount = m_appIdList.size();
|
||||
|
@ -50,8 +50,10 @@ private:
|
||||
void setupComboAppGroups();
|
||||
QLayout *setupLogLayout();
|
||||
QLayout *setupAllowLayout();
|
||||
QLayout *setupExtraLayout();
|
||||
QLayout *setupCheckDateTimeEdit();
|
||||
void setupAllowEclusiveGroup();
|
||||
void setupAllowConnections();
|
||||
|
||||
bool save();
|
||||
bool saveApp(App &app);
|
||||
|
Loading…
Reference in New Issue
Block a user