diff --git a/ui/opensnitch/service.py b/ui/opensnitch/service.py index f0aeefaeda..e95462d5b0 100644 --- a/ui/opensnitch/service.py +++ b/ui/opensnitch/service.py @@ -123,6 +123,7 @@ def _setup_tray(self): self._tray = QtWidgets.QSystemTrayIcon(self.off_icon) self._tray.setContextMenu(self._menu) + self._tray.activated.connect(self._on_tray_icon_activated) self._menu.addAction("Help").triggered.connect( lambda: QtGui.QDesktopServices.openUrl(QtCore.QUrl(Config.HELP_URL)) @@ -135,6 +136,13 @@ def _setup_tray(self): if not self._tray.isSystemTrayAvailable(): self._stats_dialog.show() + def _on_tray_icon_activated(self, reason): + if reason == QtWidgets.QSystemTrayIcon.Trigger or reason == QtWidgets.QSystemTrayIcon.MiddleClick: + if self._stats_dialog.isVisible(): + self._stats_dialog.hide() + else: + self._stats_dialog.show() + def _on_close(self): self._exit = True self._on_exit()