comparison widgets/IconLoader.cpp @ 958:85b39667e9cf scalable-icons

Various fixes to scalable rendering
author Chris Cannam
date Wed, 06 May 2015 10:44:19 +0100
parents 4b5efd76a55c
children 5fdf5cd032ac
comparison
equal deleted inserted replaced
957:4b5efd76a55c 958:85b39667e9cf
90 90
91 QPixmap 91 QPixmap
92 IconLoader::loadPixmap(QString name, int size) 92 IconLoader::loadPixmap(QString name, int size)
93 { 93 {
94 bool invert = shouldInvert(); 94 bool invert = shouldInvert();
95 /* 95
96 QString nonScalableName = makeNonScalableFilename(name, size, invert); 96 QString scalableName, nonScalableName;
97 QPixmap pmap(nonScalableName); 97 QPixmap pmap;
98
99 nonScalableName = makeNonScalableFilename(name, size, invert);
100 pmap = QPixmap(nonScalableName);
98 if (!pmap.isNull()) return pmap; 101 if (!pmap.isNull()) return pmap;
99 */ 102
100 QString scalableName = makeScalableFilename(name, invert); 103 if (size > 0) {
101 QPixmap pmap = loadScalable(scalableName, size); 104 scalableName = makeScalableFilename(name, invert);
102 if (!pmap.isNull()) return pmap; 105 pmap = loadScalable(scalableName, size);
103 /* 106 if (!pmap.isNull()) return pmap;
107 }
108
104 if (invert && shouldAutoInvert(name)) { 109 if (invert && shouldAutoInvert(name)) {
105 110
106 nonScalableName = makeNonScalableFilename(name, size, false); 111 nonScalableName = makeNonScalableFilename(name, size, false);
107 pmap = QPixmap(nonScalableName); 112 pmap = QPixmap(nonScalableName);
108 if (!pmap.isNull()) return invertPixmap(pmap); 113 if (!pmap.isNull()) return invertPixmap(pmap);
109 114
110 scalableName = makeScalableFilename(name, false); 115 if (size > 0) {
111 pmap = loadScalable(scalableName, size); 116 scalableName = makeScalableFilename(name, false);
112 if (!pmap.isNull()) return invertPixmap(pmap); 117 pmap = loadScalable(scalableName, size);
113 } 118 if (!pmap.isNull()) return invertPixmap(pmap);
114 */ 119 }
120 }
121
115 return QPixmap(); 122 return QPixmap();
116 } 123 }
117 124
118 QPixmap 125 QPixmap
119 IconLoader::loadScalable(QString name, int size) 126 IconLoader::loadScalable(QString name, int size)
122 cerr << "loadScalable: no such file as: \"" << name << "\"" << endl; 129 cerr << "loadScalable: no such file as: \"" << name << "\"" << endl;
123 return QPixmap(); 130 return QPixmap();
124 } 131 }
125 QPixmap pmap(size, size); 132 QPixmap pmap(size, size);
126 pmap.fill(Qt::transparent); 133 pmap.fill(Qt::transparent);
127 QPainter painter(&pmap);
128 QSvgRenderer renderer(name); 134 QSvgRenderer renderer(name);
135 QPainter painter;
136 painter.begin(&pmap);
137 cerr << "calling renderer for " << name << " at size " << size << "..." << endl;
129 renderer.render(&painter); 138 renderer.render(&painter);
139 cerr << "renderer completed" << endl;
140 painter.end();
130 return pmap; 141 return pmap;
131 } 142 }
132 143
133 QString 144 QString
134 IconLoader::makeNonScalableFilename(QString name, int size, bool invert) 145 IconLoader::makeNonScalableFilename(QString name, int size, bool invert)