Browse Source

Fix trayicon hide show context menu

master
Nils 4 years ago
parent
commit
b0c10cdcf0
  1. 9
      qtgui/systemtray.py

9
qtgui/systemtray.py

@ -36,7 +36,7 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
def __init__(self, mainWindow):
super().__init__(QtGui.QIcon(":icon.png"))
self.mainWindow = mainWindow
self.available = self.isSystemTrayAvailable()
self.available = self.isSystemTrayAvailable()
self.show()
#self.showMessage("Title", "Helllo!", QtWidgets.QSystemTrayIcon.Information) #title, message, icon, timeout. #has messageClicked() signal.
#Don't build the context menu here. The engine is not ready to provide us with session information. Let the callbacks do it.
@ -61,8 +61,7 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
nsmSessionName = api.currentSession()
_add(QtCore.QCoreApplication.translate("TrayIcon", "Hide/Show Argodejo"), self.mainWindow.toggleVisible)
_add(QtCore.QCoreApplication.translate("TrayIcon", "Hide/Show Argodejo"), lambda: self.mainWindow.toggleVisible(force=None)) #explicit force=None because the qt signal is sending a bool
menu.addSeparator()
#Add other pre-defined actions
@ -82,7 +81,7 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
else:
for recentName in self.mainWindow.recentlyOpenedSessions.get():
_add(f"Session: {recentName}", lambda: api.sessionOpen(recentName))
_add(QtCore.QCoreApplication.translate("TrayIcon", "Quit "), self.mainWindow.menuRealQuit)
self.setContextMenu(menu)
@ -95,7 +94,7 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
QtWidgets.QSystemTrayIcon.Trigger
QtWidgets.QSystemTrayIcon.MiddleClick
"""
logger.info(f"System tray activated with reason {qActivationReason}")
logger.info(f"System tray activated with reason {qActivationReason}")
if qActivationReason == QtWidgets.QSystemTrayIcon.Trigger:
self.mainWindow.toggleVisible()

Loading…
Cancel
Save