UI: Options: Prepare Services page.

This commit is contained in:
Nodir Temirkhodjaev 2021-05-21 12:23:46 +03:00
parent e547ffc046
commit 71a9186bea
11 changed files with 139 additions and 15 deletions

View File

@ -56,6 +56,7 @@ SOURCES += \
form/opt/pages/optmainpage.cpp \ form/opt/pages/optmainpage.cpp \
form/opt/pages/rulespage.cpp \ form/opt/pages/rulespage.cpp \
form/opt/pages/schedulepage.cpp \ form/opt/pages/schedulepage.cpp \
form/opt/pages/servicespage.cpp \
form/opt/pages/statisticspage.cpp \ form/opt/pages/statisticspage.cpp \
form/prog/programeditdialog.cpp \ form/prog/programeditdialog.cpp \
form/prog/programscontroller.cpp \ form/prog/programscontroller.cpp \
@ -83,6 +84,7 @@ SOURCES += \
model/applistmodel.cpp \ model/applistmodel.cpp \
model/appstatmodel.cpp \ model/appstatmodel.cpp \
model/connlistmodel.cpp \ model/connlistmodel.cpp \
model/servicelistmodel.cpp \
model/traflistmodel.cpp \ model/traflistmodel.cpp \
model/zonelistmodel.cpp \ model/zonelistmodel.cpp \
model/zonesourcewrapper.cpp \ model/zonesourcewrapper.cpp \
@ -200,6 +202,7 @@ HEADERS += \
form/opt/pages/optmainpage.h \ form/opt/pages/optmainpage.h \
form/opt/pages/rulespage.h \ form/opt/pages/rulespage.h \
form/opt/pages/schedulepage.h \ form/opt/pages/schedulepage.h \
form/opt/pages/servicespage.h \
form/opt/pages/statisticspage.h \ form/opt/pages/statisticspage.h \
form/prog/programeditdialog.h \ form/prog/programeditdialog.h \
form/prog/programscontroller.h \ form/prog/programscontroller.h \
@ -228,6 +231,7 @@ HEADERS += \
model/applistmodel.h \ model/applistmodel.h \
model/appstatmodel.h \ model/appstatmodel.h \
model/connlistmodel.h \ model/connlistmodel.h \
model/servicelistmodel.h \
model/traflistmodel.h \ model/traflistmodel.h \
model/zonelistmodel.h \ model/zonelistmodel.h \
model/zonesourcewrapper.h \ model/zonesourcewrapper.h \

View File

