summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/feature_always_show_context_menu3
-rw-r--r--src/leap/gui/mainwindow.py34
2 files changed, 25 insertions, 12 deletions
diff --git a/changes/feature_always_show_context_menu b/changes/feature_always_show_context_menu
new file mode 100644
index 00000000..9e94726e
--- /dev/null
+++ b/changes/feature_always_show_context_menu
@@ -0,0 +1,3 @@
+ o Clicking in the tray icon will always show the context menu
+ instead of activating the window under certain
+ circumstances. Closes #2788 \ No newline at end of file
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index 01707554..3c6c579c 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -523,31 +523,41 @@ class MainWindow(QtGui.QMainWindow):
self._systray.setContextMenu(systrayMenu)
self._systray.setIcon(QtGui.QIcon(self.ERROR_ICON))
self._systray.setVisible(True)
- self._systray.activated.connect(self._toggle_visible)
+ self._systray.activated.connect(self._tray_activated)
- def _toggle_visible(self, reason=None):
+ def _tray_activated(self, reason=None):
"""
SLOT
TRIGGER: self._systray.activated
- Toggles the window visibility
+ Displays the context menu from the tray icon
"""
get_action = lambda visible: (
- self.tr("Show"),
- self.tr("Hide"))[int(visible)]
-
- minimized = self.isMinimized()
+ self.tr("Show Main Window"),
+ self.tr("Hide Main Window"))[int(visible)]
if reason != QtGui.QSystemTrayIcon.Context:
- # do show
- if minimized:
- self.showNormal()
- self.setVisible(not self.isVisible())
-
# set labels
visible = self.isVisible()
self._action_visible.setText(get_action(visible))
+ context_menu = self._systray.contextMenu()
+ # for some reason, context_menu.show()
+ # is failing in a way beyond my understanding.
+ # (not working the first time it's clicked).
+ # this works however.
+ # XXX in osx it shows some glitches.
+ context_menu.exec_(self._systray.geometry().center())
+
+ def _toggle_visible(self):
+ """
+ SLOT
+ TRIGGER: self._action_visible.triggered
+
+ Toggles the window visibility
+ """
+ self.setVisible(not self.isVisible())
+
def _center_window(self):
"""
Centers the mainwindow based on the desktop geometry