Browse Source

Submenu in tray icon to toggle visibility of individual clients (if supported)

master
Nils 3 years ago
parent
commit
da93e3e7e0
  1. 1
      CHANGELOG
  2. 7
      qtgui/opensessioncontroller.py
  3. 27
      qtgui/systemtray.py

1
CHANGELOG

@ -2,6 +2,7 @@
Remove "Quick" mode. As it turns out "Full" mode is quick enough. Port convenience features to full mode. Remove "Quick" mode. As it turns out "Full" mode is quick enough. Port convenience features to full mode.
Add button in session chooser for alternative access to context menu options Add button in session chooser for alternative access to context menu options
Add normal "Save" to tray icon. Add normal "Save" to tray icon.
Submenu in tray icon to toggle visibility of individual clients (if supported)
Double click on a crashed clients opens it again. This was intentional so far, because a crash is special. But it will be fine... Double click on a crashed clients opens it again. This was intentional so far, because a crash is special. But it will be fine...
2021-01-15 Version 0.2.1 2021-01-15 Version 0.2.1

7
qtgui/opensessioncontroller.py

@ -197,6 +197,9 @@ class ClientTable(object):
ClientItem.allItems.clear() ClientItem.allItems.clear()
self.clientsTreeWidget.clear() self.clientsTreeWidget.clear()
def allItems(self):
return ClientItem.allItems
def clientsContextMenu(self, qpoint): def clientsContextMenu(self, qpoint):
"""Reuses the menubar menus""" """Reuses the menubar menus"""
pos = QtGui.QCursor.pos() pos = QtGui.QCursor.pos()
@ -516,6 +519,10 @@ class OpenSessionController(object):
api.callbacks.sessionOpenReady.append(self._reactCallback_sessionOpen) api.callbacks.sessionOpenReady.append(self._reactCallback_sessionOpen)
logger.info("Full View Open Session Controller ready") logger.info("Full View Open Session Controller ready")
def allSessionItems(self):
"""Can be used by external parts, like the tray icon"""
return self.clientTabe.allItems().values() #dict clientId:SessionItem
def _reactCallback_sessionOpen(self, nsmSessionExportDict:dict): def _reactCallback_sessionOpen(self, nsmSessionExportDict:dict):
"""Open does not mean we come from the session chooser. Switching does not close a session""" """Open does not mean we come from the session chooser. Switching does not close a session"""
#self.description.clear() #Deletes the placesholder and text! #self.description.clear() #Deletes the placesholder and text!

27
qtgui/systemtray.py

@ -48,6 +48,26 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
api.callbacks.sessionClosed.append(self.buildContextMenu) api.callbacks.sessionClosed.append(self.buildContextMenu)
api.callbacks.sessionOpenReady.append(self.buildContextMenu) api.callbacks.sessionOpenReady.append(self.buildContextMenu)
api.callbacks.sessionsChanged.append(self.buildContextMenu) api.callbacks.sessionsChanged.append(self.buildContextMenu)
#api.callbacks.clientStatusChanged.append(self.buildContextMenu) #too much. We deal with the client list separately.
self.toggleVisMenu = None
def updateToggleVisMenu(self):
if not self.toggleVisMenu or not api.currentSession(): return #program start or not in a session
for a in self.toggleVisMenu.findChildren(QtWidgets.QAction):
if not a.menu():
self.toggleVisMenu.removeAction(a)
del a
for clientItem in self.mainWindow.sessionController.openSessionController.allSessionItems():
if clientItem.clientDict["hasOptionalGUI"]:
a = QtWidgets.QAction(clientItem.clientDict["reportedName"], self.toggleVisMenu)
self.toggleVisMenu.addAction(a)
def createToggleLambda(clientId):
return lambda: api.clientToggleVisible(clientId)
command = createToggleLambda(clientItem.clientDict["clientId"])
a.triggered.connect(command)
def buildContextMenu(self, *args): def buildContextMenu(self, *args):
"""In a function for readability. """In a function for readability.
@ -63,7 +83,6 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
_add(QtCore.QCoreApplication.translate("TrayIcon", "Hide/Show Agordejo"), lambda: self.mainWindow.toggleVisible(force=None)) #explicit force=None because the qt signal is sending a bool _add(QtCore.QCoreApplication.translate("TrayIcon", "Hide/Show Agordejo"), lambda: self.mainWindow.toggleVisible(force=None)) #explicit force=None because the qt signal is sending a bool
menu.addSeparator() menu.addSeparator()
#Add other pre-defined actions #Add other pre-defined actions
if nsmSessionName: #We are in a loaded session if nsmSessionName: #We are in a loaded session
menu.addAction(self.mainWindow.ui.actionShow_All_Clients) menu.addAction(self.mainWindow.ui.actionShow_All_Clients)
@ -71,6 +90,11 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
menu.addSeparator() menu.addSeparator()
menu.addAction(self.mainWindow.ui.actionShow_All_Clients) menu.addAction(self.mainWindow.ui.actionShow_All_Clients)
menu.addAction(self.mainWindow.ui.actionHide_All_Clients) menu.addAction(self.mainWindow.ui.actionHide_All_Clients)
#Create a submenu to toggle visibility for all supported clients.
self.toggleVisMenu = menu.addMenu(QtCore.QCoreApplication.translate("TrayIcon", "Toggle Client Visibility"))
#Updated on each trayIcon show event with updateToggleVisMenu
menu.addSeparator() menu.addSeparator()
_add(QtCore.QCoreApplication.translate("TrayIcon", "Save {}".format(nsmSessionName)), api.sessionSave) _add(QtCore.QCoreApplication.translate("TrayIcon", "Save {}".format(nsmSessionName)), api.sessionSave)
_add(QtCore.QCoreApplication.translate("TrayIcon", "Save && Close {}".format(nsmSessionName)), api.sessionClose) _add(QtCore.QCoreApplication.translate("TrayIcon", "Save && Close {}".format(nsmSessionName)), api.sessionClose)
@ -96,6 +120,7 @@ class SystemTray(QtWidgets.QSystemTrayIcon):
QtWidgets.QSystemTrayIcon.MiddleClick QtWidgets.QSystemTrayIcon.MiddleClick
""" """
logger.info(f"System tray activated with reason {qActivationReason}") logger.info(f"System tray activated with reason {qActivationReason}")
self.updateToggleVisMenu()
if qActivationReason == QtWidgets.QSystemTrayIcon.Trigger: if qActivationReason == QtWidgets.QSystemTrayIcon.Trigger:
self.mainWindow.toggleVisible() self.mainWindow.toggleVisible()

Loading…
Cancel
Save