changeset 958:85b39667e9cf scalable-icons

Various fixes to scalable rendering
author Chris Cannam
date Wed, 06 May 2015 10:44:19 +0100
parents 4b5efd76a55c
children c91878670297
files widgets/IconLoader.cpp
diffstat 1 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/IconLoader.cpp	Wed May 06 10:08:28 2015 +0100
+++ b/widgets/IconLoader.cpp	Wed May 06 10:44:19 2015 +0100
@@ -92,26 +92,33 @@
 IconLoader::loadPixmap(QString name, int size)
 {
     bool invert = shouldInvert();
-/*
-    QString nonScalableName = makeNonScalableFilename(name, size, invert);
-    QPixmap pmap(nonScalableName);
+
+    QString scalableName, nonScalableName;
+    QPixmap pmap;
+
+    nonScalableName = makeNonScalableFilename(name, size, invert);
+    pmap = QPixmap(nonScalableName);
     if (!pmap.isNull()) return pmap;
-*/
-    QString scalableName = makeScalableFilename(name, invert);
-   QPixmap pmap = loadScalable(scalableName, size);
-    if (!pmap.isNull()) return pmap;
-    /*
+
+    if (size > 0) {
+        scalableName = makeScalableFilename(name, invert);
+        pmap = loadScalable(scalableName, size);
+        if (!pmap.isNull()) return pmap;
+    }
+
     if (invert && shouldAutoInvert(name)) {
 
         nonScalableName = makeNonScalableFilename(name, size, false);
         pmap = QPixmap(nonScalableName);
         if (!pmap.isNull()) return invertPixmap(pmap);
 
-        scalableName = makeScalableFilename(name, false);
-        pmap = loadScalable(scalableName, size);
-        if (!pmap.isNull()) return invertPixmap(pmap);
+        if (size > 0) {
+            scalableName = makeScalableFilename(name, false);
+            pmap = loadScalable(scalableName, size);
+            if (!pmap.isNull()) return invertPixmap(pmap);
+        }
     }
-    */                
+
     return QPixmap();
 }
 
@@ -124,9 +131,13 @@
     }
     QPixmap pmap(size, size);
     pmap.fill(Qt::transparent);
-    QPainter painter(&pmap);
     QSvgRenderer renderer(name);
+    QPainter painter;
+    painter.begin(&pmap);
+    cerr << "calling renderer for " << name << " at size " << size << "..." << endl;
     renderer.render(&painter);
+    cerr << "renderer completed" << endl;
+    painter.end();
     return pmap;
 }