@ -22,6 +22,7 @@ FirewallConf::FirewallConf(FortSettings *settings, QObject *parent) :
m_logBlockedIp(false), m_logBlockedIp(false),
m_appBlockAll(true), m_appBlockAll(true),
m_appAllowAll(false), m_appAllowAll(false),
m_filterServices(false),
m_activePeriodEnabled(false), m_activePeriodEnabled(false),
m_ini(settings) m_ini(settings)
{ {
@ -101,6 +102,11 @@ void FirewallConf::setAppAllowAll(bool appAllowAll)
m_appAllowAll = appAllowAll; m_appAllowAll = appAllowAll;
} }
void FirewallConf::setFilterServices(bool filterServices)
{
m_filterServices = filterServices;
}
void FirewallConf::setActivePeriodEnabled(bool activePeriodEnabled) void FirewallConf::setActivePeriodEnabled(bool activePeriodEnabled)
{ {
m_activePeriodEnabled = activePeriodEnabled; m_activePeriodEnabled = activePeriodEnabled;
@ -266,6 +272,8 @@ void FirewallConf::copyFlags(const FirewallConf &o)
m_appBlockAll = o.appBlockAll(); m_appBlockAll = o.appBlockAll();
m_appAllowAll = o.appAllowAll(); m_appAllowAll = o.appAllowAll();
m_filterServices = o.filterServices();
m_activePeriodEnabled = o.activePeriodEnabled(); m_activePeriodEnabled = o.activePeriodEnabled();
m_activePeriodFrom = o.activePeriodFrom(); m_activePeriodFrom = o.activePeriodFrom();
m_activePeriodTo = o.activePeriodTo(); m_activePeriodTo = o.activePeriodTo();
@ -312,6 +320,8 @@ QVariant FirewallConf::flagsToVariant() const
map["appBlockAll"] = appBlockAll(); map["appBlockAll"] = appBlockAll();
map["appAllowAll"] = appAllowAll(); map["appAllowAll"] = appAllowAll();
map["filterServices"] = filterServices();
map["activePeriodEnabled"] = activePeriodEnabled(); map["activePeriodEnabled"] = activePeriodEnabled();
map["activePeriodFrom"] = activePeriodFrom(); map["activePeriodFrom"] = activePeriodFrom();
map["activePeriodTo"] = activePeriodTo(); map["activePeriodTo"] = activePeriodTo();
@ -342,6 +352,8 @@ void FirewallConf::flagsFromVariant(const QVariant &v)
m_appBlockAll = map["appBlockAll"].toBool(); m_appBlockAll = map["appBlockAll"].toBool();
m_appAllowAll = map["appAllowAll"].toBool(); m_appAllowAll = map["appAllowAll"].toBool();
m_filterServices = map["filterServices"].toBool();
m_activePeriodEnabled = map["activePeriodEnabled"].toBool(); m_activePeriodEnabled = map["activePeriodEnabled"].toBool();
m_activePeriodFrom = map["activePeriodFrom"].toString(); m_activePeriodFrom = map["activePeriodFrom"].toString();
m_activePeriodTo = map["activePeriodTo"].toString(); m_activePeriodTo = map["activePeriodTo"].toString();

View File

@ -78,6 +78,9 @@ public:
bool appAllowAll() const { return m_appAllowAll; } bool appAllowAll() const { return m_appAllowAll; }
void setAppAllowAll(bool appAllowAll); void setAppAllowAll(bool appAllowAll);
bool filterServices() const { return m_filterServices; }
void setFilterServices(bool filterServices);
bool activePeriodEnabled() const { return m_activePeriodEnabled; } bool activePeriodEnabled() const { return m_activePeriodEnabled; }
void setActivePeriodEnabled(bool activePeriodEnabled); void setActivePeriodEnabled(bool activePeriodEnabled);
@ -169,6 +172,8 @@ private:
uint m_appBlockAll : 1; uint m_appBlockAll : 1;
uint m_appAllowAll : 1; uint m_appAllowAll : 1;
uint m_filterServices : 1;
uint m_activePeriodEnabled : 1; uint m_activePeriodEnabled : 1;
quint32 m_appGroupBits = 0; quint32 m_appGroupBits = 0;

View File

@ -18,6 +18,7 @@
#include "optionspage.h" #include "optionspage.h"
#include "rulespage.h" #include "rulespage.h"
#include "schedulepage.h" #include "schedulepage.h"
#include "servicespage.h"
#include "statisticspage.h" #include "statisticspage.h"
OptMainPage::OptMainPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent) OptMainPage::OptMainPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent)
@ -31,8 +32,9 @@ void OptMainPage::onRetranslateUi()
m_tabBar->setTabText(1, tr("IPv4 Addresses")); m_tabBar->setTabText(1, tr("IPv4 Addresses"));
m_tabBar->setTabText(2, tr("Network Rules")); m_tabBar->setTabText(2, tr("Network Rules"));
m_tabBar->setTabText(3, tr("Application Groups")); m_tabBar->setTabText(3, tr("Application Groups"));
m_tabBar->setTabText(4, tr("Statistics")); m_tabBar->setTabText(4, tr("Services"));
m_tabBar->setTabText(5, tr("Schedule")); m_tabBar->setTabText(5, tr("Statistics"));
m_tabBar->setTabText(6, tr("Schedule"));
m_btLogs->setText(tr("Logs")); m_btLogs->setText(tr("Logs"));
m_btProfile->setText(tr("Profile")); m_btProfile->setText(tr("Profile"));
@ -66,6 +68,7 @@ void OptMainPage::setupTabBar()
auto addressesPage = new AddressesPage(ctrl()); auto addressesPage = new AddressesPage(ctrl());
auto rulesPage = new RulesPage(ctrl()); auto rulesPage = new RulesPage(ctrl());
auto applicationsPage = new ApplicationsPage(ctrl()); auto applicationsPage = new ApplicationsPage(ctrl());
auto servicesPage = new ServicesPage(ctrl());
auto statisticsPage = new StatisticsPage(ctrl()); auto statisticsPage = new StatisticsPage(ctrl());
auto schedulePage = new SchedulePage(ctrl()); auto schedulePage = new SchedulePage(ctrl());
@ -74,11 +77,13 @@ void OptMainPage::setupTabBar()
m_tabBar->addTab(addressesPage, IconCache::icon(":/icons/map-marker.png"), QString()); m_tabBar->addTab(addressesPage, IconCache::icon(":/icons/map-marker.png"), QString());
m_tabBar->addTab(rulesPage, IconCache::icon(":/icons/task-list.png"), QString()); m_tabBar->addTab(rulesPage, IconCache::icon(":/icons/task-list.png"), QString());
m_tabBar->addTab(applicationsPage, IconCache::icon(":/icons/window.png"), QString()); m_tabBar->addTab(applicationsPage, IconCache::icon(":/icons/window.png"), QString());
m_tabBar->addTab(servicesPage, IconCache::icon(":/icons/windows-48.png"), QString());
m_tabBar->addTab(statisticsPage, IconCache::icon(":/icons/chart-bar.png"), QString()); m_tabBar->addTab(statisticsPage, IconCache::icon(":/icons/chart-bar.png"), QString());
m_tabBar->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString()); m_tabBar->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString());
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
m_tabBar->setTabVisible(2, false); // TODO: Impl. Network Rules m_tabBar->setTabVisible(2, false); // TODO: Impl. Network Rules
// m_tabBar->setTabVisible(4, false); // TODO: Impl. Services
#endif #endif
} }

