Skip to content

Commit

Permalink
UI: show/hide stats window by clicking on the systray icon
Browse files Browse the repository at this point in the history
closes #39
  • Loading branch information
gustavo-iniguez-goya committed Jun 20, 2020
1 parent 73eb5b6 commit 3011d9f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ui/opensnitch/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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()
Expand Down

0 comments on commit 3011d9f

Please sign in to comment.