UI/PixmapCache.py

branch
Py2 comp.
changeset 3484
645c12de6b0c
parent 3178
f25fc1364c88
parent 3270
d8532d902e76
child 3621
15f23ed3f216
diff -r 96232974dcdb -r 645c12de6b0c UI/PixmapCache.py
--- a/UI/PixmapCache.py	Sun Mar 30 22:00:14 2014 +0200
+++ b/UI/PixmapCache.py	Thu Apr 03 23:05:31 2014 +0200
@@ -11,6 +11,7 @@
 
 import os
 
+from PyQt4.QtCore import Qt, QSize
 from PyQt4.QtGui import QPixmap, QIcon, QPainter
 
 
@@ -99,6 +100,37 @@
     return QIcon(pix1)
 
 
+def getCombinedIcon(keys, cache=pixCache):
+    """
+    Module function to retrieve a symbolic link icon.
+
+    @param keys list of names of icons (string)
+    @param cache reference to the pixmap cache object (PixmapCache)
+    @return the requested icon (QIcon)
+    """
+    height = width = 0
+    pixmaps = []
+    for key in keys:
+        pix = cache.getPixmap(key)
+        if not pix.isNull():
+            height = max(height, pix.height())
+            width = max(width, pix.width())
+            pixmaps.append(pix)
+    if pixmaps:
+        pix = QPixmap(len(pixmaps) * width, height)
+        pix.fill(Qt.transparent)
+        painter = QPainter(pix)
+        x = 0
+        for pixmap in pixmaps:
+            painter.drawPixmap(x, 0, pixmap.scaled(QSize(width, height)))
+            x += width
+        painter.end()
+        icon = QIcon(pix)
+    else:
+        icon = QIcon()
+    return icon
+
+
 def addSearchPath(path, cache=pixCache):
     """
     Module function to add a path to the search path.

eric ide

mercurial