|
|
@ -103,76 +103,79 @@ class StarterClientItem(QtWidgets.QListWidgetItem): |
|
|
|
self.nsmClientDict = clientDict #for comparison with later status changes. Especially for stopped clients. |
|
|
|
if clientDict is None: |
|
|
|
self.removed() |
|
|
|
else: |
|
|
|
else: |
|
|
|
getattr(self, clientDict["lastStatus"], nothing)() |
|
|
|
|
|
|
|
def _setIconOverlay(self, status:str): |
|
|
|
"""https://doc.qt.io/qt-5/qstyle.html#StandardPixmap-enum""" |
|
|
|
#TODO: this crashes with certain Qt Themes. It was a hack anyway. Use our own graphical overlays instead. That is prettier and works. |
|
|
|
return True |
|
|
|
|
|
|
|
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), |
|
|
|
"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 standardPixmap: |
|
|
|
overlayPixmap = self.parentController.listWidget.style().standardPixmap(standardPixmap) |
|
|
|
|
|
|
|
if removeAlpha: |
|
|
|
whiteBg = QtGui.QPixmap(overlayPixmap.size()) |
|
|
|
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.drawPixmap(0, 0, overlayPixmap) |
|
|
|
p.end() |
|
|
|
ico = QtGui.QIcon(pixmap) |
|
|
|
else: |
|
|
|
else: |
|
|
|
ico = self.parentController.mainWindow.programIcons[self.argodejoExec] |
|
|
|
|
|
|
|
self.setIcon(ico) |
|
|
|
self.setIcon(ico) |
|
|
|
|
|
|
|
#Status |
|
|
|
def ready(self): |
|
|
|
if self.nsmClientDict["hasOptionalGUI"]: |
|
|
|
if self.nsmClientDict["visible"]: |
|
|
|
self._setIconOverlay("ready") |
|
|
|
else: |
|
|
|
self._setIconOverlay("hidden") |
|
|
|
else: |
|
|
|
self._setIconOverlay("hidden") |
|
|
|
else: |
|
|
|
self._setIconOverlay("ready") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.setFlags(QtCore.Qt.ItemIsEnabled) #We can still mouseClick through parent signal when set to NoItemFlags |
|
|
|
|
|
|
|
def removed(self): |
|
|
|
self.setFlags(QtCore.Qt.NoItemFlags) #We can still mouseClick through parent signal when set to NoItemFlags |
|
|
|
self.setFlags(QtCore.Qt.NoItemFlags) #We can still mouseClick through parent signal when set to NoItemFlags |
|
|
|
self.nsmClientDict = None #in opposite to stop |
|
|
|
|
|
|
|
def stopped(self): |
|
|
|
self.setFlags(QtCore.Qt.ItemIsEnabled) |
|
|
|
self._setIconOverlay("stopped") |
|
|
|
self._setIconOverlay("stopped") |
|
|
|
|
|
|
|
def handleClick(self): |
|
|
|
def handleClick(self): |
|
|
|
alreadyInSession = api.executableInSession(self.argodejoExec) |
|
|
|
#Development-paranoia Start |
|
|
|
if self.nsmClientDict: |
|
|
|
assert alreadyInSession |
|
|
|
elif alreadyInSession: |
|
|
|
assert alreadyInSession |
|
|
|
elif alreadyInSession: |
|
|
|
assert self.nsmClientDict |
|
|
|
#Development-paranoia End |
|
|
|
|
|
|
|
|
|
|
|
if not alreadyInSession: |
|
|
|
api.clientAdd(self.argodejoExec) #triggers status update callback which activates our item. |
|
|
|
elif self.nsmClientDict["lastStatus"] == "stopped": |
|
|
|
api.clientResume(self.nsmClientDict["clientId"]) |
|
|
|
api.clientResume(self.nsmClientDict["clientId"]) |
|
|
|
else: |
|
|
|
api.clientToggleVisible(self.nsmClientDict["clientId"]) #api is tolerant to sending this to non-optional-GUI clients |
|
|
|
|
|
|
@ -292,7 +295,7 @@ class QuickOpenSessionController(object): |
|
|
|
del item |
|
|
|
|
|
|
|
#old: rebuild from scratch |
|
|
|
""" |
|
|
|
""" |
|
|
|
self.listWidget.clear() |
|
|
|
StarterClientItem.allItems.clear() |
|
|
|
whitelist = [e for e in api.getSystemPrograms() if e["whitelist"]] |
|
|
@ -302,7 +305,7 @@ class QuickOpenSessionController(object): |
|
|
|
self.listWidget.addItem(item) |
|
|
|
StarterClientItem.allItems[entry["argodejoExec"]] = item |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def _clientStatusChanged(self, clientDict:dict): |
|
|
|
"""Maps to nsmd status changes. |
|
|
|
We already have icons for all programs, in opposite to detailed-view opensession controller. |
|
|
@ -311,11 +314,11 @@ class QuickOpenSessionController(object): |
|
|
|
""" |
|
|
|
#index = self.listWidget.indexFromItem(QuickClientItem.allItems[clientId]).row() #Row is the real index in a listView, no matter iconViewMode. |
|
|
|
if clientDict["dumbClient"]: |
|
|
|
#This includes the initial loading of nsm-clients. |
|
|
|
#This includes the initial loading of nsm-clients. |
|
|
|
return |
|
|
|
backgroundClients = METADATA["preferredClients"].values() |
|
|
|
if clientDict["executable"] in backgroundClients: |
|
|
|
return |
|
|
|
if clientDict["executable"] in backgroundClients: |
|
|
|
return |
|
|
|
|
|
|
|
if clientDict["executable"] in StarterClientItem.allItems: |
|
|
|
item = StarterClientItem.allItems[clientDict["executable"]] |
|
|
|