View File

@ -0,0 +1,48 @@
#include "servicespage.h"
#include <QCheckBox>
#include <QHeaderView>
#include <QMenu>
#include <QPushButton>
#include <QVBoxLayout>
#include "../../../conf/firewallconf.h"
#include "../../../model/servicelistmodel.h"
#include "../../../user/iniuser.h"
#include "../../controls/controlutil.h"
#include "../../controls/tableview.h"
#include "../optionscontroller.h"
ServicesPage::ServicesPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent)
{
setupUi();
}
void ServicesPage::onRetranslateUi()
{
}
void ServicesPage::setupUi()
{
}
QLayout *ServicesPage::setupHeader()
{
return nullptr;
}
void ServicesPage::setupOptions()
{
}
void ServicesPage::setupFilterServices()
{
}
void ServicesPage::setupTableServList()
{
}
void ServicesPage::setupTableServListHeader()
{
}

View File

@ -0,0 +1,32 @@
#ifndef SERVICESPAGE_H
#define SERVICESPAGE_H
#include "optbasepage.h"
class TableView;
class ServicesPage : public OptBasePage
{
Q_OBJECT
public:
explicit ServicesPage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr);
protected slots:
void onRetranslateUi() override;
private:
void setupUi();
QLayout *setupHeader();
void setupOptions();
void setupFilterServices();
void setupTableServList();
void setupTableServListHeader();
private:
QPushButton *m_btOptions = nullptr;
QCheckBox *m_cbFilterServices = nullptr;
TableView *m_servListView = nullptr;
};
#endif // SERVICESPAGE_H

View File

