Browse Source

Properly reset quick session controller after switching session

master
Nils 4 years ago
parent
commit
f36c6063cf
  1. 2
      qtgui/opensessioncontroller.py
  2. 43
      qtgui/quickopensessioncontroller.py

2
qtgui/opensessioncontroller.py

@ -114,7 +114,7 @@ class ClientItem(QtWidgets.QTreeWidgetItem):
#TODO: this should be an nsmd status. Check if excecutable exists. nsmd just reports "stopped", and worse: after a long timeout.
if clientDict["lastStatus"] == "stopped" and clientDict["reportedName"] is None:
cself.setText(self.parentController.clientsTreeWidgetColumns.index("lastStatus"), QtCore.QCoreApplication.translate("OpenSession", "(command not found)"))
self.setText(self.parentController.clientsTreeWidgetColumns.index("lastStatus"), QtCore.QCoreApplication.translate("OpenSession", "(command not found)"))
class ClientTable(object):

43
qtgui/quickopensessioncontroller.py

@ -84,6 +84,7 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
icon = programIcons[desktopEntry["argodejoExec"]]
self.setIcon(icon)
self.updateStatus(None) #removed/off
def updateStatus(self, clientDict:dict):
"""
@ -107,43 +108,7 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
self.removed()
else:
getattr(self, clientDict["lastStatus"], nothing)()
def _deprecated_setIconOverlay(self, status:str):
"""Crashes on some systems with themes.
https://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum"""
standardPixmap, enabled, removeAlpha = {
"removed":(QtWidgets.QStyle.SP_TrashIcon, False, True),
"stopped":(QtWidgets.QStyle.SP_BrowserStop, False, False),
"ready": (None, True, False),
"hidden":(QtWidgets.QStyle.SP_TitleBarMaxButton, True, True),
}[status]
if standardPixmap:
overlayPixmap = self.parentController.listWidget.style().standardPixmap(standardPixmap)
if removeAlpha:
whiteBg = QtGui.QPixmap(overlayPixmap.size())
whiteBg.fill(QtGui.QColor(255,255,255,255)) #red
icon = self.parentController.mainWindow.programIcons[self.argodejoExec]
if enabled:
pixmap = icon.pixmap(QtCore.QSize(70,70))
else:
pixmap = icon.pixmap(QtCore.QSize(70,70), QtGui.QIcon.Disabled)
p = QtGui.QPainter(pixmap)
if removeAlpha:
p.drawPixmap(0, 0, whiteBg)
p.drawPixmap(0, 0, overlayPixmap)
p.end()
ico = QtGui.QIcon(pixmap)
else:
ico = self.parentController.mainWindow.programIcons[self.argodejoExec]
self.setIcon(ico)
def _setIconOverlay(self, status:str):
options = {
"removed": ":alert.svg",
@ -311,6 +276,10 @@ class QuickOpenSessionController(object):
"""
whitelist = [e for e in api.getSystemPrograms() if e["whitelist"]]
leftovers = set(StarterClientItem.allItems.keys()) #"argodejoExec"
for forIcon in StarterClientItem.allItems.values():
forIcon._setIconOverlay("") #empty initial state
for entry in whitelist:
exe = entry["argodejoExec"]
if exe in StarterClientItem.allItems:

Loading…
Cancel
Save