UI: Options: Add "Traffic Graph" tab

This commit is contained in:
Nodir Temirkhodjaev 2023-05-15 11:51:08 +03:00
parent df3bafa36c
commit ba72921b81
13 changed files with 470 additions and 349 deletions

View File

@ -71,6 +71,7 @@ SOURCES += \
form/opt/pages/addressespage.cpp \
form/opt/pages/applicationspage.cpp \
form/opt/pages/apps/appscolumn.cpp \
form/opt/pages/graphpage.cpp \
form/opt/pages/optbasepage.cpp \
form/opt/pages/optionspage.cpp \
form/opt/pages/optmainpage.cpp \
@ -258,6 +259,7 @@ HEADERS += \
form/opt/pages/addressespage.h \
form/opt/pages/applicationspage.h \
form/opt/pages/apps/appscolumn.h \
form/opt/pages/graphpage.h \
form/opt/pages/optbasepage.h \
form/opt/pages/optionspage.h \
form/opt/pages/optmainpage.h \

View File

@ -26,12 +26,6 @@ HomeWindow::HomeWindow(QWidget *parent) :
setupUi();
setupController();
setupStateWatcher();
connect(this, &HomeWindow::activationChanged, this, [&](bool isActive) {
if (isActive) {
m_btMenu->showMenu();
}
});
}
ConfManager *HomeWindow::confManager() const
@ -67,6 +61,11 @@ void HomeWindow::restoreWindowState()
emit ctrl()->afterRestoreWindowState(iniUser());
}
void HomeWindow::showMenu()
{
m_btMenu->showMenu();
}
void HomeWindow::retranslateUi()
{
this->unsetLocale();

View File

@ -26,6 +26,9 @@ public:
void saveWindowState();
void restoreWindowState();
public slots:
void showMenu();
private:
void setupController();
void setupStateWatcher();

View File

@ -0,0 +1,216 @@
#include "graphpage.h"
#include <QCheckBox>
#include <QGroupBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QVBoxLayout>
#include <conf/firewallconf.h>
#include <form/controls/controlutil.h>
#include <form/controls/labelcolor.h>
#include <form/controls/labelspin.h>
#include <form/opt/optionscontroller.h>
#include <util/iconcache.h>
GraphPage::GraphPage(OptionsController *ctrl, QWidget *parent) : OptBasePage(ctrl, parent)
{
setupUi();
}
void GraphPage::onRetranslateUi()
{
m_gbGraph->setTitle(tr("Graph"));
m_cbGraphAlwaysOnTop->setText(tr("Always on top"));
m_cbGraphFrameless->setText(tr("Frameless"));
m_cbGraphClickThrough->setText(tr("Click through"));
m_cbGraphHideOnHover->setText(tr("Hide on hover"));
m_graphOpacity->label()->setText(tr("Opacity:"));
m_graphHoverOpacity->label()->setText(tr("Hover opacity:"));
m_graphMaxSeconds->label()->setText(tr("Max seconds:"));
m_graphColor->label()->setText(tr("Background:"));
m_graphColorIn->label()->setText(tr("Download:"));
m_graphColorOut->label()->setText(tr("Upload:"));
m_graphAxisColor->label()->setText(tr("Axis:"));
m_graphTickLabelColor->label()->setText(tr("Tick label:"));
m_graphLabelColor->label()->setText(tr("Label:"));
m_graphGridColor->label()->setText(tr("Grid:"));
}
void GraphPage::setupUi()
{
// Column #1
auto colLayout1 = setupColumn1();
// Column #2
auto colLayout2 = setupColumn2();
// Main layout
auto layout = new QHBoxLayout();
layout->addLayout(colLayout1);
layout->addStretch();
layout->addLayout(colLayout2);
layout->addStretch();
this->setLayout(layout);
}
QLayout *GraphPage::setupColumn1()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
// Graph Group Box
setupGraphBox();
layout->addWidget(m_gbGraph);
layout->addStretch();
return layout;
}
QLayout *GraphPage::setupColumn2()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
layout->addStretch();
return layout;
}
void GraphPage::setupGraphBox()
{
setupGraphCheckboxes();
setupGraphOptions();
setupGraphColors();
// Layout
auto colLayout1 = ControlUtil::createLayoutByWidgets({ m_cbGraphAlwaysOnTop, m_cbGraphFrameless,
m_cbGraphClickThrough, m_cbGraphHideOnHover, ControlUtil::createSeparator(),
m_graphOpacity, m_graphHoverOpacity, m_graphMaxSeconds, nullptr });
auto colLayout2 =
ControlUtil::createLayoutByWidgets({ m_graphColor, m_graphColorIn, m_graphColorOut,
m_graphAxisColor, m_graphTickLabelColor, m_graphLabelColor, m_graphGridColor });
auto layout = new QHBoxLayout();
layout->addLayout(colLayout1);
layout->addWidget(ControlUtil::createSeparator(Qt::Vertical));
layout->addLayout(colLayout2);
m_gbGraph = new QGroupBox();
m_gbGraph->setLayout(layout);
}
void GraphPage::setupGraphCheckboxes()
{
m_cbGraphAlwaysOnTop =
ControlUtil::createCheckBox(ini()->graphWindowAlwaysOnTop(), [&](bool checked) {
if (ini()->graphWindowAlwaysOnTop() != checked) {
ini()->setGraphWindowAlwaysOnTop(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphFrameless =
ControlUtil::createCheckBox(ini()->graphWindowFrameless(), [&](bool checked) {
if (ini()->graphWindowFrameless() != checked) {
ini()->setGraphWindowFrameless(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphClickThrough =
ControlUtil::createCheckBox(ini()->graphWindowClickThrough(), [&](bool checked) {
if (ini()->graphWindowClickThrough() != checked) {
ini()->setGraphWindowClickThrough(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphHideOnHover =
ControlUtil::createCheckBox(ini()->graphWindowHideOnHover(), [&](bool checked) {
if (ini()->graphWindowHideOnHover() != checked) {
ini()->setGraphWindowHideOnHover(checked);
ctrl()->setIniEdited();
}
});
}
void GraphPage::setupGraphOptions()
{
m_graphOpacity = ControlUtil::createSpin(ini()->graphWindowOpacity(), 0, 100, " %", [&](int v) {
if (ini()->graphWindowOpacity() != v) {
ini()->setGraphWindowOpacity(v);
ctrl()->setIniEdited();
}
});
m_graphHoverOpacity =
ControlUtil::createSpin(ini()->graphWindowHoverOpacity(), 0, 100, " %", [&](int v) {
if (ini()->graphWindowHoverOpacity() != v) {
ini()->setGraphWindowHoverOpacity(v);
ctrl()->setIniEdited();
}
});
m_graphMaxSeconds =
ControlUtil::createSpin(ini()->graphWindowMaxSeconds(), 0, 9999, {}, [&](int v) {
if (ini()->graphWindowMaxSeconds() != v) {
ini()->setGraphWindowMaxSeconds(v);
ctrl()->setIniEdited();
}
});
}
void GraphPage::setupGraphColors()
{
m_graphColor = ControlUtil::createLabelColor(ini()->graphWindowColor(), [&](const QColor &v) {
if (ini()->graphWindowColor() != v) {
ini()->setGraphWindowColor(v);
ctrl()->setIniEdited();
}
});
m_graphColorIn =
ControlUtil::createLabelColor(ini()->graphWindowColorIn(), [&](const QColor &v) {
if (ini()->graphWindowColorIn() != v) {
ini()->setGraphWindowColorIn(v);
ctrl()->setIniEdited();
}
});
m_graphColorOut =
ControlUtil::createLabelColor(ini()->graphWindowColorOut(), [&](const QColor &v) {
if (ini()->graphWindowColorOut() != v) {
ini()->setGraphWindowColorOut(v);
ctrl()->setIniEdited();
}
});
m_graphAxisColor =
ControlUtil::createLabelColor(ini()->graphWindowAxisColor(), [&](const QColor &v) {
if (ini()->graphWindowAxisColor() != v) {
ini()->setGraphWindowAxisColor(v);
ctrl()->setIniEdited();
}
});
m_graphTickLabelColor =
ControlUtil::createLabelColor(ini()->graphWindowTickLabelColor(), [&](const QColor &v) {
if (ini()->graphWindowTickLabelColor() != v) {
ini()->setGraphWindowTickLabelColor(v);
ctrl()->setIniEdited();
}
});
m_graphLabelColor =
ControlUtil::createLabelColor(ini()->graphWindowLabelColor(), [&](const QColor &v) {
if (ini()->graphWindowLabelColor() != v) {
ini()->setGraphWindowLabelColor(v);
ctrl()->setIniEdited();
}
});
m_graphGridColor =
ControlUtil::createLabelColor(ini()->graphWindowGridColor(), [&](const QColor &v) {
if (ini()->graphWindowGridColor() != v) {
ini()->setGraphWindowGridColor(v);
ctrl()->setIniEdited();
}
});
}

View File

@ -0,0 +1,46 @@
#ifndef GRAPHPAGE_H
#define GRAPHPAGE_H
#include "optbasepage.h"
class LabelColor;
class LabelSpin;
class GraphPage : public OptBasePage
{
Q_OBJECT
public:
explicit GraphPage(OptionsController *ctrl = nullptr, QWidget *parent = nullptr);
protected slots:
void onRetranslateUi() override;
private:
void setupUi();
QLayout *setupColumn1();
void setupGraphBox();
void setupGraphCheckboxes();
void setupGraphOptions();
void setupGraphColors();
QLayout *setupColumn2();
private:
QGroupBox *m_gbGraph = nullptr;
QCheckBox *m_cbGraphAlwaysOnTop = nullptr;
QCheckBox *m_cbGraphFrameless = nullptr;
QCheckBox *m_cbGraphClickThrough = nullptr;
QCheckBox *m_cbGraphHideOnHover = nullptr;
LabelSpin *m_graphOpacity = nullptr;
LabelSpin *m_graphHoverOpacity = nullptr;
LabelSpin *m_graphMaxSeconds = nullptr;
LabelColor *m_graphColor = nullptr;
LabelColor *m_graphColorIn = nullptr;
LabelColor *m_graphColorOut = nullptr;
LabelColor *m_graphAxisColor = nullptr;
LabelColor *m_graphTickLabelColor = nullptr;
LabelColor *m_graphLabelColor = nullptr;
LabelColor *m_graphGridColor = nullptr;
};
#endif // GRAPHPAGE_H

View File

@ -336,30 +336,10 @@ QLayout *OptionsPage::setupColumn1()
setupTrafficBox();
layout->addWidget(m_gbTraffic);
// Global Group Box
setupGlobalBox();
layout->addWidget(m_gbGlobal);
// Hot Keys Group Box
setupHotKeysBox();
layout->addWidget(m_gbHotKeys);
// Protection Group Box
setupProtectionBox();
layout->addWidget(m_gbProtection);
// Tray Group Box
setupTrayBox();
layout->addWidget(m_gbTray);
// Confirmations Group Box
setupConfirmationsBox();
layout->addWidget(m_gbConfirmations);
// Logs Group Box
setupLogsBox();
layout->addWidget(m_gbLogs);
layout->addStretch();
return layout;
@ -442,75 +422,6 @@ QLayout *OptionsPage::setupFilterModeLayout()
return ControlUtil::createRowLayout(m_labelFilterMode, m_comboFilterMode);
}
void OptionsPage::setupGlobalBox()
{
m_cbExplorerMenu = ControlUtil::createCheckBox(ini()->explorerIntegrated(), [&](bool checked) {
ini()->setExplorerIntegrated(checked);
ctrl()->setIniEdited();
});
m_cbExplorerMenu->setEnabled(settings()->hasMasterAdmin());
// Language Row
auto langLayout = setupLangLayout();
auto layout = new QVBoxLayout();
layout->addWidget(m_cbExplorerMenu);
layout->addLayout(langLayout);
m_gbGlobal = new QGroupBox();
m_gbGlobal->setLayout(layout);
}
void OptionsPage::setupHotKeysBox()
{
m_cbHotKeysEnabled = ControlUtil::createCheckBox(iniUser()->hotKeyEnabled(), [&](bool checked) {
iniUser()->setHotKeyEnabled(checked);
ctrl()->setIniUserEdited(true);
});
m_cbHotKeysGlobal = ControlUtil::createCheckBox(iniUser()->hotKeyGlobal(), [&](bool checked) {
iniUser()->setHotKeyGlobal(checked);
ctrl()->setIniUserEdited(true);
});
auto layout = new QVBoxLayout();
layout->addWidget(m_cbHotKeysEnabled);
layout->addWidget(m_cbHotKeysGlobal);
m_gbHotKeys = new QGroupBox();
m_gbHotKeys->setLayout(layout);
}
QLayout *OptionsPage::setupLangLayout()
{
m_labelLanguage = ControlUtil::createLabel();
setupComboLanguage();
return ControlUtil::createRowLayout(m_labelLanguage, m_comboLanguage);
}
void OptionsPage::setupComboLanguage()
{
m_comboLanguage =
ControlUtil::createComboBox(translationManager()->displayLabels(), [&](int index) {
if (translationManager()->switchLanguage(index)) {
setLanguageEdited(true);
iniUser()->setLanguage(translationManager()->localeName());
ctrl()->setIniUserEdited();
}
});
m_comboLanguage->setFixedWidth(200);
const auto refreshComboLanguage = [&] {
m_comboLanguage->setCurrentIndex(translationManager()->language());
};
refreshComboLanguage();
connect(translationManager(), &TranslationManager::languageChanged, this, refreshComboLanguage);
}
void OptionsPage::setupProtectionBox()
{
m_cbBootFilter = ControlUtil::createCheckBox(conf()->bootFilter(), [&](bool checked) {
@ -610,6 +521,105 @@ void OptionsPage::setupPasswordLock()
connect(settings(), &FortSettings::passwordCheckedChanged, this, refreshPasswordLock);
}
QLayout *OptionsPage::setupColumn2()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
// Global Group Box
setupGlobalBox();
layout->addWidget(m_gbGlobal);
// Hot Keys Group Box
setupHotKeysBox();
layout->addWidget(m_gbHotKeys);
// Tray Group Box
setupTrayBox();
layout->addWidget(m_gbTray);
// Confirmations Group Box
setupConfirmationsBox();
layout->addWidget(m_gbConfirmations);
// Logs Group Box
setupLogsBox();
layout->addWidget(m_gbLogs);
layout->addStretch();
return layout;
}
void OptionsPage::setupGlobalBox()
{
m_cbExplorerMenu = ControlUtil::createCheckBox(ini()->explorerIntegrated(), [&](bool checked) {
ini()->setExplorerIntegrated(checked);
ctrl()->setIniEdited();
});
m_cbExplorerMenu->setEnabled(settings()->hasMasterAdmin());
// Language Row
auto langLayout = setupLangLayout();
auto layout = new QVBoxLayout();
layout->addWidget(m_cbExplorerMenu);
layout->addLayout(langLayout);
m_gbGlobal = new QGroupBox();
m_gbGlobal->setLayout(layout);
}
QLayout *OptionsPage::setupLangLayout()
{
m_labelLanguage = ControlUtil::createLabel();
setupComboLanguage();
return ControlUtil::createRowLayout(m_labelLanguage, m_comboLanguage);
}
void OptionsPage::setupComboLanguage()
{
m_comboLanguage =
ControlUtil::createComboBox(translationManager()->displayLabels(), [&](int index) {
if (translationManager()->switchLanguage(index)) {
setLanguageEdited(true);
iniUser()->setLanguage(translationManager()->localeName());
ctrl()->setIniUserEdited();
}
});
m_comboLanguage->setFixedWidth(200);
const auto refreshComboLanguage = [&] {
m_comboLanguage->setCurrentIndex(translationManager()->language());
};
refreshComboLanguage();
connect(translationManager(), &TranslationManager::languageChanged, this, refreshComboLanguage);
}
void OptionsPage::setupHotKeysBox()
{
m_cbHotKeysEnabled = ControlUtil::createCheckBox(iniUser()->hotKeyEnabled(), [&](bool checked) {
iniUser()->setHotKeyEnabled(checked);
ctrl()->setIniUserEdited(true);
});
m_cbHotKeysGlobal = ControlUtil::createCheckBox(iniUser()->hotKeyGlobal(), [&](bool checked) {
iniUser()->setHotKeyGlobal(checked);
ctrl()->setIniUserEdited(true);
});
auto layout = new QVBoxLayout();
layout->addWidget(m_cbHotKeysEnabled);
layout->addWidget(m_cbHotKeysGlobal);
m_gbHotKeys = new QGroupBox();
m_gbHotKeys->setLayout(layout);
}
void OptionsPage::setupTrayBox()
{
m_cbTrayShowIcon = ControlUtil::createCheckBox(iniUser()->trayShowIcon(), [&](bool checked) {
@ -714,13 +724,3 @@ void OptionsPage::setupLogsBox()
m_gbLogs = new QGroupBox();
m_gbLogs->setLayout(layout);
}
QLayout *OptionsPage::setupColumn2()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
layout->addStretch();
return layout;
}

View File

@ -40,21 +40,21 @@ private:
QLayout *setupStartModeLayout();
void setupTrafficBox();
QLayout *setupFilterModeLayout();
void setupGlobalBox();
void setupHotKeysBox();
QLayout *setupLangLayout();
void setupComboLanguage();
void setupProtectionBox();
QLayout *setupPasswordLayout();
void setupEditPassword();
void setupPasswordLock();
QLayout *setupColumn2();
void setupGlobalBox();
QLayout *setupLangLayout();
void setupComboLanguage();
void setupHotKeysBox();
void setupTrayBox();
void refreshComboTrayAction();
QLayout *setupTrayEventLayout();
QLayout *setupTrayActionLayout();
void setupConfirmationsBox();
void setupLogsBox();
QLayout *setupColumn2();
private:
bool m_passwordEdited : 1;
@ -64,9 +64,9 @@ private:
QGroupBox *m_gbStartup = nullptr;
QGroupBox *m_gbTraffic = nullptr;
QGroupBox *m_gbProtection = nullptr;
QGroupBox *m_gbGlobal = nullptr;
QGroupBox *m_gbHotKeys = nullptr;
QGroupBox *m_gbProtection = nullptr;
QGroupBox *m_gbTray = nullptr;
QGroupBox *m_gbConfirmations = nullptr;
QGroupBox *m_gbLogs = nullptr;
@ -78,11 +78,6 @@ private:
QCheckBox *m_cbStopInetTraffic = nullptr;
QLabel *m_labelFilterMode = nullptr;
QComboBox *m_comboFilterMode = nullptr;
QCheckBox *m_cbExplorerMenu = nullptr;
QCheckBox *m_cbHotKeysEnabled = nullptr;
QCheckBox *m_cbHotKeysGlobal = nullptr;
QLabel *m_labelLanguage = nullptr;
QComboBox *m_comboLanguage = nullptr;
QCheckBox *m_cbBootFilter = nullptr;
QCheckBox *m_cbFilterLocals = nullptr;
QCheckBox *m_cbNoServiceControl = nullptr;
@ -90,6 +85,11 @@ private:
QCheckBox *m_cbPassword = nullptr;
QLineEdit *m_editPassword = nullptr;
QToolButton *m_btPasswordLock = nullptr;
QCheckBox *m_cbExplorerMenu = nullptr;
QLabel *m_labelLanguage = nullptr;
QComboBox *m_comboLanguage = nullptr;
QCheckBox *m_cbHotKeysEnabled = nullptr;
QCheckBox *m_cbHotKeysGlobal = nullptr;
QCheckBox *m_cbTrayShowIcon = nullptr;
QCheckBox *m_cbTrayAnimateAlert = nullptr;
QLabel *m_labelTrayEvent = nullptr;

View File

@ -19,6 +19,7 @@
#include "addressespage.h"
#include "applicationspage.h"
#include "graphpage.h"
#include "optionspage.h"
#include "schedulepage.h"
#include "statisticspage.h"
@ -34,7 +35,8 @@ void OptMainPage::onRetranslateUi()
m_tabWidget->setTabText(1, tr("IP Addresses"));
m_tabWidget->setTabText(2, tr("Application Groups"));
m_tabWidget->setTabText(3, tr("Statistics"));
m_tabWidget->setTabText(4, tr("Schedule"));
m_tabWidget->setTabText(4, tr("Traffic Graph"));
m_tabWidget->setTabText(5, tr("Schedule"));
m_btLogs->setText(tr("Logs"));
m_btProfile->setText(tr("Profile"));
@ -68,9 +70,11 @@ void OptMainPage::setupTabBar()
auto addressesPage = new AddressesPage(ctrl());
auto applicationsPage = new ApplicationsPage(ctrl());
auto statisticsPage = new StatisticsPage(ctrl());
auto graphPage = new GraphPage(ctrl());
auto schedulePage = new SchedulePage(ctrl());
m_pages = { optionsPage, addressesPage, applicationsPage, statisticsPage, schedulePage };
m_pages = { optionsPage, addressesPage, applicationsPage, statisticsPage, graphPage,
schedulePage };
m_tabWidget = new QTabWidget();
m_tabWidget->addTab(ControlUtil::wrapToScrollArea(optionsPage),
@ -80,6 +84,7 @@ void OptMainPage::setupTabBar()
applicationsPage, IconCache::icon(":/icons/application_double.png"), QString());
m_tabWidget->addTab(ControlUtil::wrapToScrollArea(statisticsPage),
IconCache::icon(":/icons/chart_bar.png"), QString());
m_tabWidget->addTab(graphPage, IconCache::icon(":/icons/action_log.png"), QString());
m_tabWidget->addTab(schedulePage, IconCache::icon(":/icons/clock.png"), QString());
// Menu button

View File

@ -44,9 +44,9 @@ StatisticsPage::StatisticsPage(OptionsController *ctrl, QWidget *parent) : OptBa
void StatisticsPage::onRetranslateUi()
{
m_gbTraffic->setTitle(tr("Traffic"));
m_gbConn->setTitle(tr("Connections"));
m_gbBlockedConn->setTitle(tr("Blocked Connections"));
m_gbAllowedConn->setTitle(tr("Allowed Connections"));
m_gbProg->setTitle(tr("Programs"));
m_gbGraph->setTitle(tr("Graph"));
m_cbLogStat->setText(tr("Collect Traffic Statistics"));
m_cbLogStatNoFilter->setText(tr("Collect Traffic, when Filter Disabled"));
@ -64,11 +64,13 @@ void StatisticsPage::onRetranslateUi()
m_lscQuotaMonthMb->label()->setText(tr("Month's Quota:"));
m_cbQuotaStopInternet->setText(tr("Stop Internet traffic when quota exceeds"));
m_cbLogAllowedIp->setText(tr("Collect allowed connections"));
m_lscAllowedIpKeepCount->label()->setText(tr("Keep count for 'Allowed connections':"));
m_cbLogBlockedIp->setText(tr("Collect blocked connections"));
m_cbLogAlertedBlockedIp->setText(tr("Alerted only"));
m_lscBlockedIpKeepCount->label()->setText(tr("Keep count for 'Blocked connections':"));
m_cbLogAllowedIp->setText(tr("Collect allowed connections"));
m_lscAllowedIpKeepCount->label()->setText(tr("Keep count for 'Allowed connections':"));
m_cbLogBlocked->setText(tr("Collect New Blocked Programs"));
m_cbPurgeOnStart->setText(tr("Purge Obsolete on startup"));
@ -76,21 +78,6 @@ void StatisticsPage::onRetranslateUi()
retranslateTrafKeepMonthNames();
retranslateQuotaNames();
retranslateIpKeepCountNames();
m_cbGraphAlwaysOnTop->setText(tr("Always on top"));
m_cbGraphFrameless->setText(tr("Frameless"));
m_cbGraphClickThrough->setText(tr("Click through"));
m_cbGraphHideOnHover->setText(tr("Hide on hover"));
m_graphOpacity->label()->setText(tr("Opacity:"));
m_graphHoverOpacity->label()->setText(tr("Hover opacity:"));
m_graphMaxSeconds->label()->setText(tr("Max seconds:"));
m_graphColor->label()->setText(tr("Background:"));
m_graphColorIn->label()->setText(tr("Download:"));
m_graphColorOut->label()->setText(tr("Upload:"));
m_graphAxisColor->label()->setText(tr("Axis:"));
m_graphTickLabelColor->label()->setText(tr("Tick label:"));
m_graphLabelColor->label()->setText(tr("Label:"));
m_graphGridColor->label()->setText(tr("Grid:"));
}
void StatisticsPage::retranslateTrafKeepDayNames()
@ -164,14 +151,6 @@ QLayout *StatisticsPage::setupColumn1()
setupTrafficBox();
layout->addWidget(m_gbTraffic);
// Connections Group Box
setupConnBox();
layout->addWidget(m_gbConn);
// Programs Group Box
setupProgBox();
layout->addWidget(m_gbProg);
layout->addStretch();
return layout;
@ -322,39 +301,38 @@ void StatisticsPage::setupQuota()
});
}
void StatisticsPage::setupConnBox()
QLayout *StatisticsPage::setupColumn2()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
// Blocked Connections Group Box
setupBlockedConnBox();
layout->addWidget(m_gbBlockedConn);
// Allowed Connections Group Box
setupAllowedConnBox();
layout->addWidget(m_gbAllowedConn);
// Programs Group Box
setupProgBox();
layout->addWidget(m_gbProg);
layout->addStretch();
return layout;
}
void StatisticsPage::setupBlockedConnBox()
{
setupLogAllowedIp();
setupLogBlockedIp();
// Layout
auto layout = ControlUtil::createLayoutByWidgets({ // TODO: Collect allowed connections
// m_cbLogAllowedIp, m_lscAllowedIpKeepCount, ControlUtil::createSeparator(),
m_cbLogBlockedIp, m_cbLogAlertedBlockedIp, m_lscBlockedIpKeepCount });
auto layout = ControlUtil::createLayoutByWidgets(
{ m_cbLogBlockedIp, m_cbLogAlertedBlockedIp, m_lscBlockedIpKeepCount });
m_gbConn = new QGroupBox();
m_gbConn->setLayout(layout);
}
void StatisticsPage::setupLogAllowedIp()
{
m_cbLogAllowedIp = ControlUtil::createCheckBox(conf()->logAllowedIp(), [&](bool checked) {
if (conf()->logAllowedIp() != checked) {
conf()->setLogAllowedIp(checked);
ctrl()->setFlagsEdited();
}
});
m_cbLogAllowedIp->setFont(ControlUtil::fontDemiBold());
const auto logIpKeepCountList = SpinCombo::makeValuesList(logIpKeepCountValues);
m_lscAllowedIpKeepCount = ControlUtil::createSpinCombo(
ini()->allowedIpKeepCount(), 0, 999999999, logIpKeepCountList, {}, [&](int value) {
if (ini()->allowedIpKeepCount() != value) {
ini()->setAllowedIpKeepCount(value);
ctrl()->setIniEdited();
}
});
m_gbBlockedConn = new QGroupBox();
m_gbBlockedConn->setLayout(layout);
}
void StatisticsPage::setupLogBlockedIp()
@ -376,7 +354,7 @@ void StatisticsPage::setupLogBlockedIp()
}
});
const auto logIpKeepCountList = m_lscAllowedIpKeepCount->values();
const auto logIpKeepCountList = SpinCombo::makeValuesList(logIpKeepCountValues);
m_lscBlockedIpKeepCount = ControlUtil::createSpinCombo(
ini()->blockedIpKeepCount(), 0, 999999999, logIpKeepCountList, {}, [&](int value) {
if (ini()->blockedIpKeepCount() != value) {
@ -386,6 +364,40 @@ void StatisticsPage::setupLogBlockedIp()
});
}
void StatisticsPage::setupAllowedConnBox()
{
setupLogAllowedIp();
// Layout
auto layout = ControlUtil::createLayoutByWidgets({ m_cbLogAllowedIp, m_lscAllowedIpKeepCount });
m_gbAllowedConn = new QGroupBox();
m_gbAllowedConn->setLayout(layout);
// m_gbAllowedConn->setVisible(false); // TODO: Impl. allowed connections
}
void StatisticsPage::setupLogAllowedIp()
{
m_cbLogAllowedIp = ControlUtil::createCheckBox(conf()->logAllowedIp(), [&](bool checked) {
if (conf()->logAllowedIp() != checked) {
conf()->setLogAllowedIp(checked);
ctrl()->setFlagsEdited();
}
});
m_cbLogAllowedIp->setFont(ControlUtil::fontDemiBold());
const auto logIpKeepCountList = SpinCombo::makeValuesList(logIpKeepCountValues);
m_lscAllowedIpKeepCount = ControlUtil::createSpinCombo(
ini()->allowedIpKeepCount(), 0, 999999999, logIpKeepCountList, {}, [&](int value) {
if (ini()->allowedIpKeepCount() != value) {
ini()->setAllowedIpKeepCount(value);
ctrl()->setIniEdited();
}
});
}
void StatisticsPage::setupProgBox()
{
setupLogBlocked();
@ -419,151 +431,3 @@ void StatisticsPage::setupPurgeOnStart()
}
});
}
QLayout *StatisticsPage::setupColumn2()
{
auto layout = new QVBoxLayout();
layout->setSpacing(10);
// Graph Group Box
setupGraphBox();
layout->addWidget(m_gbGraph);
layout->addStretch();
return layout;
}
void StatisticsPage::setupGraphBox()
{
setupGraphCheckboxes();
setupGraphOptions();
setupGraphColors();
// Layout
auto colLayout1 = ControlUtil::createLayoutByWidgets({ m_cbGraphAlwaysOnTop, m_cbGraphFrameless,
m_cbGraphClickThrough, m_cbGraphHideOnHover, ControlUtil::createSeparator(),
m_graphOpacity, m_graphHoverOpacity, m_graphMaxSeconds, nullptr });
auto colLayout2 =
ControlUtil::createLayoutByWidgets({ m_graphColor, m_graphColorIn, m_graphColorOut,
m_graphAxisColor, m_graphTickLabelColor, m_graphLabelColor, m_graphGridColor });
auto layout = new QHBoxLayout();
layout->addLayout(colLayout1);
layout->addWidget(ControlUtil::createSeparator(Qt::Vertical));
layout->addLayout(colLayout2);
m_gbGraph = new QGroupBox();
m_gbGraph->setLayout(layout);
}
void StatisticsPage::setupGraphCheckboxes()
{
m_cbGraphAlwaysOnTop =
ControlUtil::createCheckBox(ini()->graphWindowAlwaysOnTop(), [&](bool checked) {
if (ini()->graphWindowAlwaysOnTop() != checked) {
ini()->setGraphWindowAlwaysOnTop(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphFrameless =
ControlUtil::createCheckBox(ini()->graphWindowFrameless(), [&](bool checked) {
if (ini()->graphWindowFrameless() != checked) {
ini()->setGraphWindowFrameless(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphClickThrough =
ControlUtil::createCheckBox(ini()->graphWindowClickThrough(), [&](bool checked) {
if (ini()->graphWindowClickThrough() != checked) {
ini()->setGraphWindowClickThrough(checked);
ctrl()->setIniEdited();
}
});
m_cbGraphHideOnHover =
ControlUtil::createCheckBox(ini()->graphWindowHideOnHover(), [&](bool checked) {
if (ini()->graphWindowHideOnHover() != checked) {
ini()->setGraphWindowHideOnHover(checked);
ctrl()->setIniEdited();
}
});
}
void StatisticsPage::setupGraphOptions()
{
m_graphOpacity = ControlUtil::createSpin(ini()->graphWindowOpacity(), 0, 100, " %", [&](int v) {
if (ini()->graphWindowOpacity() != v) {
ini()->setGraphWindowOpacity(v);
ctrl()->setIniEdited();
}
});
m_graphHoverOpacity =
ControlUtil::createSpin(ini()->graphWindowHoverOpacity(), 0, 100, " %", [&](int v) {
if (ini()->graphWindowHoverOpacity() != v) {
ini()->setGraphWindowHoverOpacity(v);
ctrl()->setIniEdited();
}
});
m_graphMaxSeconds =
ControlUtil::createSpin(ini()->graphWindowMaxSeconds(), 0, 9999, {}, [&](int v) {
if (ini()->graphWindowMaxSeconds() != v) {
ini()->setGraphWindowMaxSeconds(v);
ctrl()->setIniEdited();
}
});
}
void StatisticsPage::setupGraphColors()
{
m_graphColor = ControlUtil::createLabelColor(ini()->graphWindowColor(), [&](const QColor &v) {
if (ini()->graphWindowColor() != v) {
ini()->setGraphWindowColor(v);
ctrl()->setIniEdited();
}
});
m_graphColorIn =
ControlUtil::createLabelColor(ini()->graphWindowColorIn(), [&](const QColor &v) {
if (ini()->graphWindowColorIn() != v) {
ini()->setGraphWindowColorIn(v);
ctrl()->setIniEdited();
}
});
m_graphColorOut =
ControlUtil::createLabelColor(ini()->graphWindowColorOut(), [&](const QColor &v) {
if (ini()->graphWindowColorOut() != v) {
ini()->setGraphWindowColorOut(v);
ctrl()->setIniEdited();
}
});
m_graphAxisColor =
ControlUtil::createLabelColor(ini()->graphWindowAxisColor(), [&](const QColor &v) {
if (ini()->graphWindowAxisColor() != v) {
ini()->setGraphWindowAxisColor(v);
ctrl()->setIniEdited();
}
});
m_graphTickLabelColor =
ControlUtil::createLabelColor(ini()->graphWindowTickLabelColor(), [&](const QColor &v) {
if (ini()->graphWindowTickLabelColor() != v) {
ini()->setGraphWindowTickLabelColor(v);
ctrl()->setIniEdited();
}
});
m_graphLabelColor =
ControlUtil::createLabelColor(ini()->graphWindowLabelColor(), [&](const QColor &v) {
if (ini()->graphWindowLabelColor() != v) {
ini()->setGraphWindowLabelColor(v);
ctrl()->setIniEdited();
}
});
m_graphGridColor =
ControlUtil::createLabelColor(ini()->graphWindowGridColor(), [&](const QColor &v) {
if (ini()->graphWindowGridColor() != v) {
ini()->setGraphWindowGridColor(v);
ctrl()->setIniEdited();
}
});
}

View File

@ -4,8 +4,6 @@
#include "optbasepage.h"
class CheckTimePeriod;
class LabelColor;
class LabelSpin;
class LabelSpinCombo;
class StatisticsPage : public OptBasePage
@ -33,23 +31,20 @@ private:
void setupMonthStart();
void setupTrafKeep();
void setupQuota();
void setupConnBox();
void setupLogAllowedIp();
QLayout *setupColumn2();
void setupBlockedConnBox();
void setupLogBlockedIp();
void setupAllowedConnBox();
void setupLogAllowedIp();
void setupProgBox();
void setupLogBlocked();
void setupPurgeOnStart();
QLayout *setupColumn2();
void setupGraphBox();
void setupGraphCheckboxes();
void setupGraphOptions();
void setupGraphColors();
private:
QGroupBox *m_gbTraffic = nullptr;
QGroupBox *m_gbConn = nullptr;
QGroupBox *m_gbBlockedConn = nullptr;
QGroupBox *m_gbAllowedConn = nullptr;
QGroupBox *m_gbProg = nullptr;
QGroupBox *m_gbGraph = nullptr;
QCheckBox *m_cbLogStat = nullptr;
QCheckBox *m_cbLogStatNoFilter = nullptr;
CheckTimePeriod *m_ctpActivePeriod = nullptr;
@ -60,27 +55,13 @@ private:
LabelSpinCombo *m_lscQuotaDayMb = nullptr;
LabelSpinCombo *m_lscQuotaMonthMb = nullptr;
QCheckBox *m_cbQuotaStopInternet = nullptr;
QCheckBox *m_cbLogAllowedIp = nullptr;
LabelSpinCombo *m_lscAllowedIpKeepCount = nullptr;
QCheckBox *m_cbLogBlockedIp = nullptr;
QCheckBox *m_cbLogAlertedBlockedIp = nullptr;
LabelSpinCombo *m_lscBlockedIpKeepCount = nullptr;
QCheckBox *m_cbLogAllowedIp = nullptr;
LabelSpinCombo *m_lscAllowedIpKeepCount = nullptr;
QCheckBox *m_cbLogBlocked = nullptr;
QCheckBox *m_cbPurgeOnStart = nullptr;
QCheckBox *m_cbGraphAlwaysOnTop = nullptr;
QCheckBox *m_cbGraphFrameless = nullptr;
QCheckBox *m_cbGraphClickThrough = nullptr;
QCheckBox *m_cbGraphHideOnHover = nullptr;
LabelSpin *m_graphOpacity = nullptr;
LabelSpin *m_graphHoverOpacity = nullptr;
LabelSpin *m_graphMaxSeconds = nullptr;
LabelColor *m_graphColor = nullptr;
LabelColor *m_graphColorIn = nullptr;
LabelColor *m_graphColorOut = nullptr;
LabelColor *m_graphAxisColor = nullptr;
LabelColor *m_graphTickLabelColor = nullptr;
LabelColor *m_graphLabelColor = nullptr;
LabelColor *m_graphGridColor = nullptr;
};
#endif // STATISTICSPAGE_H

View File

@ -271,6 +271,7 @@ void WindowManager::setupHomeWindow(bool quitOnClose)
m_homeWindow->restoreWindowState();
if (quitOnClose) {
connect(m_homeWindow, &HomeWindow::activated, m_homeWindow, &HomeWindow::showMenu);
connect(m_homeWindow, &HomeWindow::aboutToClose, trayIcon(), &TrayIcon::quitProgram);
} else {
connect(m_homeWindow, &HomeWindow::aboutToClose, this, &WindowManager::closeHomeWindow);

View File

@ -77,9 +77,11 @@ bool WidgetWindow::event(QEvent *event)
switch (event->type()) {
case QEvent::WindowActivate: {
emit activationChanged(/*isActive=*/true);
emit activated();
} break;
case QEvent::WindowDeactivate: {
emit activationChanged(/*isActive=*/false);
emit deactivated();
} break;
default:
break;

View File

@ -12,6 +12,8 @@ public:
signals:
void activationChanged(bool isActive);
void activated();
void deactivated();
void positionChanged();
void sizeChanged();