Browse Source

quick open session icons now have custom overlays

master
Nils 5 years ago
parent
commit
fef55435ed
  1. BIN
      icon.png
  2. 50
      qtgui/quickopensessioncontroller.py

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

50
qtgui/quickopensessioncontroller.py

@ -23,15 +23,17 @@ import logging; logger = logging.getLogger(__name__); logger.info("import")
#Standard Library
#Third Party
from PyQt5 import QtCore, QtGui, QtWidgets
#Engine
import engine.api as api
from engine.config import METADATA #includes METADATA only. No other environmental setup is executed.
#QtGui
from .descriptiontextwidget import DescriptionController
from .resources import *
#Third Party
from PyQt5 import QtCore, QtGui, QtWidgets
def nothing():
pass
@ -106,10 +108,10 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
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
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),
@ -141,6 +143,38 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
ico = self.parentController.mainWindow.programIcons[self.argodejoExec]
self.setIcon(ico)
def _setIconOverlay(self, status:str):
options = {
"removed": ":alert.svg",
"stopped": ":power.svg",
"hidden": ":hidden.svg",
"ready": ":running.svg",
}
if status in options:
overlayPixmap = QtGui.QIcon(options[status]).pixmap(QtCore.QSize(30,30))
shadow = QtGui.QIcon(options[status]).pixmap(QtCore.QSize(35,35)) #original color is black
#Colorize overlay symbol. Painter works inplace.
painter = QtGui.QPainter(overlayPixmap);
painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn)
painter.fillRect(overlayPixmap.rect(), QtGui.QColor("cyan"))
painter.end()
icon = self.parentController.mainWindow.programIcons[self.argodejoExec]
pixmap = icon.pixmap(QtCore.QSize(70,70))
p = QtGui.QPainter(pixmap)
p.drawPixmap(0, -1, shadow)
p.drawPixmap(2, 2, overlayPixmap) #top left corner of icon, with some padding for the shadow
p.end()
ico = QtGui.QIcon(pixmap)
else:
ico = self.parentController.mainWindow.programIcons[self.argodejoExec]
self.setIcon(ico)
#Status
def ready(self):
@ -152,10 +186,10 @@ class StarterClientItem(QtWidgets.QListWidgetItem):
else:
self._setIconOverlay("ready")
self.setFlags(QtCore.Qt.ItemIsEnabled) #We can still mouseClick through parent signal when set to NoItemFlags
#self.setFlags(QtCore.Qt.ItemIsEnabled)
def removed(self):
self.setFlags(QtCore.Qt.NoItemFlags) #We can still mouseClick through parent signal when set to NoItemFlags
#self.setFlags(QtCore.Qt.NoItemFlags) #Black and white. We can still mouseClick through parent signal when set to NoItemFlags
self.nsmClientDict = None #in opposite to stop
def stopped(self):

Loading…
Cancel
Save