diff --git a/examples/demo.py b/examples/demo.py index bbcce87..064dd53 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -1,12 +1,11 @@ import os -os.environ["ICONIFY_QTLIB"] = "PySide2" os.environ["ICONIFY_PATH"] = os.path.dirname(__file__) + "/icons" -from PySide2 import QtCore, QtGui, QtWidgets import iconify as ico +from iconify.qt import QtCore, QtGui, QtWidgets app = QtWidgets.QApplication([]) diff --git a/examples/modelViewUsage.py b/examples/modelViewUsage.py index 471978f..9cc318f 100644 --- a/examples/modelViewUsage.py +++ b/examples/modelViewUsage.py @@ -2,12 +2,11 @@ import os -os.environ["ICONIFY_QTLIB"] = "PySide2" os.environ["ICONIFY_PATH"] = os.path.dirname(__file__) + "/icons" import iconify as ico -from iconify.qt import QtCore, QtGui, QtWidgets, QtSvg +from iconify.qt import QtCore, QtGui, QtSvg, QtWidgets diff --git a/iconify/core.py b/iconify/core.py index 07c88d2..d9f2384 100644 --- a/iconify/core.py +++ b/iconify/core.py @@ -299,11 +299,11 @@ def pixmap(self, size): if self._anim is not None: key = ( - self._path, size, str(self._anim.__class__), + self._path, str(size), str(self._anim.__class__), self._anim.frame(), color ) # type: PixmapCacheKey else: - key = (self._path, size, "", 0, color) + key = (self._path, str(size), "", 0, color) if key in self._pixmapCache: return self._pixmapCache[key] @@ -324,17 +324,12 @@ def pixmap(self, size): painter.setTransform(xfm) self._renderer.render(painter) - painter.end() if self._color is not None: - # Use the alpha channel on a solid colour image - colorImage = QtGui.QImage( - size, - QtGui.QImage.Format_ARGB32_Premultiplied, - ) - colorImage.fill(QtGui.QColor(self._color)) - colorImage.setAlphaChannel(image.alphaChannel()) - image = colorImage + painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn) + painter.fillRect(image.rect(), QtGui.QColor(self._color)) + + painter.end() pixmap = QtGui.QPixmap.fromImage(image) self._pixmapCache[key] = pixmap diff --git a/iconify/qt.py b/iconify/qt.py index 8c2e7a2..e62f42e 100644 --- a/iconify/qt.py +++ b/iconify/qt.py @@ -26,3 +26,6 @@ if None in (QtCore, QtGui, QtSvg, QtWidgets, QtXml): raise ImportError(_IMPORT_ERROR_MESSAGE.format(qtlib)) + +if qtlib == "PyQt5": + QtCore.Signal = QtCore.pyqtSignal