mirror of
https://github.com/tnodir/fort
synced 2024-11-15 06:35:23 +00:00
UI: Prepare ConnectionsWindow.
This commit is contained in:
parent
13f6dd0c1c
commit
dac4eec3ec
2
src/ui/3rdparty/sqlite/sqlitestmt.h
vendored
2
src/ui/3rdparty/sqlite/sqlitestmt.h
vendored
@ -7,7 +7,7 @@
|
||||
|
||||
#include "../../util/classhelpers.h"
|
||||
|
||||
QT_FORWARD_DECLARE_STRUCT(sqlite3_stmt)
|
||||
struct sqlite3_stmt;
|
||||
|
||||
class SqliteStmt
|
||||
{
|
||||
|
@ -18,6 +18,8 @@ SOURCES += \
|
||||
control/controlworker.cpp \
|
||||
driver/drivermanager.cpp \
|
||||
driver/driverworker.cpp \
|
||||
form/conn/connectionscontroller.cpp \
|
||||
form/conn/connectionswindow.cpp \
|
||||
form/controls/checkspincombo.cpp \
|
||||
form/controls/checktimeperiod.cpp \
|
||||
form/controls/controlutil.cpp \
|
||||
@ -133,6 +135,8 @@ HEADERS += \
|
||||
control/controlworker.h \
|
||||
driver/drivermanager.h \
|
||||
driver/driverworker.h \
|
||||
form/conn/connectionscontroller.h \
|
||||
form/conn/connectionswindow.h \
|
||||
form/controls/checkspincombo.h \
|
||||
form/controls/checktimeperiod.h \
|
||||
form/controls/controlutil.h \
|
||||
|
37
src/ui/form/conn/connectionscontroller.cpp
Normal file
37
src/ui/form/conn/connectionscontroller.cpp
Normal file
@ -0,0 +1,37 @@
|
||||
#include "connectionscontroller.h"
|
||||
|
||||
#include "../../conf/confmanager.h"
|
||||
#include "../../fortmanager.h"
|
||||
#include "../../translationmanager.h"
|
||||
|
||||
ConnectionsController::ConnectionsController(FortManager *fortManager, QObject *parent) :
|
||||
QObject(parent), m_fortManager(fortManager)
|
||||
{
|
||||
connect(translationManager(), &TranslationManager::languageChanged, this,
|
||||
&ConnectionsController::retranslateUi);
|
||||
}
|
||||
|
||||
FortSettings *ConnectionsController::settings() const
|
||||
{
|
||||
return fortManager()->settings();
|
||||
}
|
||||
|
||||
ConfManager *ConnectionsController::confManager() const
|
||||
{
|
||||
return fortManager()->confManager();
|
||||
}
|
||||
|
||||
FirewallConf *ConnectionsController::conf() const
|
||||
{
|
||||
return confManager()->conf();
|
||||
}
|
||||
|
||||
ConnListModel *ConnectionsController::connListModel() const
|
||||
{
|
||||
return fortManager()->connListModel();
|
||||
}
|
||||
|
||||
TranslationManager *ConnectionsController::translationManager() const
|
||||
{
|
||||
return TranslationManager::instance();
|
||||
}
|
34
src/ui/form/conn/connectionscontroller.h
Normal file
34
src/ui/form/conn/connectionscontroller.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef CONNECTIONSCONTROLLER_H
|
||||
#define CONNECTIONSCONTROLLER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class ConfManager;
|
||||
class ConnListModel;
|
||||
class FirewallConf;
|
||||
class FortManager;
|
||||
class FortSettings;
|
||||
class TranslationManager;
|
||||
|
||||
class ConnectionsController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectionsController(FortManager *fortManager, QObject *parent = nullptr);
|
||||
|
||||
FortManager *fortManager() const { return m_fortManager; }
|
||||
FortSettings *settings() const;
|
||||
ConfManager *confManager() const;
|
||||
FirewallConf *conf() const;
|
||||
ConnListModel *connListModel() const;
|
||||
TranslationManager *translationManager() const;
|
||||
|
||||
signals:
|
||||
void retranslateUi();
|
||||
|
||||
private:
|
||||
FortManager *m_fortManager = nullptr;
|
||||
};
|
||||
|
||||
#endif // CONNECTIONSCONTROLLER_H
|
190
src/ui/form/conn/connectionswindow.cpp
Normal file
190
src/ui/form/conn/connectionswindow.cpp
Normal file
@ -0,0 +1,190 @@
|
||||
#include "connectionswindow.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QHeaderView>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "../../conf/firewallconf.h"
|
||||
#include "../../fortmanager.h"
|
||||
#include "../../fortsettings.h"
|
||||
#include "../../model/connlistmodel.h"
|
||||
#include "../../util/guiutil.h"
|
||||
#include "../../util/iconcache.h"
|
||||
#include "../controls/controlutil.h"
|
||||
#include "../controls/tableview.h"
|
||||
#include "connectionscontroller.h"
|
||||
|
||||
namespace {
|
||||
|
||||
#define CONN_LIST_HEADER_VERSION 1
|
||||
|
||||
}
|
||||
|
||||
ConnectionsWindow::ConnectionsWindow(FortManager *fortManager, QWidget *parent) :
|
||||
WidgetWindow(parent), m_ctrl(new ConnectionsController(fortManager, this))
|
||||
{
|
||||
setupUi();
|
||||
setupController();
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupController()
|
||||
{
|
||||
connect(ctrl(), &ConnectionsController::retranslateUi, this,
|
||||
&ConnectionsWindow::onRetranslateUi);
|
||||
|
||||
connect(this, &ConnectionsWindow::aboutToClose, fortManager(),
|
||||
&FortManager::closeConnectionsWindow);
|
||||
|
||||
connect(fortManager(), &FortManager::afterSaveConnWindowState, this,
|
||||
&ConnectionsWindow::onSaveWindowState);
|
||||
connect(fortManager(), &FortManager::afterRestoreConnWindowState, this,
|
||||
&ConnectionsWindow::onRestoreWindowState);
|
||||
|
||||
emit ctrl()->retranslateUi();
|
||||
}
|
||||
|
||||
void ConnectionsWindow::onSaveWindowState()
|
||||
{
|
||||
auto header = m_connListView->horizontalHeader();
|
||||
settings()->setConnListHeader(header->saveState());
|
||||
settings()->setConnListHeaderVersion(CONN_LIST_HEADER_VERSION);
|
||||
}
|
||||
|
||||
void ConnectionsWindow::onRestoreWindowState()
|
||||
{
|
||||
if (settings()->connListHeaderVersion() != CONN_LIST_HEADER_VERSION)
|
||||
return;
|
||||
|
||||
auto header = m_connListView->horizontalHeader();
|
||||
header->restoreState(settings()->connListHeader());
|
||||
}
|
||||
|
||||
void ConnectionsWindow::onRetranslateUi()
|
||||
{
|
||||
this->unsetLocale();
|
||||
|
||||
m_cbLogBlockedIp->setText(tr("Collect blocked connections"));
|
||||
|
||||
connListModel()->refresh();
|
||||
|
||||
this->setWindowTitle(tr("Connections"));
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupUi()
|
||||
{
|
||||
auto layout = new QVBoxLayout();
|
||||
layout->setContentsMargins(6, 6, 6, 6);
|
||||
|
||||
// Header
|
||||
auto header = setupHeader();
|
||||
layout->addLayout(header);
|
||||
|
||||
// Table
|
||||
setupTableConnList();
|
||||
setupTableConnListHeader();
|
||||
layout->addWidget(m_connListView, 1);
|
||||
|
||||
this->setLayout(layout);
|
||||
|
||||
// Font
|
||||
this->setFont(QFont("Tahoma", 9));
|
||||
|
||||
// Icon
|
||||
this->setWindowIcon(GuiUtil::overlayIcon(":/images/sheild-96.png", ":/icons/connect.png"));
|
||||
|
||||
// Size
|
||||
this->resize(1024, 768);
|
||||
this->setMinimumSize(500, 400);
|
||||
}
|
||||
|
||||
QLayout *ConnectionsWindow::setupHeader()
|
||||
{
|
||||
auto layout = new QHBoxLayout();
|
||||
|
||||
// Log Options
|
||||
setupLogOptions();
|
||||
|
||||
layout->addStretch();
|
||||
layout->addWidget(m_btLogOptions);
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupLogOptions()
|
||||
{
|
||||
setupLogBlockedIp();
|
||||
|
||||
// Menu
|
||||
const QList<QWidget *> menuWidgets = { /*m_cbLogBlocked,*/ ControlUtil::createSeparator(),
|
||||
m_cbLogBlockedIp };
|
||||
auto layout = ControlUtil::createLayoutByWidgets(menuWidgets);
|
||||
|
||||
auto menu = ControlUtil::createMenuByLayout(layout, this);
|
||||
|
||||
m_btLogOptions = ControlUtil::createButton(":/icons/wrench.png");
|
||||
m_btLogOptions->setMenu(menu);
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupLogBlockedIp()
|
||||
{
|
||||
m_cbLogBlockedIp = ControlUtil::createCheckBox(conf()->logBlockedIp(), [&](bool checked) {
|
||||
if (conf()->logBlockedIp() == checked)
|
||||
return;
|
||||
|
||||
conf()->setLogBlockedIp(checked);
|
||||
|
||||
fortManager()->applyConfImmediateFlags();
|
||||
});
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupTableConnList()
|
||||
{
|
||||
m_connListView = new TableView();
|
||||
m_connListView->setAlternatingRowColors(true);
|
||||
m_connListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||
m_connListView->setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||
|
||||
m_connListView->setSortingEnabled(true);
|
||||
m_connListView->setModel(connListModel());
|
||||
}
|
||||
|
||||
void ConnectionsWindow::setupTableConnListHeader()
|
||||
{
|
||||
auto header = m_connListView->horizontalHeader();
|
||||
|
||||
header->setSectionResizeMode(0, QHeaderView::Interactive);
|
||||
header->setSectionResizeMode(1, QHeaderView::Interactive);
|
||||
header->setSectionResizeMode(2, QHeaderView::Interactive);
|
||||
header->setSectionResizeMode(3, QHeaderView::Fixed);
|
||||
header->setSectionResizeMode(4, QHeaderView::Stretch);
|
||||
|
||||
header->resizeSection(0, 600);
|
||||
header->resizeSection(1, 120);
|
||||
header->resizeSection(2, 100);
|
||||
header->resizeSection(3, 30);
|
||||
|
||||
header->setSectionsClickable(true);
|
||||
header->setSortIndicatorShown(true);
|
||||
header->setSortIndicator(4, Qt::DescendingOrder);
|
||||
}
|
||||
|
||||
FortManager *ConnectionsWindow::fortManager() const
|
||||
{
|
||||
return ctrl()->fortManager();
|
||||
}
|
||||
|
||||
FortSettings *ConnectionsWindow::settings() const
|
||||
{
|
||||
return ctrl()->settings();
|
||||
}
|
||||
|
||||
FirewallConf *ConnectionsWindow::conf() const
|
||||
{
|
||||
return ctrl()->conf();
|
||||
}
|
||||
|
||||
ConnListModel *ConnectionsWindow::connListModel() const
|
||||
{
|
||||
return fortManager()->connListModel();
|
||||
}
|
53
src/ui/form/conn/connectionswindow.h
Normal file
53
src/ui/form/conn/connectionswindow.h
Normal file
@ -0,0 +1,53 @@
|
||||
#ifndef CONNECTIONSWINDOW_H
|
||||
#define CONNECTIONSWINDOW_H
|
||||
|
||||
#include "../../util/window/widgetwindow.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
|
||||
class ConnListModel;
|
||||
class ConnectionsController;
|
||||
class FirewallConf;
|
||||
class FortManager;
|
||||
class FortSettings;
|
||||
class TableView;
|
||||
|
||||
class ConnectionsWindow : public WidgetWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnectionsWindow(FortManager *fortManager, QWidget *parent = nullptr);
|
||||
|
||||
protected slots:
|
||||
void onSaveWindowState();
|
||||
void onRestoreWindowState();
|
||||
|
||||
void onRetranslateUi();
|
||||
|
||||
private:
|
||||
void setupController();
|
||||
|
||||
void setupUi();
|
||||
QLayout *setupHeader();
|
||||
void setupLogOptions();
|
||||
void setupLogBlockedIp();
|
||||
void setupTableConnList();
|
||||
void setupTableConnListHeader();
|
||||
|
||||
ConnectionsController *ctrl() const { return m_ctrl; }
|
||||
FortManager *fortManager() const;
|
||||
FortSettings *settings() const;
|
||||
FirewallConf *conf() const;
|
||||
ConnListModel *connListModel() const;
|
||||
|
||||
private:
|
||||
ConnectionsController *m_ctrl = nullptr;
|
||||
|
||||
QPushButton *m_btLogOptions = nullptr;
|
||||
QCheckBox *m_cbLogBlockedIp = nullptr;
|
||||
TableView *m_connListView = nullptr;
|
||||
};
|
||||
|
||||
#endif // CONNECTIONSWINDOW_H
|
@ -19,7 +19,6 @@
|
||||
#include "../../../conf/firewallconf.h"
|
||||
#include "../../../fortmanager.h"
|
||||
#include "../../../fortsettings.h"
|
||||
#include "../../../log/logmanager.h"
|
||||
#include "../../../model/appstatmodel.h"
|
||||
#include "../../../model/traflistmodel.h"
|
||||
#include "../../../util/app/appinfocache.h"
|
||||
@ -68,7 +67,7 @@ void StatisticsPage::setGraphEdited(bool v)
|
||||
|
||||
AppStatModel *StatisticsPage::appStatModel() const
|
||||
{
|
||||
return fortManager()->logManager()->appStatModel();
|
||||
return fortManager()->appStatModel();
|
||||
}
|
||||
|
||||
AppInfoCache *StatisticsPage::appInfoCache() const
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
#include "../../conf/confmanager.h"
|
||||
#include "../../fortmanager.h"
|
||||
#include "../../log/logmanager.h"
|
||||
#include "../../translationmanager.h"
|
||||
|
||||
ProgramsController::ProgramsController(FortManager *fortManager, QObject *parent) :
|
||||
@ -29,7 +28,7 @@ FirewallConf *ProgramsController::conf() const
|
||||
|
||||
AppListModel *ProgramsController::appListModel() const
|
||||
{
|
||||
return fortManager()->logManager()->appListModel();
|
||||
return fortManager()->appListModel();
|
||||
}
|
||||
|
||||
TranslationManager *ProgramsController::translationManager() const
|
||||
|
@ -111,7 +111,6 @@ void ProgramsWindow::onRetranslateUi()
|
||||
|
||||
m_btLogOptions->setText(tr("Options"));
|
||||
m_cbLogBlocked->setText(tr("Collect New Blocked Programs"));
|
||||
m_cbLogBlockedIp->setText(tr("Collect blocked connections"));
|
||||
|
||||
appListModel()->refresh();
|
||||
|
||||
@ -390,11 +389,9 @@ QLayout *ProgramsWindow::setupHeader()
|
||||
void ProgramsWindow::setupLogOptions()
|
||||
{
|
||||
setupLogBlocked();
|
||||
setupLogBlockedIp();
|
||||
|
||||
// Menu
|
||||
const QList<QWidget *> menuWidgets = { m_cbLogBlocked, ControlUtil::createSeparator(),
|
||||
m_cbLogBlockedIp };
|
||||
const QList<QWidget *> menuWidgets = { m_cbLogBlocked };
|
||||
auto layout = ControlUtil::createLayoutByWidgets(menuWidgets);
|
||||
|
||||
auto menu = ControlUtil::createMenuByLayout(layout, this);
|
||||
@ -417,18 +414,6 @@ void ProgramsWindow::setupLogBlocked()
|
||||
m_cbLogBlocked->setFont(ControlUtil::fontDemiBold());
|
||||
}
|
||||
|
||||
void ProgramsWindow::setupLogBlockedIp()
|
||||
{
|
||||
m_cbLogBlockedIp = ControlUtil::createCheckBox(conf()->logBlockedIp(), [&](bool checked) {
|
||||
if (conf()->logBlockedIp() == checked)
|
||||
return;
|
||||
|
||||
conf()->setLogBlockedIp(checked);
|
||||
|
||||
fortManager()->applyConfImmediateFlags();
|
||||
});
|
||||
}
|
||||
|
||||
void ProgramsWindow::setupTableApps()
|
||||
{
|
||||
m_appListView = new TableView();
|
||||
|
@ -22,8 +22,6 @@ class FortSettings;
|
||||
class ProgramsController;
|
||||
class TableView;
|
||||
|
||||
QT_FORWARD_DECLARE_STRUCT(AppRow)
|
||||
|
||||
class ProgramsWindow : public WidgetWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -49,7 +47,6 @@ private:
|
||||
QLayout *setupHeader();
|
||||
void setupLogOptions();
|
||||
void setupLogBlocked();
|
||||
void setupLogBlockedIp();
|
||||
void setupTableApps();
|
||||
void setupTableAppsHeader();
|
||||
void setupAppInfoRow();
|
||||
@ -109,7 +106,6 @@ private:
|
||||
QDialog *m_formAppEdit = nullptr;
|
||||
QPushButton *m_btLogOptions = nullptr;
|
||||
QCheckBox *m_cbLogBlocked = nullptr;
|
||||
QCheckBox *m_cbLogBlockedIp = nullptr;
|
||||
TableView *m_appListView = nullptr;
|
||||
QWidget *m_appInfoRow = nullptr;
|
||||
QPushButton *m_btAppCopyPath = nullptr;
|
||||
|
@ -17,8 +17,6 @@ class TaskManager;
|
||||
class ZoneListModel;
|
||||
class ZonesController;
|
||||
|
||||
QT_FORWARD_DECLARE_STRUCT(ZoneRow)
|
||||
|
||||
class ZonesWindow : public WidgetWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -7,6 +7,7 @@
|
||||
<file>icons/arrow-retweet.png</file>
|
||||
<file>icons/clock.png</file>
|
||||
<file>icons/cog.png</file>
|
||||
<file>icons/connect.png</file>
|
||||
<file>icons/copy.png</file>
|
||||
<file>icons/database.png</file>
|
||||
<file>icons/download.png</file>
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "conf/confmanager.h"
|
||||
#include "conf/firewallconf.h"
|
||||
#include "driver/drivermanager.h"
|
||||
#include "form/conn/connectionswindow.h"
|
||||
#include "form/graph/graphwindow.h"
|
||||
#include "form/opt/optionswindow.h"
|
||||
#include "form/prog/programswindow.h"
|
||||
@ -56,6 +57,7 @@ FortManager::FortManager(FortSettings *fortSettings, QObject *parent) :
|
||||
m_optWindowState(new WidgetWindowStateWatcher(this)),
|
||||
m_zoneWindowState(new WidgetWindowStateWatcher(this)),
|
||||
m_graphWindowState(new WidgetWindowStateWatcher(this)),
|
||||
m_connWindowState(new WidgetWindowStateWatcher(this)),
|
||||
m_settings(fortSettings),
|
||||
m_quotaManager(new QuotaManager(fortSettings, this)),
|
||||
m_statManager(new StatManager(fortSettings->statFilePath(), m_quotaManager, this)),
|
||||
@ -69,6 +71,7 @@ FortManager::FortManager(FortSettings *fortSettings, QObject *parent) :
|
||||
m_appInfoCache(new AppInfoCache(this)),
|
||||
m_appListModel(new AppListModel(m_confManager, this)),
|
||||
m_appStatModel(new AppStatModel(m_statManager, this)),
|
||||
m_connListModel(new ConnListModel(m_confManager, this)),
|
||||
m_zoneListModel(new ZoneListModel(m_confManager, this))
|
||||
{
|
||||
setupTranslationManager();
|
||||
@ -320,12 +323,22 @@ bool FortManager::setupZonesWindow()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FortManager::setupConnectionsWindow()
|
||||
{
|
||||
m_connWindow = new ConnectionsWindow(this);
|
||||
|
||||
m_connWindowState->install(m_connWindow);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FortManager::closeUi()
|
||||
{
|
||||
closeGraphWindow(true);
|
||||
closeOptionsWindow();
|
||||
closeProgramsWindow();
|
||||
closeZonesWindow();
|
||||
closeConnectionsWindow();
|
||||
}
|
||||
|
||||
void FortManager::launch()
|
||||
@ -504,6 +517,34 @@ void FortManager::updateGraphWindow()
|
||||
m_graphWindow->updateWindowFlags();
|
||||
}
|
||||
|
||||
void FortManager::showConnectionsWindow()
|
||||
{
|
||||
if (!(m_connWindow && m_connWindow->isVisible()))
|
||||
return;
|
||||
|
||||
if (!m_connWindow) {
|
||||
setupConnectionsWindow();
|
||||
restoreConnWindowState();
|
||||
}
|
||||
|
||||
m_connWindow->show();
|
||||
m_connWindow->raise();
|
||||
m_connWindow->activateWindow();
|
||||
}
|
||||
|
||||
void FortManager::closeConnectionsWindow()
|
||||
{
|
||||
if (!m_connWindow)
|
||||
return;
|
||||
|
||||
saveConnWindowState();
|
||||
|
||||
m_connWindow->hide();
|
||||
|
||||
m_connWindow->deleteLater();
|
||||
m_connWindow = nullptr;
|
||||
}
|
||||
|
||||
void FortManager::exit(int retcode)
|
||||
{
|
||||
if (!checkPassword())
|
||||
@ -720,6 +761,22 @@ void FortManager::restoreGraphWindowState()
|
||||
settings()->graphWindowMaximized());
|
||||
}
|
||||
|
||||
void FortManager::saveConnWindowState()
|
||||
{
|
||||
settings()->setConnWindowGeometry(m_connWindowState->geometry());
|
||||
settings()->setConnWindowMaximized(m_connWindowState->maximized());
|
||||
|
||||
emit afterSaveConnWindowState();
|
||||
}
|
||||
|
||||
void FortManager::restoreConnWindowState()
|
||||
{
|
||||
m_connWindowState->restore(m_connWindow, QSize(1024, 768), settings()->connWindowGeometry(),
|
||||
settings()->connWindowMaximized());
|
||||
|
||||
emit afterRestoreConnWindowState();
|
||||
}
|
||||
|
||||
void FortManager::updateTrayIcon(bool alerted)
|
||||
{
|
||||
const auto icon = alerted
|
||||
@ -769,6 +826,10 @@ void FortManager::createTrayMenu()
|
||||
this, SLOT(switchGraphWindow()), true, (m_graphWindow != nullptr));
|
||||
addHotKey(m_graphWindowAction, settings()->hotKeyGraph(), conf()->logStat());
|
||||
|
||||
m_connectionsAction = addAction(menu, IconCache::icon(":/icons/connect.png"), QString(), this,
|
||||
SLOT(showConnectionsWindow()));
|
||||
addHotKey(m_connectionsAction, settings()->hotKeyConnections(), hotKeyEnabled);
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
m_filterEnabledAction = addAction(menu, QIcon(), QString(), this, SLOT(saveTrayFlags()), true);
|
||||
@ -837,6 +898,7 @@ void FortManager::retranslateTrayMenu()
|
||||
m_optionsAction->setText(tr("Options"));
|
||||
m_zonesAction->setText(tr("Zones"));
|
||||
m_graphWindowAction->setText(tr("Traffic Graph"));
|
||||
m_connectionsAction->setText(tr("Connections"));
|
||||
|
||||
m_filterEnabledAction->setText(tr("Filter Enabled"));
|
||||
m_stopTrafficAction->setText(tr("Stop Traffic"));
|
||||
|
@ -12,6 +12,8 @@ class AppInfoCache;
|
||||
class AppListModel;
|
||||
class AppStatModel;
|
||||
class ConfManager;
|
||||
class ConnListModel;
|
||||
class ConnectionsWindow;
|
||||
class DriverManager;
|
||||
class EnvManager;
|
||||
class FirewallConf;
|
||||
@ -52,6 +54,7 @@ public:
|
||||
TaskManager *taskManager() const { return m_taskManager; }
|
||||
AppListModel *appListModel() const { return m_appListModel; }
|
||||
AppStatModel *appStatModel() const { return m_appStatModel; }
|
||||
ConnListModel *connListModel() const { return m_connListModel; }
|
||||
ZoneListModel *zoneListModel() const { return m_zoneListModel; }
|
||||
|
||||
signals:
|
||||
@ -66,6 +69,9 @@ signals:
|
||||
void afterSaveZoneWindowState();
|
||||
void afterRestoreZoneWindowState();
|
||||
|
||||
void afterSaveConnWindowState();
|
||||
void afterRestoreConnWindowState();
|
||||
|
||||
public slots:
|
||||
void installDriver();
|
||||
void removeDriver();
|
||||
@ -91,6 +97,9 @@ public slots:
|
||||
void switchGraphWindow();
|
||||
void updateGraphWindow();
|
||||
|
||||
void showConnectionsWindow();
|
||||
void closeConnectionsWindow();
|
||||
|
||||
void exit(int retcode = 0);
|
||||
|
||||
bool checkPassword();
|
||||
@ -134,6 +143,7 @@ private:
|
||||
bool setupProgramsWindow();
|
||||
bool setupOptionsWindow();
|
||||
bool setupZonesWindow();
|
||||
bool setupConnectionsWindow();
|
||||
|
||||
void closeUi();
|
||||
|
||||
@ -157,6 +167,9 @@ private:
|
||||
void saveGraphWindowState(bool visible);
|
||||
void restoreGraphWindowState();
|
||||
|
||||
void saveConnWindowState();
|
||||
void restoreConnWindowState();
|
||||
|
||||
void updateTrayIcon(bool alerted = false);
|
||||
|
||||
void updateTrayMenu(bool onlyFlags = false);
|
||||
@ -195,10 +208,14 @@ private:
|
||||
GraphWindow *m_graphWindow = nullptr;
|
||||
WidgetWindowStateWatcher *m_graphWindowState = nullptr;
|
||||
|
||||
ConnectionsWindow *m_connWindow = nullptr;
|
||||
WidgetWindowStateWatcher *m_connWindowState = nullptr;
|
||||
|
||||
QAction *m_programsAction = nullptr;
|
||||
QAction *m_optionsAction = nullptr;
|
||||
QAction *m_zonesAction = nullptr;
|
||||
QAction *m_graphWindowAction = nullptr;
|
||||
QAction *m_connectionsAction = nullptr;
|
||||
QAction *m_filterEnabledAction = nullptr;
|
||||
QAction *m_stopTrafficAction = nullptr;
|
||||
QAction *m_stopInetTrafficAction = nullptr;
|
||||
@ -220,6 +237,7 @@ private:
|
||||
|
||||
AppListModel *m_appListModel = nullptr;
|
||||
AppStatModel *m_appStatModel = nullptr;
|
||||
ConnListModel *m_connListModel = nullptr;
|
||||
ZoneListModel *m_zoneListModel = nullptr;
|
||||
};
|
||||
|
||||
|
@ -208,6 +208,18 @@ public:
|
||||
}
|
||||
void setGraphWindowGridColor(const QColor &v) { setIniColor("graphWindow/gridColor", v); }
|
||||
|
||||
QRect connWindowGeometry() const { return iniValue("connWindow/geometry").toRect(); }
|
||||
void setConnWindowGeometry(const QRect &v) { setIniValue("connWindow/geometry", v); }
|
||||
|
||||
bool connWindowMaximized() const { return iniBool("connWindow/maximized"); }
|
||||
void setConnWindowMaximized(bool on) { setIniValue("connWindow/maximized", on); }
|
||||
|
||||
int connListHeaderVersion() const { return iniInt("connWindow/connListHeaderVersion"); }
|
||||
void setConnListHeaderVersion(int v) { setIniValue("connWindow/connListHeaderVersion", v); }
|
||||
|
||||
QByteArray connListHeader() const { return iniByteArray("connWindow/connListHeader"); }
|
||||
void setConnListHeader(const QByteArray &v) { setIniValue("connWindow/connListHeader", v); }
|
||||
|
||||
qint32 quotaDayAlerted() const { return iniInt("quota/dayAlerted"); }
|
||||
void setQuotaDayAlerted(qint32 v) { setIniValue("quota/dayAlerted", v); }
|
||||
|
||||
@ -221,6 +233,7 @@ public:
|
||||
QString hotKeyOptions() const { return iniText("hotKey/options"); }
|
||||
QString hotKeyZones() const { return iniText("hotKey/zones"); }
|
||||
QString hotKeyGraph() const { return iniText("hotKey/graph"); }
|
||||
QString hotKeyConnections() const { return iniText("hotKey/connections"); }
|
||||
QString hotKeyFilter() const { return iniText("hotKey/filter", "Ctrl+Alt+Shift+F"); }
|
||||
QString hotKeyStopTraffic() const { return iniText("hotKey/stopTraffic"); }
|
||||
QString hotKeyStopInetTraffic() const { return iniText("hotKey/stopInetTraffic"); }
|
||||
|
BIN
src/ui/icons/connect.png
Normal file
BIN
src/ui/icons/connect.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -9,6 +9,7 @@
|
||||
#include "../fortmanager.h"
|
||||
#include "../model/applistmodel.h"
|
||||
#include "../model/appstatmodel.h"
|
||||
#include "../model/connlistmodel.h"
|
||||
#include "../util/dateutil.h"
|
||||
#include "../util/osutil.h"
|
||||
#include "logbuffer.h"
|
||||
@ -33,6 +34,11 @@ AppStatModel *LogManager::appStatModel() const
|
||||
return fortManager()->appStatModel();
|
||||
}
|
||||
|
||||
ConnListModel *LogManager::connListModel() const
|
||||
{
|
||||
return fortManager()->connListModel();
|
||||
}
|
||||
|
||||
DriverWorker *LogManager::driverWorker() const
|
||||
{
|
||||
return fortManager()->driverManager()->driverWorker();
|
||||
@ -143,7 +149,7 @@ void LogManager::readLogEntries(LogBuffer *logBuffer)
|
||||
case LogEntry::AppBlockedIp: {
|
||||
LogEntryBlockedIp blockedIpEntry;
|
||||
logBuffer->readEntryBlockedIp(&blockedIpEntry);
|
||||
// connListModel()->handleLogBlockedIp(blockedIpEntry);
|
||||
connListModel()->handleLogBlockedIp(blockedIpEntry);
|
||||
break;
|
||||
}
|
||||
case LogEntry::ProcNew: {
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
class AppListModel;
|
||||
class AppStatModel;
|
||||
class ConnListModel;
|
||||
class FortManager;
|
||||
class DriverWorker;
|
||||
class LogBuffer;
|
||||
@ -21,6 +22,7 @@ public:
|
||||
DriverWorker *driverWorker() const;
|
||||
AppListModel *appListModel() const;
|
||||
AppStatModel *appStatModel() const;
|
||||
ConnListModel *connListModel() const;
|
||||
|
||||
void setActive(bool active);
|
||||
|
||||
|
@ -61,12 +61,6 @@ void AppListModel::handleLogBlocked(const LogEntryBlocked &logEntry)
|
||||
{
|
||||
const QString appPath = logEntry.path();
|
||||
|
||||
#if 0
|
||||
const QString ipText = NetUtil::ip4ToText(logEntry.ip())
|
||||
+ ", " + NetUtil::protocolName(logEntry.proto())
|
||||
+ ':' + QString::number(logEntry.port());
|
||||
#endif
|
||||
|
||||
if (confManager()->appPathExists(appPath))
|
||||
return; // already added by user
|
||||
|
||||
|
@ -1,12 +1,33 @@
|
||||
#include "connlistmodel.h"
|
||||
|
||||
ConnListModel::ConnListModel(QObject *parent) : StringListModel(parent) { }
|
||||
#include "../log/logentryblockedip.h"
|
||||
|
||||
ConnListModel::ConnListModel(ConfManager *confManager, QObject *parent) :
|
||||
StringListModel(parent), m_confManager(confManager)
|
||||
{
|
||||
}
|
||||
|
||||
void ConnListModel::setAppPath(const QString &appPath)
|
||||
{
|
||||
m_appPath = appPath;
|
||||
}
|
||||
|
||||
void ConnListModel::handleLogBlockedIp(const LogEntryBlockedIp &logEntry)
|
||||
{
|
||||
const QString appPath = logEntry.path();
|
||||
|
||||
#if 0
|
||||
const QString ipText = NetUtil::ip4ToText(logEntry.ip())
|
||||
+ ", " + NetUtil::protocolName(logEntry.proto())
|
||||
+ ':' + QString::number(logEntry.port());
|
||||
|
||||
if (confManager()->addApp(
|
||||
appPath, QString(), QDateTime(), groupId, false, logEntry.blocked(), true)) {
|
||||
reset();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ConnListModel::clear()
|
||||
{
|
||||
m_appPath = QString();
|
||||
|
@ -3,22 +3,27 @@
|
||||
|
||||
#include "../util/model/stringlistmodel.h"
|
||||
|
||||
class ConfManager;
|
||||
class LogEntryBlockedIp;
|
||||
|
||||
class ConnListModel : public StringListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConnListModel(QObject *parent = nullptr);
|
||||
explicit ConnListModel(ConfManager *confManager, QObject *parent = nullptr);
|
||||
|
||||
QString appPath() const { return m_appPath; }
|
||||
void setAppPath(const QString &appPath);
|
||||
|
||||
signals:
|
||||
void handleLogBlockedIp(const LogEntryBlockedIp &logEntry);
|
||||
|
||||
public slots:
|
||||
void clear() override;
|
||||
|
||||
private:
|
||||
ConfManager *m_confManager = nullptr;
|
||||
|
||||
QString m_appPath;
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@ class ConfAppsWalker;
|
||||
class EnvManager;
|
||||
class FirewallConf;
|
||||
|
||||
QT_FORWARD_DECLARE_STRUCT(fort_traf)
|
||||
struct fort_traf;
|
||||
|
||||
using longs_arr_t = QVector<quint32>;
|
||||
using shorts_arr_t = QVector<quint16>;
|
||||
|
Loading…
Reference in New Issue
Block a user