diff --git a/src/ui/FortFirewallUI.pro b/src/ui/FortFirewallUI.pro index 19c99c01..e3abd0b4 100644 --- a/src/ui/FortFirewallUI.pro +++ b/src/ui/FortFirewallUI.pro @@ -32,6 +32,7 @@ SOURCES += \ form/controls/appinforow.cpp \ form/controls/checkspincombo.cpp \ form/controls/checktimeperiod.cpp \ + form/controls/clickablemenu.cpp \ form/controls/controlutil.cpp \ form/controls/labelcolor.cpp \ form/controls/labeldoublespin.cpp \ @@ -193,6 +194,7 @@ HEADERS += \ form/controls/appinforow.h \ form/controls/checkspincombo.h \ form/controls/checktimeperiod.h \ + form/controls/clickablemenu.h \ form/controls/controlutil.h \ form/controls/labelcolor.h \ form/controls/labeldoublespin.h \ diff --git a/src/ui/form/controls/clickablemenu.cpp b/src/ui/form/controls/clickablemenu.cpp new file mode 100644 index 00000000..6c1d1c3c --- /dev/null +++ b/src/ui/form/controls/clickablemenu.cpp @@ -0,0 +1,15 @@ +#include "clickablemenu.h" + +#include + +ClickableMenu::ClickableMenu(QWidget *parent) : QMenu(parent) +{ + setAttribute(Qt::WA_WindowPropagation); // to inherit default font +} + +void ClickableMenu::mousePressEvent(QMouseEvent *event) +{ + QMenu::mousePressEvent(event); + + emit clicked(); +} diff --git a/src/ui/form/controls/clickablemenu.h b/src/ui/form/controls/clickablemenu.h new file mode 100644 index 00000000..e721da20 --- /dev/null +++ b/src/ui/form/controls/clickablemenu.h @@ -0,0 +1,20 @@ +#ifndef CLICKABLEMENU_H +#define CLICKABLEMENU_H + +#include + +class ClickableMenu : public QMenu +{ + Q_OBJECT + +public: + explicit ClickableMenu(QWidget *parent = nullptr); + +signals: + void clicked(); + +protected: + void mousePressEvent(QMouseEvent *event) override; +}; + +#endif // CLICKABLEMENU_H diff --git a/src/ui/form/tray/trayicon.cpp b/src/ui/form/tray/trayicon.cpp index c3591c9f..3a3828fb 100644 --- a/src/ui/form/tray/trayicon.cpp +++ b/src/ui/form/tray/trayicon.cpp @@ -10,6 +10,7 @@ #include #include #include +#include
#include #include #include @@ -372,13 +373,15 @@ void TrayIcon::setupTrayMenu() void TrayIcon::setupTrayMenuOptions() { - m_optionsMenu = ControlUtil::createMenu(m_menu); + m_optionsMenu = new ClickableMenu(m_menu); m_optionsMenu->setIcon(IconCache::icon(":/icons/cog.png")); m_optionsAction = addAction(m_optionsMenu, IconCache::icon(":/icons/cog.png"), QString(), windowManager(), SLOT(showOptionsWindow())); addHotKey(m_optionsAction, iniUser()->hotKeyOptions()); + connect(m_optionsMenu, &ClickableMenu::clicked, m_optionsAction, &QAction::trigger); + m_zonesAction = addAction(m_optionsMenu, IconCache::icon(":/icons/ip_class.png"), QString(), windowManager(), SLOT(showZonesWindow())); addHotKey(m_zonesAction, iniUser()->hotKeyZones()); diff --git a/src/ui/form/tray/trayicon.h b/src/ui/form/tray/trayicon.h index 4edbc526..7935c9c5 100644 --- a/src/ui/form/tray/trayicon.h +++ b/src/ui/form/tray/trayicon.h @@ -7,6 +7,7 @@ QT_FORWARD_DECLARE_CLASS(QAction) QT_FORWARD_DECLARE_CLASS(QActionGroup) QT_FORWARD_DECLARE_CLASS(QTimer) +class ClickableMenu; class ConfManager; class DriverManager; class FirewallConf; @@ -119,7 +120,7 @@ private: QMenu *m_menu = nullptr; QAction *m_programsAction = nullptr; - QMenu *m_optionsMenu = nullptr; + ClickableMenu *m_optionsMenu = nullptr; QAction *m_optionsAction = nullptr; QAction *m_statisticsAction = nullptr; QAction *m_graphAction = nullptr;