@ -63,9 +63,9 @@ void ConnectionsPage::onRetranslateUi()
m_actCopy->setText(tr("Copy")); m_actCopy->setText(tr("Copy"));
m_actAddProgram->setText(tr("Add Program")); m_actAddProgram->setText(tr("Add Program"));
m_actRemoveConn->setText(tr("Remove")); m_actRemoveConn->setText(tr("Remove"));
m_actClearConns->setText(tr("Clear All")); m_actClearAll->setText(tr("Clear All"));
m_btLogOptions->setText(tr("Options")); m_btOptions->setText(tr("Options"));
m_cbAutoScroll->setText(tr("Auto scroll")); m_cbAutoScroll->setText(tr("Auto scroll"));
m_cbShowHostNames->setText(tr("Show host names")); m_cbShowHostNames->setText(tr("Show host names"));
@ -114,7 +114,7 @@ QLayout *ConnectionsPage::setupHeader()
m_actRemoveConn = editMenu->addAction(IconCache::icon(":/icons/sign-delete.png"), QString()); m_actRemoveConn = editMenu->addAction(IconCache::icon(":/icons/sign-delete.png"), QString());
m_actRemoveConn->setShortcut(Qt::Key_Delete); m_actRemoveConn->setShortcut(Qt::Key_Delete);
m_actClearConns = editMenu->addAction(IconCache::icon(":/icons/trashcan-full.png"), QString()); m_actClearAll = editMenu->addAction(IconCache::icon(":/icons/trashcan-full.png"), QString());
connect(m_actCopy, &QAction::triggered, this, connect(m_actCopy, &QAction::triggered, this,
[&] { GuiUtil::setClipboardData(m_connListView->selectedText()); }); [&] { GuiUtil::setClipboardData(m_connListView->selectedText()); });
@ -130,7 +130,7 @@ QLayout *ConnectionsPage::setupHeader()
deleteConn(m_connListView->currentRow()); deleteConn(m_connListView->currentRow());
} }
}); });
connect(m_actClearConns, &QAction::triggered, this, [&] { connect(m_actClearAll, &QAction::triggered, this, [&] {
if (fortManager()->showQuestionBox(tr("Are you sure to remove all connections?"))) { if (fortManager()->showQuestionBox(tr("Are you sure to remove all connections?"))) {
connListModel()->clear(); connListModel()->clear();
} }
@ -139,17 +139,17 @@ QLayout *ConnectionsPage::setupHeader()
m_btEdit = ControlUtil::createButton(":/icons/pencil.png"); m_btEdit = ControlUtil::createButton(":/icons/pencil.png");
m_btEdit->setMenu(editMenu); m_btEdit->setMenu(editMenu);
// Log Options // Options
setupLogOptions(); setupOptions();
layout->addWidget(m_btEdit); layout->addWidget(m_btEdit);
layout->addStretch(); layout->addStretch();
layout->addWidget(m_btLogOptions); layout->addWidget(m_btOptions);
return layout; return layout;
} }
void ConnectionsPage::setupLogOptions() void ConnectionsPage::setupOptions()
{ {
setupAutoScroll(); setupAutoScroll();
setupShowHostNames(); setupShowHostNames();
@ -160,8 +160,8 @@ void ConnectionsPage::setupLogOptions()
auto menu = ControlUtil::createMenuByLayout(layout, this); auto menu = ControlUtil::createMenuByLayout(layout, this);
m_btLogOptions = ControlUtil::createButton(":/icons/wrench.png"); m_btOptions = ControlUtil::createButton(":/icons/wrench.png");
m_btLogOptions->setMenu(menu); m_btOptions->setMenu(menu);
} }
void ConnectionsPage::setupAutoScroll() void ConnectionsPage::setupAutoScroll()

View File

@ -37,7 +37,7 @@ protected slots:
private: private:
void setupUi(); void setupUi();
QLayout *setupHeader(); QLayout *setupHeader();
void setupLogOptions(); void setupOptions();
void setupAutoScroll(); void setupAutoScroll();
void setupShowHostNames(); void setupShowHostNames();
void setupTableConnList(); void setupTableConnList();
@ -58,8 +58,8 @@ private:
QAction *m_actCopy = nullptr; QAction *m_actCopy = nullptr;
QAction *m_actAddProgram = nullptr; QAction *m_actAddProgram = nullptr;
QAction *m_actRemoveConn = nullptr; QAction *m_actRemoveConn = nullptr;
QAction *m_actClearConns = nullptr; QAction *m_actClearAll = nullptr;
QPushButton *m_btLogOptions = nullptr; QPushButton *m_btOptions = nullptr;
QCheckBox *m_cbAutoScroll = nullptr; QCheckBox *m_cbAutoScroll = nullptr;
QCheckBox *m_cbShowHostNames = nullptr; QCheckBox *m_cbShowHostNames = nullptr;
TableView *m_connListView = nullptr; TableView *m_connListView = nullptr;

View File

@ -337,6 +337,7 @@ void FortSettings::writeConfIni(const FirewallConf &conf)
setIniValue("logBlockedIp", conf.logBlockedIp()); setIniValue("logBlockedIp", conf.logBlockedIp());
setIniValue("appBlockAll", conf.appBlockAll()); setIniValue("appBlockAll", conf.appBlockAll());
setIniValue("appAllowAll", conf.appAllowAll()); setIniValue("appAllowAll", conf.appAllowAll());
setIniValue("filterServices", conf.filterServices());
setIniValue("appGroupBits", conf.appGroupBits(), DEFAULT_APP_GROUP_BITS); setIniValue("appGroupBits", conf.appGroupBits(), DEFAULT_APP_GROUP_BITS);
ini()->endGroup(); ini()->endGroup();

View File

@ -0,0 +1,3 @@
#include "servicelistmodel.h"
ServiceListModel::ServiceListModel(QObject *parent) : QObject(parent) { }

View File

@ -0,0 +1,14 @@
#ifndef SERVICELISTMODEL_H
#define SERVICELISTMODEL_H
#include <QObject>
class ServiceListModel : public QObject
{
Q_OBJECT
public:
explicit ServiceListModel(QObject *parent = nullptr);
};
#endif // SERVICELISTMODEL_H