#ifndef FORTMANAGER_H #define FORTMANAGER_H #include #include class QQmlApplicationEngine; class QSystemTrayIcon; class DriverManager; class FortSettings; class FirewallConf; class LogBuffer; class FortManager : public QObject { Q_OBJECT Q_PROPERTY(FortSettings *fortSettings READ fortSettings CONSTANT) Q_PROPERTY(FirewallConf *firewallConfToEdit READ firewallConfToEdit NOTIFY firewallConfToEditChanged) Q_PROPERTY(DriverManager *driverManager READ driverManager CONSTANT) public: explicit FortManager(QObject *parent = nullptr); FortSettings *fortSettings() const { return m_fortSettings; } FirewallConf *firewallConfToEdit() const { return m_firewallConfToEdit ? m_firewallConfToEdit : m_firewallConf; } DriverManager *driverManager() const { return m_driverManager; } signals: void firewallConfToEditChanged(); public slots: bool setupDriver(); void showTrayIcon(); void showWindow(); void closeWindow(); void showErrorBox(const QString &text); bool saveConf(); bool applyConf(); void setAppLogBlocked(bool enable); private slots: void saveTrayFlags(); private: FirewallConf *nullConf() const { return nullptr; } void setFirewallConfToEdit(FirewallConf *conf); static void registerQmlTypes(); void setupTrayIcon(); void setupEngine(); bool saveSettings(FirewallConf *newConf); bool updateDriverFlags(FirewallConf *conf); FirewallConf *cloneConf(const FirewallConf &conf); void updateTrayMenu(); static QAction *addAction(QWidget *widget, const QIcon &icon, const QString &text, const QObject *receiver = 0, const char *member = 0, bool checkable = false, bool checked = false); static void setActionCheckable(QAction *action, bool checked = false, const QObject *receiver = 0, const char *member = 0); private: QMainWindow m_window; // dummy window for tray icon QSystemTrayIcon *m_trayIcon; QQmlApplicationEngine *m_engine; QWindow *m_appWindow; FortSettings *m_fortSettings; FirewallConf *m_firewallConf; FirewallConf *m_firewallConfToEdit; QAction *m_filterEnabledAction; QAction *m_ipIncludeAllAction; QAction *m_ipExcludeAllAction; QAction *m_appBlockAllAction; QAction *m_appAllowAllAction; QMenu *m_appGroupsMenu; DriverManager *m_driverManager; }; #endif // FORTMANAGER_H