qicon.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qicon.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5static QBasicAtomicInt serialNumCounter = { 1 };-
6-
7static void qt_cleanup_icon_cache();-
8namespace {-
9 struct IconCache : public QCache<QString, QIcon>-
10 {-
11 IconCache()-
12 {-
13-
14 qAddPostRoutine(qt_cleanup_icon_cache);-
15 }
never executed: end of block
0
16 };-
17}-
18-
19namespace { namespace Q_QGS_qtIconCache { typedef IconCache Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<IconCache, Q_QGS_qtIconCache::innerFunction, Q_QGS_qtIconCache::guard> qtIconCache;
0
20-
21static void qt_cleanup_icon_cache()-
22{-
23 qtIconCache()->clear();-
24}
never executed: end of block
0
25static qreal qt_effective_device_pixel_ratio(QWindow *window = 0)-
26{-
27 if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_UseHighDpiPixmaps)
!(static_cast<...ighDpiPixmaps)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
28 return
never executed: return qreal(1.0);
qreal(1.0);
never executed: return qreal(1.0);
0
29-
30 if (window
windowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
31 return
never executed: return window->devicePixelRatio();
window->devicePixelRatio();
never executed: return window->devicePixelRatio();
0
32-
33 return
never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();
(static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();
never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();
0
34}-
35-
36QIconPrivate::QIconPrivate()-
37 : engine(0), ref(1),-
38 serialNum(serialNumCounter.fetchAndAddRelaxed(1)),-
39 detach_no(0),-
40 is_mask(false)-
41{-
42}
never executed: end of block
0
43qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize)-
44{-
45 QSize targetSize = requestedSize * displayDevicePixelRatio;-
46 qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) +-
47 qreal(actualSize.height() / qreal(targetSize.height())));-
48 return
never executed: return qMax(qreal(1.0), displayDevicePixelRatio *scale);
qMax(qreal(1.0), displayDevicePixelRatio *scale);
never executed: return qMax(qreal(1.0), displayDevicePixelRatio *scale);
0
49}-
50-
51QPixmapIconEngine::QPixmapIconEngine()-
52{-
53}-
54-
55QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other)-
56 : QIconEngine(other), pixmaps(other.pixmaps)-
57{-
58}
never executed: end of block
0
59-
60QPixmapIconEngine::~QPixmapIconEngine()-
61{-
62}-
63-
64void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)-
65{-
66 QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0);-
67 QPixmap px = pixmap(pixmapSize, mode, state);-
68 painter->drawPixmap(rect, px);-
69}
never executed: end of block
0
70-
71static inline int area(const QSize &s) { return
never executed: return s.width() * s.height();
s.width() * s.height();
never executed: return s.width() * s.height();
}
0
72-
73-
74static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)-
75{-
76 int s = area(size);-
77 if (pa->size == QSize()
pa->size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
&& pa->pixmap.isNull()
pa->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
78 pa->pixmap = QPixmap(pa->fileName);-
79 pa->size = pa->pixmap.size();-
80 }
never executed: end of block
0
81 int a = area(pa->size);-
82 if (pb->size == QSize()
pb->size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
&& pb->pixmap.isNull()
pb->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
83 pb->pixmap = QPixmap(pb->fileName);-
84 pb->size = pb->pixmap.size();-
85 }
never executed: end of block
0
86 int b = area(pb->size);-
87 int res = a;-
88 if (qMin(a,b) >= s
qMin(a,b) >= sDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
89 res = qMin(a,b);
never executed: res = qMin(a,b);
0
90 else-
91 res = qMax(a,b);
never executed: res = qMax(a,b);
0
92 if (res == a
res == aDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
93 return
never executed: return pa;
pa;
never executed: return pa;
0
94 return
never executed: return pb;
pb;
never executed: return pb;
0
95}-
96-
97QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state)-
98{-
99 QPixmapIconEngineEntry *pe = 0;-
100 for (int i = 0; i < pixmaps.count()
i < pixmaps.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
101 if (pixmaps.at(i).mode == mode
pixmaps.at(i).mode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
&& pixmaps.at(i).state == state
pixmaps.at(i).state == stateDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
102 if (pe
peDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
103 pe = bestSizeMatch(size, &pixmaps[i], pe);
never executed: pe = bestSizeMatch(size, &pixmaps[i], pe);
0
104 else-
105 pe = &pixmaps[i];
never executed: pe = &pixmaps[i];
0
106 }-
107 return
never executed: return pe;
pe;
never executed: return pe;
0
108}-
109-
110-
111QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly)-
112{-
113 QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);-
114 while (!pe
!peDescription
TRUEnever evaluated
FALSEnever evaluated
){
0
115 QIcon::State oppositeState = (
(state == QIcon::On)Description
TRUEnever evaluated
FALSEnever evaluated
state == QIcon::On)
(state == QIcon::On)Description
TRUEnever evaluated
FALSEnever evaluated
? QIcon::Off : QIcon::On;
0
116 if (mode == QIcon::Disabled
mode == QIcon::DisabledDescription
TRUEnever evaluated
FALSEnever evaluated
|| mode == QIcon::Selected
mode == QIcon::SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
117 QIcon::Mode oppositeMode = (
(mode == QIcon::Disabled)Description
TRUEnever evaluated
FALSEnever evaluated
mode == QIcon::Disabled)
(mode == QIcon::Disabled)Description
TRUEnever evaluated
FALSEnever evaluated
? QIcon::Selected : QIcon::Disabled;
0
118 if ((
(pe = tryMatch...ormal, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Normal, state))
(pe = tryMatch...ormal, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
119 break;
never executed: break;
0
120 if ((
(pe = tryMatch...ctive, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Active, state))
(pe = tryMatch...ctive, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
121 break;
never executed: break;
0
122 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, mode, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
123 break;
never executed: break;
0
124 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Normal, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
125 break;
never executed: break;
0
126 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Active, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
127 break;
never executed: break;
0
128 if ((
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, oppositeMode, state))
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
129 break;
never executed: break;
0
130 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, oppositeMode, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
131 break;
never executed: break;
0
132 }
never executed: end of block
else {
0
133 QIcon::Mode oppositeMode = (
(mode == QIcon::Normal)Description
TRUEnever evaluated
FALSEnever evaluated
mode == QIcon::Normal)
(mode == QIcon::Normal)Description
TRUEnever evaluated
FALSEnever evaluated
? QIcon::Active : QIcon::Normal;
0
134 if ((
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, oppositeMode, state))
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
135 break;
never executed: break;
0
136 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, mode, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
137 break;
never executed: break;
0
138 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, oppositeMode, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
139 break;
never executed: break;
0
140 if ((
(pe = tryMatch...abled, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Disabled, state))
(pe = tryMatch...abled, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
141 break;
never executed: break;
0
142 if ((
(pe = tryMatch...ected, state))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Selected, state))
(pe = tryMatch...ected, state))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
143 break;
never executed: break;
0
144 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Disabled, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
145 break;
never executed: break;
0
146 if ((
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
pe = tryMatch(size, QIcon::Selected, oppositeState))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
147 break;
never executed: break;
0
148 }
never executed: end of block
0
149-
150 if (!pe
!peDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
151 return
never executed: return pe;
pe;
never executed: return pe;
0
152 }
never executed: end of block
0
153-
154 if (sizeOnly
sizeOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
? (pe->size.isNull()
pe->size.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| !pe->size.isValid()
!pe->size.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) : pe->pixmap.isNull()
sizeOnly ? (pe...ixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
155 pe->pixmap = QPixmap(pe->fileName);-
156 if (!pe->pixmap.isNull()
!pe->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
157 pe->size = pe->pixmap.size();
never executed: pe->size = pe->pixmap.size();
0
158 }
never executed: end of block
0
159-
160 return
never executed: return pe;
pe;
never executed: return pe;
0
161}-
162-
163QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)-
164{-
165 QPixmap pm;-
166 QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);-
167 if (pe
peDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
168 pm = pe->pixmap;
never executed: pm = pe->pixmap;
0
169-
170 if (pm.isNull()
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
171 int idx = pixmaps.count();-
172 while (--
--idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
idx >= 0
--idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
173 if (pe == &pixmaps.at(idx)
pe == &pixmaps.at(idx)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
174 pixmaps.remove(idx);-
175 break;
never executed: break;
0
176 }-
177 }
never executed: end of block
0
178 if (pixmaps.isEmpty()
pixmaps.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
179 return
never executed: return pm;
pm;
never executed: return pm;
0
180 else-
181 return
never executed: return pixmap(size, mode, state);
pixmap(size, mode, state);
never executed: return pixmap(size, mode, state);
0
182 }-
183-
184 QSize actualSize = pm.size();-
185 if (!actualSize.isNull()
!actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& (actualSize.width() > size.width()
actualSize.wid...> size.width()Description
TRUEnever evaluated
FALSEnever evaluated
|| actualSize.height() > size.height()
actualSize.hei... size.height()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
186 actualSize.scale(size, Qt::KeepAspectRatio);
never executed: actualSize.scale(size, Qt::KeepAspectRatio);
0
187-
188 QString key = QLatin1String("qt_")-
189 % HexString<quint64>(pm.cacheKey())-
190 % HexString<uint>(pe ? pe->mode : QIcon::Normal)-
191 % HexString<quint64>(QGuiApplication::palette().cacheKey())-
192 % HexString<uint>(actualSize.width())-
193 % HexString<uint>(actualSize.height());-
194-
195 if (mode == QIcon::Active
mode == QIcon::ActiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
196 if (QPixmapCache::find(key % HexString<uint>(mode), pm)
QPixmapCache::...nt>(mode), pm)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
197 return
never executed: return pm;
pm;
never executed: return pm;
0
198 if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)
QPixmapCache::...::Normal), pm)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
199 QPixmap active = pm;-
200 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
QGuiApplicatio...:instance())))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
201 active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
never executed: active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
0
202 if (pm.cacheKey() == active.cacheKey()
pm.cacheKey() ...ive.cacheKey()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
203 return
never executed: return pm;
pm;
never executed: return pm;
0
204 }
never executed: end of block
0
205 }
never executed: end of block
0
206-
207 if (!QPixmapCache::find(key % HexString<uint>(mode), pm)
!QPixmapCache:...nt>(mode), pm)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
208 if (pm.size() != actualSize
pm.size() != actualSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
209 pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
never executed: pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
0
210 if (pe->mode != mode
pe->mode != modeDescription
TRUEnever evaluated
FALSEnever evaluated
&& mode != QIcon::Normal
mode != QIcon::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
211 QPixmap generated = pm;-
212 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
QGuiApplicatio...:instance())))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
213 generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
never executed: generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
0
214 if (!generated.isNull()
!generated.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
215 pm = generated;
never executed: pm = generated;
0
216 }
never executed: end of block
0
217 QPixmapCache::insert(key % HexString<uint>(mode), pm);-
218 }
never executed: end of block
0
219 return
never executed: return pm;
pm;
never executed: return pm;
0
220}-
221-
222QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)-
223{-
224 QSize actualSize;-
225 if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true)
QPixmapIconEng..., state, true)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
226 actualSize = pe->size;
never executed: actualSize = pe->size;
0
227-
228 if (actualSize.isNull()
actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
229 return
never executed: return actualSize;
actualSize;
never executed: return actualSize;
0
230-
231 if (!actualSize.isNull()
!actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
&& (actualSize.width() > size.width()
actualSize.wid...> size.width()Description
TRUEnever evaluated
FALSEnever evaluated
|| actualSize.height() > size.height()
actualSize.hei... size.height()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
232 actualSize.scale(size, Qt::KeepAspectRatio);
never executed: actualSize.scale(size, Qt::KeepAspectRatio);
0
233 return
never executed: return actualSize;
actualSize;
never executed: return actualSize;
0
234}-
235-
236void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)-
237{-
238 if (!pixmap.isNull()
!pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
239 QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);-
240 if(pe
peDescription
TRUEnever evaluated
FALSEnever evaluated
&& pe->size == pixmap.size()
pe->size == pixmap.size()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
241 pe->pixmap = pixmap;-
242 pe->fileName.clear();-
243 }
never executed: end of block
else {
0
244 pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);-
245 }
never executed: end of block
0
246 }-
247}
never executed: end of block
0
248-
249-
250static inline int origIcoDepth(const QImage &image)-
251{-
252 const QString s = image.text(([]() -> QString { enum { Size = sizeof(u"" "_q_icoOrigDepth")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "_q_icoOrigDepth" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return
never executed: return qstring_literal_temp;
qstring_literal_temp;
never executed: return qstring_literal_temp;
}()));
0
253 return
never executed: return s.isEmpty() ? 32 : s.toInt();
s.isEmpty() ? 32 : s.toInt();
never executed: return s.isEmpty() ? 32 : s.toInt();
0
254}-
255-
256static inline int findBySize(const QVector<QImage> &images, const QSize &size)-
257{-
258 for (int i = 0; i < images.size()
i < images.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
259 if (images.at(i).size() == size
images.at(i).size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
260 return
never executed: return i;
i;
never executed: return i;
0
261 }
never executed: end of block
0
262 return
never executed: return -1;
-1;
never executed: return -1;
0
263}-
264-
265-
266namespace {-
267class ImageReader-
268{-
269public:-
270 ImageReader(const QString &fileName) : m_reader(fileName), m_atEnd(false) {}
never executed: end of block
0
271-
272 QByteArray format() const { return
never executed: return m_reader.format();
m_reader.format();
never executed: return m_reader.format();
}
0
273-
274 bool read(QImage *image)-
275 {-
276 if (m_atEnd
m_atEndDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
277 return
never executed: return false;
false;
never executed: return false;
0
278 *image = m_reader.read();-
279 if (!image->size().isValid()
!image->size().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
280 m_atEnd = true;-
281 return
never executed: return false;
false;
never executed: return false;
0
282 }-
283 m_atEnd = !m_reader.jumpToNextImage();-
284 return
never executed: return true;
true;
never executed: return true;
0
285 }-
286-
287private:-
288 QImageReader m_reader;-
289 bool m_atEnd;-
290};-
291}-
292-
293void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)-
294{-
295 if (fileName.isEmpty()
fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
296 return;
never executed: return;
0
297 const QString abs = fileName.startsWith(QLatin1Char(':'))
fileName.start...tin1Char(':'))Description
TRUEnever evaluated
FALSEnever evaluated
? fileName : QFileInfo(fileName).absoluteFilePath();
0
298 const bool ignoreSize = !size.isValid();-
299 ImageReader imageReader(abs);-
300 const QByteArray format = imageReader.format();-
301 if (format.isEmpty()
format.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
302 return;
never executed: return;
0
303 QImage image;-
304 if (format != "ico"
format != "ico"Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
305 if (ignoreSize
ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
306 while (imageReader.read(&image)
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
307 pixmaps += QPixmapIconEngineEntry(abs, image, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, image, mode, state);
0
308 }
never executed: end of block
else {
0
309-
310 while (imageReader.read(&image)
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
&& image.size() != size
image.size() != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {}
never executed: end of block
0
311 pixmaps += image.size() == size
image.size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
?
0
312 QPixmapIconEngineEntry(abs, image, mode, state) : QPixmapIconEngineEntry(abs, size, mode, state);-
313 }
never executed: end of block
0
314 return;
never executed: return;
0
315 }-
316-
317-
318-
319-
320 QVector<QImage> icoImages;-
321 while (imageReader.read(&image)
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
322 if (ignoreSize
ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
|| image.size() == size
image.size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
323 const int position = findBySize(icoImages, image.size());-
324 if (position >= 0
position >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
325 if (origIcoDepth(image) > origIcoDepth(icoImages.at(position))
origIcoDepth(i....at(position))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
326 icoImages[position] = image;
never executed: icoImages[position] = image;
0
327 }
never executed: end of block
else {
0
328 icoImages.append(image);-
329 }
never executed: end of block
0
330 }-
331 }
never executed: end of block
0
332 for (const QImage &i : qAsConst(icoImages))-
333 pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
0
334 if (icoImages.isEmpty()
icoImages.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& !ignoreSize
!ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
335 pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);
0
336}
never executed: end of block
0
337-
338QString QPixmapIconEngine::key() const-
339{-
340 return
never executed: return QLatin1String("QPixmapIconEngine");
QLatin1String("QPixmapIconEngine");
never executed: return QLatin1String("QPixmapIconEngine");
0
341}-
342-
343QIconEngine *QPixmapIconEngine::clone() const-
344{-
345 return
never executed: return new QPixmapIconEngine(*this);
new QPixmapIconEngine(*this);
never executed: return new QPixmapIconEngine(*this);
0
346}-
347-
348bool QPixmapIconEngine::read(QDataStream &in)-
349{-
350 int num_entries;-
351 QPixmap pm;-
352 QString fileName;-
353 QSize sz;-
354 uint mode;-
355 uint state;-
356-
357 in >> num_entries;-
358 for (int i=0; i < num_entries
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
359 if (in.atEnd()
in.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
360 pixmaps.clear();-
361 return
never executed: return false;
false;
never executed: return false;
0
362 }-
363 in >> pm;-
364 in >> fileName;-
365 in >> sz;-
366 in >> mode;-
367 in >> state;-
368 if (pm.isNull()
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
369 addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));-
370 }
never executed: end of block
else {
0
371 QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));-
372 pe.pixmap = pm;-
373 pixmaps += pe;-
374 }
never executed: end of block
0
375 }-
376 return
never executed: return true;
true;
never executed: return true;
0
377}-
378-
379bool QPixmapIconEngine::write(QDataStream &out) const-
380{-
381 int num_entries = pixmaps.size();-
382 out << num_entries;-
383 for (int i=0; i < num_entries
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
384 if (pixmaps.at(i).pixmap.isNull()
pixmaps.at(i).pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
385 out << QPixmap(pixmaps.at(i).fileName);
never executed: out << QPixmap(pixmaps.at(i).fileName);
0
386 else-
387 out << pixmaps.at(i).pixmap;
never executed: out << pixmaps.at(i).pixmap;
0
388 out << pixmaps.at(i).fileName;-
389 out << pixmaps.at(i).size;-
390 out << (uint) pixmaps.at(i).mode;-
391 out << (uint) pixmaps.at(i).state;-
392 }
never executed: end of block
0
393 return
never executed: return true;
true;
never executed: return true;
0
394}-
395-
396void QPixmapIconEngine::virtual_hook(int id, void *data)-
397{-
398 switch (id) {-
399 case
never executed: case QIconEngine::AvailableSizesHook:
QIconEngine::AvailableSizesHook:
never executed: case QIconEngine::AvailableSizesHook:
{
0
400 QIconEngine::AvailableSizesArgument &arg =-
401 *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);-
402 arg.sizes.clear();-
403 for (int i = 0; i < pixmaps.size()
i < pixmaps.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
404 QPixmapIconEngineEntry &pe = pixmaps[i];-
405 if (pe.size == QSize()
pe.size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
&& pe.pixmap.isNull()
pe.pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
406 pe.pixmap = QPixmap(pe.fileName);-
407 pe.size = pe.pixmap.size();-
408 }
never executed: end of block
0
409 if (pe.mode == arg.mode
pe.mode == arg.modeDescription
TRUEnever evaluated
FALSEnever evaluated
&& pe.state == arg.state
pe.state == arg.stateDescription
TRUEnever evaluated
FALSEnever evaluated
&& !pe.size.isEmpty()
!pe.size.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
410 arg.sizes.push_back(pe.size);
never executed: arg.sizes.push_back(pe.size);
0
411 }
never executed: end of block
0
412 break;
never executed: break;
0
413 }-
414 default
never executed: default:
:
never executed: default:
0
415 QIconEngine::virtual_hook(id, data);-
416 }
never executed: end of block
0
417}-
418-
419namespace { namespace Q_QGS_loader { typedef QFactoryLoader Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
) guard.store(QtGlobalStatic::Destroyed);
never executed: guard.store(QtGlobalStatic::Destroyed);
}
never executed: end of block
}; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ("org.qt-project.Qt.QIconEngineFactoryInterface", QLatin1String("/iconengines"), Qt::CaseInsensitive))) : value ("org.qt-project.Qt.QIconEngineFactoryInterface", QLatin1String("/iconengines"), Qt::CaseInsensitive) { guard.store(QtGlobalStatic::Initialized); } } holder; return
never executed: return &holder.value;
&holder.value;
never executed: return &holder.value;
} } } static QGlobalStatic<QFactoryLoader, Q_QGS_loader::innerFunction, Q_QGS_loader::guard> loader;
0
420-
421-
422QFactoryLoader *qt_iconEngineFactoryLoader()-
423{-
424 return
never executed: return loader();
loader();
never executed: return loader();
0
425}-
426QIcon::QIcon() noexcept-
427 : d(0)-
428{-
429}
never executed: end of block
0
430-
431-
432-
433-
434QIcon::QIcon(const QPixmap &pixmap)-
435 :d(0)-
436{-
437 addPixmap(pixmap);-
438}
never executed: end of block
0
439-
440-
441-
442-
443QIcon::QIcon(const QIcon &other)-
444 :d(other.d)-
445{-
446 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
447 d->ref.ref();
never executed: d->ref.ref();
0
448}
never executed: end of block
0
449QIcon::QIcon(const QString &fileName)-
450 : d(0)-
451{-
452 addFile(fileName);-
453}
never executed: end of block
0
454-
455-
456-
457-
458-
459-
460QIcon::QIcon(QIconEngine *engine)-
461 :d(new QIconPrivate)-
462{-
463 d->engine = engine;-
464}
never executed: end of block
0
465-
466-
467-
468-
469QIcon::~QIcon()-
470{-
471 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
472 delete d;
never executed: delete d;
0
473}
never executed: end of block
0
474-
475-
476-
477-
478-
479QIcon &QIcon::operator=(const QIcon &other)-
480{-
481 if (other.d
other.dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
482 other.d->ref.ref();
never executed: other.d->ref.ref();
0
483 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
484 delete d;
never executed: delete d;
0
485 d = other.d;-
486 return
never executed: return *this;
*this;
never executed: return *this;
0
487}-
488QIcon::operator QVariant() const-
489{-
490 return
never executed: return QVariant(QVariant::Icon, this);
QVariant(QVariant::Icon, this);
never executed: return QVariant(QVariant::Icon, this);
0
491}-
492qint64 QIcon::cacheKey() const-
493{-
494 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
495 return
never executed: return 0;
0;
never executed: return 0;
0
496 return
never executed: return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
(((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
never executed: return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
0
497}-
498QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const-
499{-
500 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
501 return
never executed: return QPixmap();
QPixmap();
never executed: return QPixmap();
0
502 return
never executed: return pixmap(0, size, mode, state);
pixmap(0, size, mode, state);
never executed: return pixmap(0, size, mode, state);
0
503}-
504QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const-
505{-
506 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
507 return
never executed: return QSize();
QSize();
never executed: return QSize();
0
508 return
never executed: return actualSize(0, size, mode, state);
actualSize(0, size, mode, state);
never executed: return actualSize(0, size, mode, state);
0
509}-
510QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state) const-
511{-
512 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
513 return
never executed: return QPixmap();
QPixmap();
never executed: return QPixmap();
0
514-
515 qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);-
516-
517-
518 if (!(devicePixelRatio > 1.0)
!(devicePixelRatio > 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
519 QPixmap pixmap = d->engine->pixmap(size, mode, state);-
520 pixmap.setDevicePixelRatio(1.0);-
521 return
never executed: return pixmap;
pixmap;
never executed: return pixmap;
0
522 }-
523-
524-
525 QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state);-
526 pixmap.setDevicePixelRatio(d->pixmapDevicePixelRatio(devicePixelRatio, size, pixmap.size()));-
527 return
never executed: return pixmap;
pixmap;
never executed: return pixmap;
0
528}-
529QSize QIcon::actualSize(QWindow *window, const QSize &size, Mode mode, State state) const-
530{-
531 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
532 return
never executed: return QSize();
QSize();
never executed: return QSize();
0
533-
534 qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);-
535-
536-
537 if (!(devicePixelRatio > 1.0)
!(devicePixelRatio > 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
538 return
never executed: return d->engine->actualSize(size, mode, state);
d->engine->actualSize(size, mode, state);
never executed: return d->engine->actualSize(size, mode, state);
0
539-
540 QSize actualSize = d->engine->actualSize(size * devicePixelRatio, mode, state);-
541 return
never executed: return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);
actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);
never executed: return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);
0
542}-
543-
544-
545-
546-
547-
548-
549-
550void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const-
551{-
552 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !painter
!painterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
553 return;
never executed: return;
0
554-
555-
556 const QSize size = d->engine->actualSize(rect.size(), mode, state);-
557 alignment = QGuiApplicationPrivate::visualAlignment(painter->layoutDirection(), alignment);-
558 int x = rect.x();-
559 int y = rect.y();-
560 int w = size.width();-
561 int h = size.height();-
562 if ((
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignVCenter) == Qt::AlignVCenter
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
563 y += rect.size().height()/2 - h/2;
never executed: y += rect.size().height()/2 - h/2;
0
564 else if ((
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignBottom) == Qt::AlignBottom
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
565 y += rect.size().height() - h;
never executed: y += rect.size().height() - h;
0
566 if ((
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignRight) == Qt::AlignRight
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
567 x += rect.size().width() - w;
never executed: x += rect.size().width() - w;
0
568 else if ((
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
alignment & Qt::AlignHCenter) == Qt::AlignHCenter
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
569 x += rect.size().width()/2 - w/2;
never executed: x += rect.size().width()/2 - w/2;
0
570 QRect alignedRect(x, y, w, h);-
571-
572 d->engine->paint(painter, alignedRect, mode, state);-
573}
never executed: end of block
0
574bool QIcon::isNull() const-
575{-
576 return
never executed: return !d || d->engine->isNull();
!d || d->engine->isNull();
never executed: return !d || d->engine->isNull();
0
577}-
578-
579-
580-
581bool QIcon::isDetached() const-
582{-
583 return
never executed: return !d || d->ref.load() == 1;
!d || d->ref.load() == 1;
never executed: return !d || d->ref.load() == 1;
0
584}-
585-
586-
587-
588void QIcon::detach()-
589{-
590 if (d
dDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
591 if (d->engine->isNull()
d->engine->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
592 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
593 delete d;
never executed: delete d;
0
594 d = 0;-
595 return;
never executed: return;
0
596 } else if (d->ref.load() != 1
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 QIconPrivate *x = new QIconPrivate;-
598 x->engine = d->engine->clone();-
599 if (!d->ref.deref()
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
600 delete d;
never executed: delete d;
0
601 d = x;-
602 }
never executed: end of block
0
603 ++d->detach_no;-
604 }
never executed: end of block
0
605}
never executed: end of block
0
606void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)-
607{-
608 if (pixmap.isNull()
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
609 return;
never executed: return;
0
610 detach();-
611 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
612 d = new QIconPrivate;-
613 d->engine = new QPixmapIconEngine;-
614 }
never executed: end of block
0
615 d->engine->addPixmap(pixmap, mode, state);-
616}
never executed: end of block
0
617-
618static QIconEngine *iconEngineFromSuffix(const QString &fileName, const QString &suffix)-
619{-
620 if (!suffix.isEmpty()
!suffix.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
621 const int index = loader()->indexOf(suffix);-
622 if (index != -1
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
623 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
QIconEnginePlu...stance(index))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
624 return
never executed: return factory->create(fileName);
factory->create(fileName);
never executed: return factory->create(fileName);
0
625 }-
626 }
never executed: end of block
0
627 }
never executed: end of block
0
628 return
never executed: return nullptr;
nullptr;
never executed: return nullptr;
0
629}-
630void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state)-
631{-
632 if (fileName.isEmpty()
fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
633 return;
never executed: return;
0
634 detach();-
635 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
636-
637 QFileInfo info(fileName);-
638 QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix());-
639-
640 if (!engine
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
641 engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
never executed: engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
0
642-
643 d = new QIconPrivate;-
644 d->engine = engine
engineDescription
TRUEnever evaluated
FALSEnever evaluated
? engine : new QPixmapIconEngine;
0
645 }
never executed: end of block
0
646-
647 d->engine->addFile(fileName, size, mode, state);-
648-
649-
650 QString atNxFileName = qt_findAtNxFile(fileName, (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio());-
651 if (atNxFileName != fileName
atNxFileName != fileNameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
652 d->engine->addFile(atNxFileName, size, mode, state);
never executed: d->engine->addFile(atNxFileName, size, mode, state);
0
653}
never executed: end of block
0
654-
655-
656-
657-
658-
659-
660-
661QList<QSize> QIcon::availableSizes(Mode mode, State state) const-
662{-
663 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->engine
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
664 return
never executed: return QList<QSize>();
QList<QSize>();
never executed: return QList<QSize>();
0
665 return
never executed: return d->engine->availableSizes(mode, state);
d->engine->availableSizes(mode, state);
never executed: return d->engine->availableSizes(mode, state);
0
666}-
667QString QIcon::name() const-
668{-
669 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
|| !d->engine
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
670 return
never executed: return QString();
QString();
never executed: return QString();
0
671 return
never executed: return d->engine->iconName();
d->engine->iconName();
never executed: return d->engine->iconName();
0
672}-
673-
674-
675-
676-
677-
678-
679-
680void QIcon::setThemeSearchPaths(const QStringList &paths)-
681{-
682 QIconLoader::instance()->setThemeSearchPath(paths);-
683}
never executed: end of block
0
684QStringList QIcon::themeSearchPaths()-
685{-
686 return
never executed: return QIconLoader::instance()->themeSearchPaths();
QIconLoader::instance()->themeSearchPaths();
never executed: return QIconLoader::instance()->themeSearchPaths();
0
687}-
688void QIcon::setThemeName(const QString &name)-
689{-
690 QIconLoader::instance()->setThemeName(name);-
691}
never executed: end of block
0
692QString QIcon::themeName()-
693{-
694 return
never executed: return QIconLoader::instance()->themeName();
QIconLoader::instance()->themeName();
never executed: return QIconLoader::instance()->themeName();
0
695}-
696QIcon QIcon::fromTheme(const QString &name)-
697{-
698 QIcon icon;-
699-
700 if (qtIconCache()->contains(name)
qtIconCache()->contains(name)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
701 icon = *qtIconCache()->object(name);-
702 }
never executed: end of block
else if (QDir::isAbsolutePath(name)
QDir::isAbsolutePath(name)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
703 return
never executed: return QIcon(name);
QIcon(name);
never executed: return QIcon(name);
0
704 } else {-
705 QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();-
706 bool hasUserTheme = QIconLoader::instance()->hasUserTheme();-
707 QIconEngine * const engine = (platformTheme
platformThemeDescription
TRUEnever evaluated
FALSEnever evaluated
&& !hasUserTheme
!hasUserThemeDescription
TRUEnever evaluated
FALSEnever evaluated
) ? platformTheme->createIconEngine(name)
0
708 : new QIconLoaderEngine(name);-
709 QIcon *cachedIcon = new QIcon(engine);-
710 icon = *cachedIcon;-
711 qtIconCache()->insert(name, cachedIcon);-
712 }
never executed: end of block
0
713-
714 return
never executed: return icon;
icon;
never executed: return icon;
0
715}-
716QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)-
717{-
718 QIcon icon = fromTheme(name);-
719-
720 if (icon.isNull()
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
|| icon.availableSizes().isEmpty()
icon.available...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
721 return
never executed: return fallback;
fallback;
never executed: return fallback;
0
722-
723 return
never executed: return icon;
icon;
never executed: return icon;
0
724}-
725bool QIcon::hasThemeIcon(const QString &name)-
726{-
727 QIcon icon = fromTheme(name);-
728-
729 return
never executed: return icon.name() == name;
icon.name() == name;
never executed: return icon.name() == name;
0
730}-
731void QIcon::setIsMask(bool isMask)-
732{-
733 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
734 d = new QIconPrivate;-
735 d->engine = new QPixmapIconEngine;-
736 }
never executed: end of block
else {
0
737 detach();-
738 }
never executed: end of block
0
739 d->is_mask = isMask;-
740}
never executed: end of block
0
741bool QIcon::isMask() const-
742{-
743 if (!d
!dDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
744 return
never executed: return false;
false;
never executed: return false;
0
745 return
never executed: return d->is_mask;
d->is_mask;
never executed: return d->is_mask;
0
746}-
747QDataStream &operator<<(QDataStream &s, const QIcon &icon)-
748{-
749 if (s.version() >= QDataStream::Qt_4_3
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
750 if (icon.isNull()
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
751 s << QString();-
752 }
never executed: end of block
else {
0
753 s << icon.d->engine->key();-
754 icon.d->engine->write(s);-
755 }
never executed: end of block
0
756 } else if (s.version() == QDataStream::Qt_4_2
s.version() ==...Stream::Qt_4_2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
757 if (icon.isNull()
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
758 s << 0;-
759 }
never executed: end of block
else {
0
760 QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);-
761 int num_entries = engine->pixmaps.size();-
762 s << num_entries;-
763 for (int i=0; i < num_entries
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
764 s << engine->pixmaps.at(i).pixmap;-
765 s << engine->pixmaps.at(i).fileName;-
766 s << engine->pixmaps.at(i).size;-
767 s << (uint) engine->pixmaps.at(i).mode;-
768 s << (uint) engine->pixmaps.at(i).state;-
769 }
never executed: end of block
0
770 }
never executed: end of block
0
771 } else {-
772 s << QPixmap(icon.pixmap(22,22));-
773 }
never executed: end of block
0
774 return
never executed: return s;
s;
never executed: return s;
0
775}-
776QDataStream &operator>>(QDataStream &s, QIcon &icon)-
777{-
778 if (s.version() >= QDataStream::Qt_4_3
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
779 icon = QIcon();-
780 QString key;-
781 s >> key;-
782 if (key == QLatin1String("QPixmapIconEngine")
key == QLatin1...apIconEngine")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
783 icon.d = new QIconPrivate;-
784 QIconEngine *engine = new QPixmapIconEngine;-
785 icon.d->engine = engine;-
786 engine->read(s);-
787 }
never executed: end of block
else if (key == QLatin1String("QIconLoaderEngine")
key == QLatin1...LoaderEngine")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
788 icon.d = new QIconPrivate;-
789 QIconEngine *engine = new QIconLoaderEngine();-
790 icon.d->engine = engine;-
791 engine->read(s);-
792 }
never executed: end of block
else {
0
793 const int index = loader()->indexOf(key);-
794 if (index != -1
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
795 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
QIconEnginePlu...stance(index))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
796 if (QIconEngine *engine= factory->create()
QIconEngine *e...tory->create()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
797 icon.d = new QIconPrivate;-
798 icon.d->engine = engine;-
799 engine->read(s);-
800 }
never executed: end of block
0
801 }
never executed: end of block
0
802 }
never executed: end of block
0
803 }
never executed: end of block
0
804 } else if (s.version() == QDataStream::Qt_4_2
s.version() ==...Stream::Qt_4_2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
805 icon = QIcon();-
806 int num_entries;-
807 QPixmap pm;-
808 QString fileName;-
809 QSize sz;-
810 uint mode;-
811 uint state;-
812-
813 s >> num_entries;-
814 for (int i=0; i < num_entries
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
815 s >> pm;-
816 s >> fileName;-
817 s >> sz;-
818 s >> mode;-
819 s >> state;-
820 if (pm.isNull()
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
821 icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
0
822 else-
823 icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
0
824 }-
825 }
never executed: end of block
else {
0
826 QPixmap pm;-
827 s >> pm;-
828 icon.addPixmap(pm);-
829 }
never executed: end of block
0
830 return
never executed: return s;
s;
never executed: return s;
0
831}-
832-
833-
834-
835-
836QDebug operator<<(QDebug dbg, const QIcon &i)-
837{-
838 QDebugStateSaver saver(dbg);-
839 dbg.resetFormat();-
840 dbg.nospace();-
841 dbg << "QIcon(";-
842 if (i.isNull()
i.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
843 dbg << "null";-
844 }
never executed: end of block
else {
0
845 if (!i.name().isEmpty()
!i.name().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
846 dbg << i.name() << ',';
never executed: dbg << i.name() << ',';
0
847 dbg << "availableSizes[normal,Off]=" << i.availableSizes()-
848 << ",cacheKey=" << showbase << hex << i.cacheKey() << dec << noshowbase;-
849 }
never executed: end of block
0
850 dbg << ')';-
851 return
never executed: return dbg;
dbg;
never executed: return dbg;
0
852}-
853QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,-
854 qreal *sourceDevicePixelRatio)-
855{-
856 if (targetDevicePixelRatio <= 1.0
targetDevicePixelRatio <= 1.0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
857 return
never executed: return baseFileName;
baseFileName;
never executed: return baseFileName;
0
858-
859 static bool disableNxImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING");-
860 if (disableNxImageLoading
disableNxImageLoadingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
861 return
never executed: return baseFileName;
baseFileName;
never executed: return baseFileName;
0
862-
863 int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.'));-
864 if (dotIndex == -1
dotIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
865 dotIndex = baseFileName.size();
never executed: dotIndex = baseFileName.size();
0
866-
867 QString atNxfileName = baseFileName;-
868 atNxfileName.insert(dotIndex, QLatin1String("@2x"));-
869-
870 for (int n = qMin(qCeil(targetDevicePixelRatio), 9); n > 1
n > 1Description
TRUEnever evaluated
FALSEnever evaluated
; --n) {
0
871 atNxfileName[dotIndex + 1] = QLatin1Char('0' + n);-
872 if (QFile::exists(atNxfileName)
QFile::exists(atNxfileName)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
873 if (sourceDevicePixelRatio
sourceDevicePixelRatioDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
874 *
never executed: *sourceDevicePixelRatio = n;
sourceDevicePixelRatio = n;
never executed: *sourceDevicePixelRatio = n;
0
875 return
never executed: return atNxfileName;
atNxfileName;
never executed: return atNxfileName;
0
876 }-
877 }
never executed: end of block
0
878-
879 return
never executed: return baseFileName;
baseFileName;
never executed: return baseFileName;
0
880}-
881-
882-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9