Mercurial > hg > svgui
comparison widgets/IconLoader.cpp @ 1262:a9c2e791ab8d
Fix loading of should-not-auto-invert scalable icons
author | Chris Cannam |
---|---|
date | Tue, 18 Jul 2017 15:11:49 +0100 |
parents | 5fdf5cd032ac |
children | 8b7f797bca86 |
comparison
equal
deleted
inserted
replaced
1261:f683b191dbe6 | 1262:a9c2e791ab8d |
---|---|
94 bool invert = shouldInvert(); | 94 bool invert = shouldInvert(); |
95 | 95 |
96 QString scalableName, nonScalableName; | 96 QString scalableName, nonScalableName; |
97 QPixmap pmap; | 97 QPixmap pmap; |
98 | 98 |
99 // attempt to load a pixmap with the right size and inversion | |
99 nonScalableName = makeNonScalableFilename(name, size, invert); | 100 nonScalableName = makeNonScalableFilename(name, size, invert); |
100 pmap = QPixmap(nonScalableName); | 101 pmap = QPixmap(nonScalableName); |
101 if (!pmap.isNull()) return pmap; | 102 |
102 | 103 if (pmap.isNull() && size > 0) { |
103 if (size > 0) { | 104 // if that failed, load a scalable vector with the right |
105 // inversion and scale it | |
104 scalableName = makeScalableFilename(name, invert); | 106 scalableName = makeScalableFilename(name, invert); |
105 pmap = loadScalable(scalableName, size); | 107 pmap = loadScalable(scalableName, size); |
106 if (!pmap.isNull()) return pmap; | 108 } |
107 } | 109 |
108 | 110 if (pmap.isNull() && invert) { |
109 if (invert && shouldAutoInvert(name)) { | 111 // if that failed, and we were asking for an inverted pixmap, |
110 | 112 // that may mean we don't have an inverted version of it. We |
113 // could either auto-invert or use the uninverted version | |
111 nonScalableName = makeNonScalableFilename(name, size, false); | 114 nonScalableName = makeNonScalableFilename(name, size, false); |
112 pmap = QPixmap(nonScalableName); | 115 pmap = QPixmap(nonScalableName); |
113 if (!pmap.isNull()) return invertPixmap(pmap); | 116 |
114 | 117 if (pmap.isNull() && size > 0) { |
115 if (size > 0) { | |
116 scalableName = makeScalableFilename(name, false); | 118 scalableName = makeScalableFilename(name, false); |
117 pmap = loadScalable(scalableName, size); | 119 pmap = loadScalable(scalableName, size); |
118 if (!pmap.isNull()) return invertPixmap(pmap); | 120 } |
119 } | 121 |
120 } | 122 if (!pmap.isNull() && shouldAutoInvert(name)) { |
121 | 123 pmap = invertPixmap(pmap); |
122 return QPixmap(); | 124 } |
125 } | |
126 | |
127 return pmap; | |
123 } | 128 } |
124 | 129 |
125 QPixmap | 130 QPixmap |
126 IconLoader::loadScalable(QString name, int size) | 131 IconLoader::loadScalable(QString name, int size) |
127 { | 132 { |