qicon.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/image/qicon.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>-
5** Contact: https://www.qt.io/licensing/-
6**-
7** This file is part of the QtGui module of the Qt Toolkit.-
8**-
9** $QT_BEGIN_LICENSE:LGPL$-
10** Commercial License Usage-
11** Licensees holding valid commercial Qt licenses may use this file in-
12** accordance with the commercial license agreement provided with the-
13** Software or, alternatively, in accordance with the terms contained in-
14** a written agreement between you and The Qt Company. For licensing terms-
15** and conditions see https://www.qt.io/terms-conditions. For further-
16** information use the contact form at https://www.qt.io/contact-us.-
17**-
18** GNU Lesser General Public License Usage-
19** Alternatively, this file may be used under the terms of the GNU Lesser-
20** General Public License version 3 as published by the Free Software-
21** Foundation and appearing in the file LICENSE.LGPL3 included in the-
22** packaging of this file. Please review the following information to-
23** ensure the GNU Lesser General Public License version 3 requirements-
24** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
25**-
26** GNU General Public License Usage-
27** Alternatively, this file may be used under the terms of the GNU-
28** General Public License version 2.0 or (at your option) the GNU General-
29** Public license version 3 or any later version approved by the KDE Free-
30** Qt Foundation. The licenses are as published by the Free Software-
31** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
32** included in the packaging of this file. Please review the following-
33** information to ensure the GNU General Public License requirements will-
34** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
35** https://www.gnu.org/licenses/gpl-3.0.html.-
36**-
37** $QT_END_LICENSE$-
38**-
39****************************************************************************/-
40-
41#include "qicon.h"-
42#include "qicon_p.h"-
43#include "qiconengine.h"-
44#include "qiconengineplugin.h"-
45#include "qimagereader.h"-
46#include "private/qfactoryloader_p.h"-
47#include "private/qiconloader_p.h"-
48#include "qpainter.h"-
49#include "qfileinfo.h"-
50#include <qmimedatabase.h>-
51#include <qmimetype.h>-
52#include "qpixmapcache.h"-
53#include "qvariant.h"-
54#include "qcache.h"-
55#include "qdebug.h"-
56#include "qdir.h"-
57#include "qpalette.h"-
58#include "qmath.h"-
59-
60#include "private/qhexstring_p.h"-
61#include "private/qguiapplication_p.h"-
62#include "qpa/qplatformtheme.h"-
63-
64#ifndef QT_NO_ICON-
65QT_BEGIN_NAMESPACE-
66-
67/*!-
68 \enum QIcon::Mode-
69-
70 This enum type describes the mode for which a pixmap is intended-
71 to be used. The currently defined modes are:-
72-
73 \value Normal-
74 Display the pixmap when the user is-
75 not interacting with the icon, but the-
76 functionality represented by the icon is available.-
77 \value Disabled-
78 Display the pixmap when the-
79 functionality represented by the icon is not available.-
80 \value Active-
81 Display the pixmap when the-
82 functionality represented by the icon is available and-
83 the user is interacting with the icon, for example, moving the-
84 mouse over it or clicking it.-
85 \value Selected-
86 Display the pixmap when the item represented by the icon is-
87 selected.-
88*/-
89-
90/*!-
91 \enum QIcon::State-
92-
93 This enum describes the state for which a pixmap is intended to be-
94 used. The \e state can be:-
95-
96 \value Off Display the pixmap when the widget is in an "off" state-
97 \value On Display the pixmap when the widget is in an "on" state-
98*/-
99-
100static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1);-
101-
102static void qt_cleanup_icon_cache();-
103namespace {-
104 struct IconCache : public QCache<QString, QIcon>-
105 {-
106 IconCache()-
107 {-
108 // ### note: won't readd if QApplication is re-created!-
109 qAddPostRoutine(qt_cleanup_icon_cache);-
110 }
never executed: end of block
0
111 };-
112}-
113-
114Q_GLOBAL_STATIC(IconCache, qtIconCache)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
115-
116static void qt_cleanup_icon_cache()-
117{-
118 qtIconCache()->clear();-
119}
never executed: end of block
0
120-
121/*! \internal-
122-
123 Returns the effective device pixel ratio, using-
124 the provided window pointer if possible.-
125-
126 if Qt::AA_UseHighDpiPixmaps is not set this function-
127 returns 1.0 to keep non-hihdpi aware code working.-
128*/-
129static qreal qt_effective_device_pixel_ratio(QWindow *window = 0)-
130{-
131 if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps))
!(static_cast<...ighDpiPixmaps)Description
TRUEnever evaluated
FALSEnever evaluated
0
132 return qreal(1.0);
never executed: return qreal(1.0);
0
133-
134 if (window)
windowDescription
TRUEnever evaluated
FALSEnever evaluated
0
135 return window->devicePixelRatio();
never executed: return window->devicePixelRatio();
0
136-
137 return qApp->devicePixelRatio(); // Don't know which window to target.
never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();
0
138}-
139-
140QIconPrivate::QIconPrivate()-
141 : engine(0), ref(1),-
142 serialNum(serialNumCounter.fetchAndAddRelaxed(1)),-
143 detach_no(0),-
144 is_mask(false)-
145{-
146}
never executed: end of block
0
147-
148/*! \internal-
149 Computes the displayDevicePixelRatio for a pixmap.-
150-
151 If displayDevicePixelRatio is 1.0 the reurned value is 1.0, always.-
152-
153 For a displayDevicePixelRatio of 2.0 the returned value will be between-
154 1.0 and 2.0, depending on requestedSize and actualsize:-
155 * If actualsize < requestedSize : 1.0 (not enough pixels for a normal-dpi pixmap)-
156 * If actualsize == requestedSize * 2.0 : 2.0 (enough pixels for a high-dpi pixmap)-
157 * else : a scaled value between 1.0 and 2.0. (pixel count is between normal-dpi and high-dpi)-
158*/-
159qreal QIconPrivate::pixmapDevicePixelRatio(qreal displayDevicePixelRatio, const QSize &requestedSize, const QSize &actualSize)-
160{-
161 QSize targetSize = requestedSize * displayDevicePixelRatio;-
162 qreal scale = 0.5 * (qreal(actualSize.width()) / qreal(targetSize.width()) +-
163 qreal(actualSize.height() / qreal(targetSize.height())));-
164 return qMax(qreal(1.0), displayDevicePixelRatio *scale);
never executed: return qMax(qreal(1.0), displayDevicePixelRatio *scale);
0
165}-
166-
167QPixmapIconEngine::QPixmapIconEngine()-
168{-
169}-
170-
171QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other)-
172 : QIconEngine(other), pixmaps(other.pixmaps)-
173{-
174}
never executed: end of block
0
175-
176QPixmapIconEngine::~QPixmapIconEngine()-
177{-
178}-
179-
180void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)-
181{-
182 QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0);-
183 QPixmap px = pixmap(pixmapSize, mode, state);-
184 painter->drawPixmap(rect, px);-
185}
never executed: end of block
0
186-
187static
never executed: return s.width() * s.height();
inline int area(const QSize &s) { return s.width() * s.height(); }
never executed: return s.width() * s.height();
0
188-
189// returns the smallest of the two that is still larger than or equal to size.-
190static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)-
191{-
192 int s = area(size);-
193 if (pa->size == QSize() && pa->pixmap.isNull()) {
pa->size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
pa->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
194 pa->pixmap = QPixmap(pa->fileName);-
195 pa->size = pa->pixmap.size();-
196 }
never executed: end of block
0
197 int a = area(pa->size);-
198 if (pb->size == QSize() && pb->pixmap.isNull()) {
pb->size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
pb->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
199 pb->pixmap = QPixmap(pb->fileName);-
200 pb->size = pb->pixmap.size();-
201 }
never executed: end of block
0
202 int b = area(pb->size);-
203 int res = a;-
204 if (qMin(a,b) >= s)
qMin(a,b) >= sDescription
TRUEnever evaluated
FALSEnever evaluated
0
205 res = qMin(a,b);
never executed: res = qMin(a,b);
0
206 else-
207 res = qMax(a,b);
never executed: res = qMax(a,b);
0
208 if (res == a)
res == aDescription
TRUEnever evaluated
FALSEnever evaluated
0
209 return pa;
never executed: return pa;
0
210 return pb;
never executed: return pb;
0
211}-
212-
213QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state)-
214{-
215 QPixmapIconEngineEntry *pe = 0;-
216 for (int i = 0; i < pixmaps.count(); ++i)
i < pixmaps.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
217 if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
pixmaps.at(i).mode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
pixmaps.at(i).state == stateDescription
TRUEnever evaluated
FALSEnever evaluated
0
218 if (pe)
peDescription
TRUEnever evaluated
FALSEnever evaluated
0
219 pe = bestSizeMatch(size, &pixmaps[i], pe);
never executed: pe = bestSizeMatch(size, &pixmaps[i], pe);
0
220 else-
221 pe = &pixmaps[i];
never executed: pe = &pixmaps[i];
0
222 }-
223 return pe;
never executed: return pe;
0
224}-
225-
226-
227QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly)-
228{-
229 QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);-
230 while (!pe){
!peDescription
TRUEnever evaluated
FALSEnever evaluated
0
231 QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On;
(state == QIcon::On)Description
TRUEnever evaluated
FALSEnever evaluated
0
232 if (mode == QIcon::Disabled || mode == QIcon::Selected) {
mode == QIcon::DisabledDescription
TRUEnever evaluated
FALSEnever evaluated
mode == QIcon::SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
233 QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled;
(mode == QIcon::Disabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
234 if ((pe = tryMatch(size, QIcon::Normal, state)))
(pe = tryMatch...ormal, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
235 break;
never executed: break;
0
236 if ((pe = tryMatch(size, QIcon::Active, state)))
(pe = tryMatch...ctive, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
237 break;
never executed: break;
0
238 if ((pe = tryMatch(size, mode, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
239 break;
never executed: break;
0
240 if ((pe = tryMatch(size, QIcon::Normal, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
241 break;
never executed: break;
0
242 if ((pe = tryMatch(size, QIcon::Active, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
243 break;
never executed: break;
0
244 if ((pe = tryMatch(size, oppositeMode, state)))
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
245 break;
never executed: break;
0
246 if ((pe = tryMatch(size, oppositeMode, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
247 break;
never executed: break;
0
248 } else {
never executed: end of block
0
249 QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal;
(mode == QIcon::Normal)Description
TRUEnever evaluated
FALSEnever evaluated
0
250 if ((pe = tryMatch(size, oppositeMode, state)))
(pe = tryMatch...eMode, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
251 break;
never executed: break;
0
252 if ((pe = tryMatch(size, mode, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
253 break;
never executed: break;
0
254 if ((pe = tryMatch(size, oppositeMode, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
255 break;
never executed: break;
0
256 if ((pe = tryMatch(size, QIcon::Disabled, state)))
(pe = tryMatch...abled, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
257 break;
never executed: break;
0
258 if ((pe = tryMatch(size, QIcon::Selected, state)))
(pe = tryMatch...ected, state))Description
TRUEnever evaluated
FALSEnever evaluated
0
259 break;
never executed: break;
0
260 if ((pe = tryMatch(size, QIcon::Disabled, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
261 break;
never executed: break;
0
262 if ((pe = tryMatch(size, QIcon::Selected, oppositeState)))
(pe = tryMatch...ppositeState))Description
TRUEnever evaluated
FALSEnever evaluated
0
263 break;
never executed: break;
0
264 }
never executed: end of block
0
265-
266 if (!pe)
!peDescription
TRUEnever evaluated
FALSEnever evaluated
0
267 return pe;
never executed: return pe;
0
268 }
never executed: end of block
0
269-
270 if (sizeOnly ? (pe->size.isNull() || !pe->size.isValid()) : pe->pixmap.isNull()) {
sizeOnly ? (pe...ixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
sizeOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
pe->size.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!pe->size.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
271 pe->pixmap = QPixmap(pe->fileName);-
272 if (!pe->pixmap.isNull())
!pe->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
273 pe->size = pe->pixmap.size();
never executed: pe->size = pe->pixmap.size();
0
274 }
never executed: end of block
0
275-
276 return pe;
never executed: return pe;
0
277}-
278-
279QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)-
280{-
281 QPixmap pm;-
282 QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);-
283 if (pe)
peDescription
TRUEnever evaluated
FALSEnever evaluated
0
284 pm = pe->pixmap;
never executed: pm = pe->pixmap;
0
285-
286 if (pm.isNull()) {
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
287 int idx = pixmaps.count();-
288 while (--idx >= 0) {
--idx >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
289 if (pe == &pixmaps.at(idx)) {
pe == &pixmaps.at(idx)Description
TRUEnever evaluated
FALSEnever evaluated
0
290 pixmaps.remove(idx);-
291 break;
never executed: break;
0
292 }-
293 }
never executed: end of block
0
294 if (pixmaps.isEmpty())
pixmaps.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
295 return pm;
never executed: return pm;
0
296 else-
297 return pixmap(size, mode, state);
never executed: return pixmap(size, mode, state);
0
298 }-
299-
300 QSize actualSize = pm.size();-
301 if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
!actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
actualSize.wid...> size.width()Description
TRUEnever evaluated
FALSEnever evaluated
actualSize.hei... size.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
302 actualSize.scale(size, Qt::KeepAspectRatio);
never executed: actualSize.scale(size, Qt::KeepAspectRatio);
0
303-
304 QString key = QLatin1String("qt_")-
305 % HexString<quint64>(pm.cacheKey())-
306 % HexString<uint>(pe ? pe->mode : QIcon::Normal)-
307 % HexString<quint64>(QGuiApplication::palette().cacheKey())-
308 % HexString<uint>(actualSize.width())-
309 % HexString<uint>(actualSize.height());-
310-
311 if (mode == QIcon::Active) {
mode == QIcon::ActiveDescription
TRUEnever evaluated
FALSEnever evaluated
0
312 if (QPixmapCache::find(key % HexString<uint>(mode), pm))
QPixmapCache::...nt>(mode), pm)Description
TRUEnever evaluated
FALSEnever evaluated
0
313 return pm; // horray
never executed: return pm;
0
314 if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
QPixmapCache::...::Normal), pm)Description
TRUEnever evaluated
FALSEnever evaluated
0
315 QPixmap active = pm;-
316 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
QGuiApplicatio...:instance())))Description
TRUEnever evaluated
FALSEnever evaluated
0
317 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
318 if (pm.cacheKey() == active.cacheKey())
pm.cacheKey() ...ive.cacheKey()Description
TRUEnever evaluated
FALSEnever evaluated
0
319 return pm;
never executed: return pm;
0
320 }
never executed: end of block
0
321 }
never executed: end of block
0
322-
323 if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
!QPixmapCache:...nt>(mode), pm)Description
TRUEnever evaluated
FALSEnever evaluated
0
324 if (pm.size() != actualSize)
pm.size() != actualSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
325 pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
never executed: pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
0
326 if (pe->mode != mode && mode != QIcon::Normal) {
pe->mode != modeDescription
TRUEnever evaluated
FALSEnever evaluated
mode != QIcon::NormalDescription
TRUEnever evaluated
FALSEnever evaluated
0
327 QPixmap generated = pm;-
328 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
QGuiApplicatio...:instance())))Description
TRUEnever evaluated
FALSEnever evaluated
0
329 generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
never executed: generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
0
330 if (!generated.isNull())
!generated.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
331 pm = generated;
never executed: pm = generated;
0
332 }
never executed: end of block
0
333 QPixmapCache::insert(key % HexString<uint>(mode), pm);-
334 }
never executed: end of block
0
335 return pm;
never executed: return pm;
0
336}-
337-
338QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)-
339{-
340 QSize actualSize;-
341 if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true))
QPixmapIconEng..., state, true)Description
TRUEnever evaluated
FALSEnever evaluated
0
342 actualSize = pe->size;
never executed: actualSize = pe->size;
0
343-
344 if (actualSize.isNull())
actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
345 return actualSize;
never executed: return actualSize;
0
346-
347 if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
!actualSize.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
actualSize.wid...> size.width()Description
TRUEnever evaluated
FALSEnever evaluated
actualSize.hei... size.height()Description
TRUEnever evaluated
FALSEnever evaluated
0
348 actualSize.scale(size, Qt::KeepAspectRatio);
never executed: actualSize.scale(size, Qt::KeepAspectRatio);
0
349 return actualSize;
never executed: return actualSize;
0
350}-
351-
352void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)-
353{-
354 if (!pixmap.isNull()) {
!pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
355 QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);-
356 if(pe && pe->size == pixmap.size()) {
peDescription
TRUEnever evaluated
FALSEnever evaluated
pe->size == pixmap.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
357 pe->pixmap = pixmap;-
358 pe->fileName.clear();-
359 } else {
never executed: end of block
0
360 pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);-
361 }
never executed: end of block
0
362 }-
363}
never executed: end of block
0
364-
365// Read out original image depth as set by ICOReader-
366static inline int origIcoDepth(const QImage &image)-
367{-
368 const QString s = image.text(QStringLiteral("_q_icoOrigDepth"));
never executed: return qstring_literal_temp;
0
369 return s.isEmpty() ? 32 : s.toInt();
never executed: return s.isEmpty() ? 32 : s.toInt();
0
370}-
371-
372static inline int findBySize(const QVector<QImage> &images, const QSize &size)-
373{-
374 for (int i = 0; i < images.size(); ++i) {
i < images.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
375 if (images.at(i).size() == size)
images.at(i).size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
376 return i;
never executed: return i;
0
377 }
never executed: end of block
0
378 return -1;
never executed: return -1;
0
379}-
380-
381// Convenience class providing a bool read() function.-
382namespace {-
383class ImageReader-
384{-
385public:-
386 ImageReader(const QString &fileName) : m_reader(fileName), m_atEnd(false) {}
never executed: end of block
0
387-
388 QByteArray format() const { return m_reader.format(); }
never executed: return m_reader.format();
0
389-
390 bool read(QImage *image)-
391 {-
392 if (m_atEnd)
m_atEndDescription
TRUEnever evaluated
FALSEnever evaluated
0
393 return false;
never executed: return false;
0
394 *image = m_reader.read();-
395 if (!image->size().isValid()) {
!image->size().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
396 m_atEnd = true;-
397 return false;
never executed: return false;
0
398 }-
399 m_atEnd = !m_reader.jumpToNextImage();-
400 return true;
never executed: return true;
0
401 }-
402-
403private:-
404 QImageReader m_reader;-
405 bool m_atEnd;-
406};-
407} // namespace-
408-
409void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)-
410{-
411 if (fileName.isEmpty())
fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
412 return;
never executed: return;
0
413 const QString abs = fileName.startsWith(QLatin1Char(':')) ? fileName : QFileInfo(fileName).absoluteFilePath();
fileName.start...tin1Char(':'))Description
TRUEnever evaluated
FALSEnever evaluated
0
414 const bool ignoreSize = !size.isValid();-
415 ImageReader imageReader(abs);-
416 const QByteArray format = imageReader.format();-
417 if (format.isEmpty()) // Device failed to open or unsupported format.
format.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
418 return;
never executed: return;
0
419 QImage image;-
420 if (format != "ico") {
format != "ico"Description
TRUEnever evaluated
FALSEnever evaluated
0
421 if (ignoreSize) { // No size specified: Add all images.
ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
422 while (imageReader.read(&image))
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
0
423 pixmaps += QPixmapIconEngineEntry(abs, image, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, image, mode, state);
0
424 } else {
never executed: end of block
0
425 // Try to match size. If that fails, add a placeholder with the filename and empty pixmap for the size.-
426 while (imageReader.read(&image) && image.size() != size) {}
never executed: end of block
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
image.size() != sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
427 pixmaps += image.size() == size ?
image.size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
428 QPixmapIconEngineEntry(abs, image, mode, state) : QPixmapIconEngineEntry(abs, size, mode, state);-
429 }
never executed: end of block
0
430 return;
never executed: return;
0
431 }-
432 // Special case for reading Windows ".ico" files. Historically (QTBUG-39287),-
433 // these files may contain low-resolution images. As this information is lost,-
434 // ICOReader sets the original format as an image text key value. Read all matching-
435 // images into a list trying to find the highest quality per size.-
436 QVector<QImage> icoImages;-
437 while (imageReader.read(&image)) {
imageReader.read(&image)Description
TRUEnever evaluated
FALSEnever evaluated
0
438 if (ignoreSize || image.size() == size) {
ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
image.size() == sizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
439 const int position = findBySize(icoImages, image.size());-
440 if (position >= 0) { // Higher quality available? -> replace.
position >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
441 if (origIcoDepth(image) > origIcoDepth(icoImages.at(position)))
origIcoDepth(i....at(position))Description
TRUEnever evaluated
FALSEnever evaluated
0
442 icoImages[position] = image;
never executed: icoImages[position] = image;
0
443 } else {
never executed: end of block
0
444 icoImages.append(image);-
445 }
never executed: end of block
0
446 }-
447 }
never executed: end of block
0
448 for (const QImage &i : qAsConst(icoImages))-
449 pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
0
450 if (icoImages.isEmpty() && !ignoreSize) // Add placeholder with the filename and empty pixmap for the size.
icoImages.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!ignoreSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
451 pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);
never executed: pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);
0
452}
never executed: end of block
0
453-
454QString QPixmapIconEngine::key() const-
455{-
456 return QLatin1String("QPixmapIconEngine");
never executed: return QLatin1String("QPixmapIconEngine");
0
457}-
458-
459QIconEngine *QPixmapIconEngine::clone() const-
460{-
461 return new QPixmapIconEngine(*this);
never executed: return new QPixmapIconEngine(*this);
0
462}-
463-
464bool QPixmapIconEngine::read(QDataStream &in)-
465{-
466 int num_entries;-
467 QPixmap pm;-
468 QString fileName;-
469 QSize sz;-
470 uint mode;-
471 uint state;-
472-
473 in >> num_entries;-
474 for (int i=0; i < num_entries; ++i) {
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
0
475 if (in.atEnd()) {
in.atEnd()Description
TRUEnever evaluated
FALSEnever evaluated
0
476 pixmaps.clear();-
477 return false;
never executed: return false;
0
478 }-
479 in >> pm;-
480 in >> fileName;-
481 in >> sz;-
482 in >> mode;-
483 in >> state;-
484 if (pm.isNull()) {
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
485 addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));-
486 } else {
never executed: end of block
0
487 QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));-
488 pe.pixmap = pm;-
489 pixmaps += pe;-
490 }
never executed: end of block
0
491 }-
492 return true;
never executed: return true;
0
493}-
494-
495bool QPixmapIconEngine::write(QDataStream &out) const-
496{-
497 int num_entries = pixmaps.size();-
498 out << num_entries;-
499 for (int i=0; i < num_entries; ++i) {
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
0
500 if (pixmaps.at(i).pixmap.isNull())
pixmaps.at(i).pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
501 out << QPixmap(pixmaps.at(i).fileName);
never executed: out << QPixmap(pixmaps.at(i).fileName);
0
502 else-
503 out << pixmaps.at(i).pixmap;
never executed: out << pixmaps.at(i).pixmap;
0
504 out << pixmaps.at(i).fileName;-
505 out << pixmaps.at(i).size;-
506 out << (uint) pixmaps.at(i).mode;-
507 out << (uint) pixmaps.at(i).state;-
508 }
never executed: end of block
0
509 return true;
never executed: return true;
0
510}-
511-
512void QPixmapIconEngine::virtual_hook(int id, void *data)-
513{-
514 switch (id) {-
515 case QIconEngine::AvailableSizesHook: {
never executed: case QIconEngine::AvailableSizesHook:
0
516 QIconEngine::AvailableSizesArgument &arg =-
517 *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);-
518 arg.sizes.clear();-
519 for (int i = 0; i < pixmaps.size(); ++i) {
i < pixmaps.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
520 QPixmapIconEngineEntry &pe = pixmaps[i];-
521 if (pe.size == QSize() && pe.pixmap.isNull()) {
pe.size == QSize()Description
TRUEnever evaluated
FALSEnever evaluated
pe.pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
522 pe.pixmap = QPixmap(pe.fileName);-
523 pe.size = pe.pixmap.size();-
524 }
never executed: end of block
0
525 if (pe.mode == arg.mode && pe.state == arg.state && !pe.size.isEmpty())
pe.mode == arg.modeDescription
TRUEnever evaluated
FALSEnever evaluated
pe.state == arg.stateDescription
TRUEnever evaluated
FALSEnever evaluated
!pe.size.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
526 arg.sizes.push_back(pe.size);
never executed: arg.sizes.push_back(pe.size);
0
527 }
never executed: end of block
0
528 break;
never executed: break;
0
529 }-
530 default:
never executed: default:
0
531 QIconEngine::virtual_hook(id, data);-
532 }
never executed: end of block
0
533}-
534-
535Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
536 (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))-
537-
538QFactoryLoader *qt_iconEngineFactoryLoader()-
539{-
540 return loader();
never executed: return loader();
0
541}-
542-
543-
544/*!-
545 \class QIcon-
546-
547 \brief The QIcon class provides scalable icons in different modes-
548 and states.-
549-
550 \ingroup painting-
551 \ingroup shared-
552 \inmodule QtGui-
553-
554 A QIcon can generate smaller, larger, active, and disabled pixmaps-
555 from the set of pixmaps it is given. Such pixmaps are used by Qt-
556 widgets to show an icon representing a particular action.-
557-
558 The simplest use of QIcon is to create one from a QPixmap file or-
559 resource, and then use it, allowing Qt to work out all the required-
560 icon styles and sizes. For example:-
561-
562 \snippet code/src_gui_image_qicon.cpp 0-
563-
564 To undo a QIcon, simply set a null icon in its place:-
565-
566 \snippet code/src_gui_image_qicon.cpp 1-
567-
568 Use the QImageReader::supportedImageFormats() and-
569 QImageWriter::supportedImageFormats() functions to retrieve a-
570 complete list of the supported file formats.-
571-
572 When you retrieve a pixmap using pixmap(QSize, Mode, State), and no-
573 pixmap for this given size, mode and state has been added with-
574 addFile() or addPixmap(), then QIcon will generate one on the-
575 fly. This pixmap generation happens in a QIconEngineV2. The default-
576 engine scales pixmaps down if required, but never up, and it uses-
577 the current style to calculate a disabled appearance. By using-
578 custom icon engines, you can customize every aspect of generated-
579 icons. With QIconEnginePluginV2 it is possible to register different-
580 icon engines for different file suffixes, making it possible for-
581 third parties to provide additional icon engines to those included-
582 with Qt.-
583-
584 \note Since Qt 4.2, an icon engine that supports SVG is included.-
585-
586 \section1 Making Classes that Use QIcon-
587-
588 If you write your own widgets that have an option to set a small-
589 pixmap, consider allowing a QIcon to be set for that pixmap. The-
590 Qt class QToolButton is an example of such a widget.-
591-
592 Provide a method to set a QIcon, and when you draw the icon, choose-
593 whichever pixmap is appropriate for the current state of your widget.-
594 For example:-
595 \snippet code/src_gui_image_qicon.cpp 2-
596-
597 You might also make use of the \c Active mode, perhaps making your-
598 widget \c Active when the mouse is over the widget (see \l-
599 QWidget::enterEvent()), while the mouse is pressed pending the-
600 release that will activate the function, or when it is the currently-
601 selected item. If the widget can be toggled, the "On" mode might be-
602 used to draw a different icon.-
603-
604 \image icon.png QIcon-
605-
606 \note QIcon needs a QGuiApplication instance before the icon is created.-
607-
608 \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}-
609*/-
610-
611-
612/*!-
613 Constructs a null icon.-
614*/-
615QIcon::QIcon() Q_DECL_NOEXCEPT-
616 : d(0)-
617{-
618}
never executed: end of block
0
619-
620/*!-
621 Constructs an icon from a \a pixmap.-
622 */-
623QIcon::QIcon(const QPixmap &pixmap)-
624 :d(0)-
625{-
626 addPixmap(pixmap);-
627}
never executed: end of block
0
628-
629/*!-
630 Constructs a copy of \a other. This is very fast.-
631*/-
632QIcon::QIcon(const QIcon &other)-
633 :d(other.d)-
634{-
635 if (d)
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
636 d->ref.ref();
never executed: d->ref.ref();
0
637}
never executed: end of block
0
638-
639/*!-
640 \fn QIcon::QIcon(QIcon &&other)-
641-
642 Move-constructs a QIcon instance, making it point to the same object-
643 that \a other was pointing to.-
644*/-
645-
646/*!-
647 Constructs an icon from the file with the given \a fileName. The-
648 file will be loaded on demand.-
649-
650 If \a fileName contains a relative path (e.g. the filename only)-
651 the relevant file must be found relative to the runtime working-
652 directory.-
653-
654 The file name can be either refer to an actual file on disk or to-
655 one of the application's embedded resources. See the-
656 \l{resources.html}{Resource System} overview for details on how to-
657 embed images and other resource files in the application's-
658 executable.-
659-
660 Use the QImageReader::supportedImageFormats() and-
661 QImageWriter::supportedImageFormats() functions to retrieve a-
662 complete list of the supported file formats.-
663*/-
664QIcon::QIcon(const QString &fileName)-
665 : d(0)-
666{-
667 addFile(fileName);-
668}
never executed: end of block
0
669-
670-
671/*!-
672 Creates an icon with a specific icon \a engine. The icon takes-
673 ownership of the engine.-
674*/-
675QIcon::QIcon(QIconEngine *engine)-
676 :d(new QIconPrivate)-
677{-
678 d->engine = engine;-
679}
never executed: end of block
0
680-
681/*!-
682 Destroys the icon.-
683*/-
684QIcon::~QIcon()-
685{-
686 if (d && !d->ref.deref())
dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
687 delete d;
never executed: delete d;
0
688}
never executed: end of block
0
689-
690/*!-
691 Assigns the \a other icon to this icon and returns a reference to-
692 this icon.-
693*/-
694QIcon &QIcon::operator=(const QIcon &other)-
695{-
696 if (other.d)
other.dDescription
TRUEnever evaluated
FALSEnever evaluated
0
697 other.d->ref.ref();
never executed: other.d->ref.ref();
0
698 if (d && !d->ref.deref())
dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
699 delete d;
never executed: delete d;
0
700 d = other.d;-
701 return *this;
never executed: return *this;
0
702}-
703-
704/*!-
705 \fn QIcon &QIcon::operator=(QIcon &&other)-
706-
707 Move-assigns \a other to this QIcon instance.-
708-
709 \since 5.2-
710*/-
711-
712/*!-
713 \fn void QIcon::swap(QIcon &other)-
714 \since 4.8-
715-
716 Swaps icon \a other with this icon. This operation is very-
717 fast and never fails.-
718*/-
719-
720/*!-
721 Returns the icon as a QVariant.-
722*/-
723QIcon::operator QVariant() const-
724{-
725 return QVariant(QVariant::Icon, this);
never executed: return QVariant(QVariant::Icon, this);
0
726}-
727-
728/*! \fn int QIcon::serialNumber() const-
729 \obsolete-
730-
731 Returns a number that identifies the contents of this-
732 QIcon object. Distinct QIcon objects can have-
733 the same serial number if they refer to the same contents-
734 (but they don't have to). Also, the serial number of-
735 a QIcon object may change during its lifetime.-
736-
737 Use cacheKey() instead.-
738-
739 A null icon always has a serial number of 0.-
740-
741 Serial numbers are mostly useful in conjunction with caching.-
742-
743 \sa QPixmap::serialNumber()-
744*/-
745-
746/*!-
747 Returns a number that identifies the contents of this QIcon-
748 object. Distinct QIcon objects can have the same key if-
749 they refer to the same contents.-
750 \since 4.3-
751-
752 The cacheKey() will change when the icon is altered via-
753 addPixmap() or addFile().-
754-
755 Cache keys are mostly useful in conjunction with caching.-
756-
757 \sa QPixmap::cacheKey()-
758*/-
759qint64 QIcon::cacheKey() const-
760{-
761 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
762 return 0;
never executed: return 0;
0
763 return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
never executed: return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
0
764}-
765-
766/*!-
767 Returns a pixmap with the requested \a size, \a mode, and \a-
768 state, generating one if necessary. The pixmap might be smaller than-
769 requested, but never larger.-
770-
771 Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this-
772 function to return pixmaps that are larger than the requested size. Such-
773 images will have a devicePixelRatio larger than 1.-
774-
775 \sa actualSize(), paint()-
776*/-
777QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const-
778{-
779 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
780 return QPixmap();
never executed: return QPixmap();
0
781 return pixmap(0, size, mode, state);
never executed: return pixmap(0, size, mode, state);
0
782}-
783-
784/*!-
785 \fn QPixmap QIcon::pixmap(int w, int h, Mode mode = Normal, State state = Off) const-
786-
787 \overload-
788-
789 Returns a pixmap of size QSize(\a w, \a h). The pixmap might be smaller than-
790 requested, but never larger.-
791-
792 Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this-
793 function to return pixmaps that are larger than the requested size. Such-
794 images will have a devicePixelRatio larger than 1.-
795*/-
796-
797/*!-
798 \fn QPixmap QIcon::pixmap(int extent, Mode mode = Normal, State state = Off) const-
799-
800 \overload-
801-
802 Returns a pixmap of size QSize(\a extent, \a extent). The pixmap might be smaller-
803 than requested, but never larger.-
804-
805 Setting the Qt::AA_UseHighDpiPixmaps application attribute enables this-
806 function to return pixmaps that are larger than the requested size. Such-
807 images will have a devicePixelRatio larger than 1.-
808*/-
809-
810/*! Returns the actual size of the icon for the requested \a size, \a-
811 mode, and \a state. The result might be smaller than requested, but-
812 never larger. The returned size is in device-independent pixels (This-
813 is relevant for high-dpi pixmaps.)-
814-
815 \sa pixmap(), paint()-
816*/-
817QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const-
818{-
819 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
820 return QSize();
never executed: return QSize();
0
821 return actualSize(0, size, mode, state);
never executed: return actualSize(0, size, mode, state);
0
822}-
823-
824/*!-
825 \since 5.1-
826-
827 Returns a pixmap with the requested \a window \a size, \a mode, and \a-
828 state, generating one if necessary.-
829-
830 The pixmap can be smaller than the requested size. If \a window is on-
831 a high-dpi display the pixmap can be larger. In that case it will have-
832 a devicePixelRatio larger than 1.-
833-
834 \sa actualSize(), paint()-
835*/-
836QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state) const-
837{-
838 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
839 return QPixmap();
never executed: return QPixmap();
0
840-
841 qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);-
842-
843 // Handle the simple normal-dpi case:-
844 if (!(devicePixelRatio > 1.0)) {
!(devicePixelRatio > 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
845 QPixmap pixmap = d->engine->pixmap(size, mode, state);-
846 pixmap.setDevicePixelRatio(1.0);-
847 return pixmap;
never executed: return pixmap;
0
848 }-
849-
850 // Try get a pixmap that is big enough to be displayed at device pixel resolution.-
851 QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state);-
852 pixmap.setDevicePixelRatio(d->pixmapDevicePixelRatio(devicePixelRatio, size, pixmap.size()));-
853 return pixmap;
never executed: return pixmap;
0
854}-
855-
856/*!-
857 \since 5.1-
858-
859 Returns the actual size of the icon for the requested \a window \a size, \a-
860 mode, and \a state.-
861-
862 The pixmap can be smaller than the requested size. The returned size-
863 is in device-independent pixels (This is relevant for high-dpi pixmaps.)-
864-
865 \sa actualSize(), pixmap(), paint()-
866*/-
867QSize QIcon::actualSize(QWindow *window, const QSize &size, Mode mode, State state) const-
868{-
869 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
870 return QSize();
never executed: return QSize();
0
871-
872 qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);-
873-
874 // Handle the simple normal-dpi case:-
875 if (!(devicePixelRatio > 1.0))
!(devicePixelRatio > 1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
876 return d->engine->actualSize(size, mode, state);
never executed: return d->engine->actualSize(size, mode, state);
0
877-
878 QSize actualSize = d->engine->actualSize(size * devicePixelRatio, mode, state);-
879 return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);
never executed: return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);
0
880}-
881-
882/*!-
883 Uses the \a painter to paint the icon with specified \a alignment,-
884 required \a mode, and \a state into the rectangle \a rect.-
885-
886 \sa actualSize(), pixmap()-
887*/-
888void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const-
889{-
890 if (!d || !painter)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
891 return;
never executed: return;
0
892-
893 // Copy of QStyle::alignedRect-
894 const QSize size = d->engine->actualSize(rect.size(), mode, state);-
895 alignment = QGuiApplicationPrivate::visualAlignment(painter->layoutDirection(), alignment);-
896 int x = rect.x();-
897 int y = rect.y();-
898 int w = size.width();-
899 int h = size.height();-
900 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
(alignment & Q...::AlignVCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
901 y += rect.size().height()/2 - h/2;
never executed: y += rect.size().height()/2 - h/2;
0
902 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
(alignment & Q...t::AlignBottomDescription
TRUEnever evaluated
FALSEnever evaluated
0
903 y += rect.size().height() - h;
never executed: y += rect.size().height() - h;
0
904 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
(alignment & Q...Qt::AlignRightDescription
TRUEnever evaluated
FALSEnever evaluated
0
905 x += rect.size().width() - w;
never executed: x += rect.size().width() - w;
0
906 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
(alignment & Q...::AlignHCenterDescription
TRUEnever evaluated
FALSEnever evaluated
0
907 x += rect.size().width()/2 - w/2;
never executed: x += rect.size().width()/2 - w/2;
0
908 QRect alignedRect(x, y, w, h);-
909-
910 d->engine->paint(painter, alignedRect, mode, state);-
911}
never executed: end of block
0
912-
913/*!-
914 \fn void QIcon::paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment,-
915 Mode mode, State state) const-
916-
917 \overload-
918-
919 Paints the icon into the rectangle QRect(\a x, \a y, \a w, \a h).-
920*/-
921-
922/*!-
923 Returns \c true if the icon is empty; otherwise returns \c false.-
924-
925 An icon is empty if it has neither a pixmap nor a filename.-
926-
927 Note: Even a non-null icon might not be able to create valid-
928 pixmaps, eg. if the file does not exist or cannot be read.-
929*/-
930bool QIcon::isNull() const-
931{-
932 return !d || d->engine->isNull();
never executed: return !d || d->engine->isNull();
0
933}-
934-
935/*!\internal-
936 */-
937bool QIcon::isDetached() const-
938{-
939 return !d || d->ref.load() == 1;
never executed: return !d || d->ref.load() == 1;
0
940}-
941-
942/*! \internal-
943 */-
944void QIcon::detach()-
945{-
946 if (d) {
dDescription
TRUEnever evaluated
FALSEnever evaluated
0
947 if (d->engine->isNull()) {
d->engine->isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
948 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
949 delete d;
never executed: delete d;
0
950 d = 0;-
951 return;
never executed: return;
0
952 } else if (d->ref.load() != 1) {
d->ref.load() != 1Description
TRUEnever evaluated
FALSEnever evaluated
0
953 QIconPrivate *x = new QIconPrivate;-
954 x->engine = d->engine->clone();-
955 if (!d->ref.deref())
!d->ref.deref()Description
TRUEnever evaluated
FALSEnever evaluated
0
956 delete d;
never executed: delete d;
0
957 d = x;-
958 }
never executed: end of block
0
959 ++d->detach_no;-
960 }
never executed: end of block
0
961}
never executed: end of block
0
962-
963/*!-
964 Adds \a pixmap to the icon, as a specialization for \a mode and-
965 \a state.-
966-
967 Custom icon engines are free to ignore additionally added-
968 pixmaps.-
969-
970 \sa addFile()-
971*/-
972void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)-
973{-
974 if (pixmap.isNull())
pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
975 return;
never executed: return;
0
976 detach();-
977 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
978 d = new QIconPrivate;-
979 d->engine = new QPixmapIconEngine;-
980 }
never executed: end of block
0
981 d->engine->addPixmap(pixmap, mode, state);-
982}
never executed: end of block
0
983-
984static QIconEngine *iconEngineFromSuffix(const QString &fileName, const QString &suffix)-
985{-
986 if (!suffix.isEmpty()) {
!suffix.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
987 const int index = loader()->indexOf(suffix);-
988 if (index != -1) {
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
989 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
QIconEnginePlu...stance(index))Description
TRUEnever evaluated
FALSEnever evaluated
0
990 return factory->create(fileName);
never executed: return factory->create(fileName);
0
991 }-
992 }
never executed: end of block
0
993 }
never executed: end of block
0
994 return nullptr;
never executed: return nullptr;
0
995}-
996-
997/*! Adds an image from the file with the given \a fileName to the-
998 icon, as a specialization for \a size, \a mode and \a state. The-
999 file will be loaded on demand. Note: custom icon engines are free-
1000 to ignore additionally added pixmaps.-
1001-
1002 If \a fileName contains a relative path (e.g. the filename only)-
1003 the relevant file must be found relative to the runtime working-
1004 directory.-
1005-
1006 The file name can be either refer to an actual file on disk or to-
1007 one of the application's embedded resources. See the-
1008 \l{resources.html}{Resource System} overview for details on how to-
1009 embed images and other resource files in the application's-
1010 executable.-
1011-
1012 Use the QImageReader::supportedImageFormats() and-
1013 QImageWriter::supportedImageFormats() functions to retrieve a-
1014 complete list of the supported file formats.-
1015-
1016 If a high resolution version of the image exists (identified by-
1017 the suffix \c @2x on the base name), it is automatically loaded-
1018 and added with the \e{device pixel ratio} set to a value of 2.-
1019 This can be disabled by setting the environment variable-
1020 \c QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING (see QImageReader).-
1021-
1022 \note When you add a non-empty filename to a QIcon, the icon becomes-
1023 non-null, even if the file doesn't exist or points to a corrupt file.-
1024-
1025 \sa addPixmap(), QPixmap::devicePixelRatio()-
1026 */-
1027void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state)-
1028{-
1029 if (fileName.isEmpty())
fileName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1030 return;
never executed: return;
0
1031 detach();-
1032 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1033-
1034 QFileInfo info(fileName);-
1035 QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix());-
1036#ifndef QT_NO_MIMETYPE-
1037 if (!engine)
!engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1038 engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
never executed: engine = iconEngineFromSuffix(fileName, QMimeDatabase().mimeTypeForFile(info).preferredSuffix());
0
1039#endif // !QT_NO_MIMETYPE-
1040 d = new QIconPrivate;-
1041 d->engine = engine ? engine : new QPixmapIconEngine;
engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1042 }
never executed: end of block
0
1043-
1044 d->engine->addFile(fileName, size, mode, state);-
1045-
1046 // Check if a "@Nx" file exists and add it.-
1047 QString atNxFileName = qt_findAtNxFile(fileName, qApp->devicePixelRatio());-
1048 if (atNxFileName != fileName)
atNxFileName != fileNameDescription
TRUEnever evaluated
FALSEnever evaluated
0
1049 d->engine->addFile(atNxFileName, size, mode, state);
never executed: d->engine->addFile(atNxFileName, size, mode, state);
0
1050}
never executed: end of block
0
1051-
1052/*!-
1053 \since 4.5-
1054-
1055 Returns a list of available icon sizes for the specified \a mode and-
1056 \a state.-
1057*/-
1058QList<QSize> QIcon::availableSizes(Mode mode, State state) const-
1059{-
1060 if (!d || !d->engine)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1061 return QList<QSize>();
never executed: return QList<QSize>();
0
1062 return d->engine->availableSizes(mode, state);
never executed: return d->engine->availableSizes(mode, state);
0
1063}-
1064-
1065/*!-
1066 \since 4.7-
1067-
1068 Returns the name used to create the icon, if available.-
1069-
1070 Depending on the way the icon was created, it may have an associated-
1071 name. This is the case for icons created with fromTheme() or icons-
1072 using a QIconEngine which supports the QIconEngineV2::IconNameHook.-
1073-
1074 \sa fromTheme(), QIconEngine-
1075*/-
1076QString QIcon::name() const-
1077{-
1078 if (!d || !d->engine)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
!d->engineDescription
TRUEnever evaluated
FALSEnever evaluated
0
1079 return QString();
never executed: return QString();
0
1080 return d->engine->iconName();
never executed: return d->engine->iconName();
0
1081}-
1082-
1083/*!-
1084 \since 4.6-
1085-
1086 Sets the search paths for icon themes to \a paths.-
1087 \sa themeSearchPaths(), fromTheme(), setThemeName()-
1088*/-
1089void QIcon::setThemeSearchPaths(const QStringList &paths)-
1090{-
1091 QIconLoader::instance()->setThemeSearchPath(paths);-
1092}
never executed: end of block
0
1093-
1094/*!-
1095 \since 4.6-
1096-
1097 Returns the search paths for icon themes.-
1098-
1099 The default value will depend on the platform:-
1100-
1101 On X11, the search path will use the XDG_DATA_DIRS environment-
1102 variable if available.-
1103-
1104 By default all platforms will have the resource directory-
1105 \c{:\icons} as a fallback. You can use "rcc -project" to generate a-
1106 resource file from your icon theme.-
1107-
1108 \sa setThemeSearchPaths(), fromTheme(), setThemeName()-
1109*/-
1110QStringList QIcon::themeSearchPaths()-
1111{-
1112 return QIconLoader::instance()->themeSearchPaths();
never executed: return QIconLoader::instance()->themeSearchPaths();
0
1113}-
1114-
1115/*!-
1116 \since 4.6-
1117-
1118 Sets the current icon theme to \a name.-
1119-
1120 The \a name should correspond to a directory name in the-
1121 themeSearchPath() containing an index.theme-
1122 file describing it's contents.-
1123-
1124 \sa themeSearchPaths(), themeName()-
1125*/-
1126void QIcon::setThemeName(const QString &name)-
1127{-
1128 QIconLoader::instance()->setThemeName(name);-
1129}
never executed: end of block
0
1130-
1131/*!-
1132 \since 4.6-
1133-
1134 Returns the name of the current icon theme.-
1135-
1136 On X11, the current icon theme depends on your desktop-
1137 settings. On other platforms it is not set by default.-
1138-
1139 \sa setThemeName(), themeSearchPaths(), fromTheme(),-
1140 hasThemeIcon()-
1141*/-
1142QString QIcon::themeName()-
1143{-
1144 return QIconLoader::instance()->themeName();
never executed: return QIconLoader::instance()->themeName();
0
1145}-
1146-
1147/*!-
1148 \since 4.6-
1149-
1150 Returns the QIcon corresponding to \a name in the current-
1151 icon theme.-
1152-
1153 The latest version of the freedesktop icon specification and naming-
1154 specification can be obtained here:-
1155-
1156 \list-
1157 \li \l{http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html}-
1158 \li \l{http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html}-
1159 \endlist-
1160-
1161 To fetch an icon from the current icon theme:-
1162-
1163 \snippet code/src_gui_image_qicon.cpp 3-
1164-
1165 \note By default, only X11 will support themed icons. In order to-
1166 use themed icons on Mac and Windows, you will have to bundle a-
1167 compliant theme in one of your themeSearchPaths() and set the-
1168 appropriate themeName().-
1169-
1170 \note Qt will make use of GTK's icon-theme.cache if present to speed up-
1171 the lookup. These caches can be generated using gtk-update-icon-cache:-
1172 \l{https://developer.gnome.org/gtk3/stable/gtk-update-icon-cache.html}.-
1173-
1174 \sa themeName(), setThemeName(), themeSearchPaths()-
1175*/-
1176QIcon QIcon::fromTheme(const QString &name)-
1177{-
1178 QIcon icon;-
1179-
1180 if (qtIconCache()->contains(name)) {
qtIconCache()->contains(name)Description
TRUEnever evaluated
FALSEnever evaluated
0
1181 icon = *qtIconCache()->object(name);-
1182 } else if (QDir::isAbsolutePath(name)) {
never executed: end of block
QDir::isAbsolutePath(name)Description
TRUEnever evaluated
FALSEnever evaluated
0
1183 return QIcon(name);
never executed: return QIcon(name);
0
1184 } else {-
1185 QPlatformTheme * const platformTheme = QGuiApplicationPrivate::platformTheme();-
1186 bool hasUserTheme = QIconLoader::instance()->hasUserTheme();-
1187 QIconEngine * const engine = (platformTheme && !hasUserTheme) ? platformTheme->createIconEngine(name)
platformThemeDescription
TRUEnever evaluated
FALSEnever evaluated
!hasUserThemeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1188 : new QIconLoaderEngine(name);-
1189 QIcon *cachedIcon = new QIcon(engine);-
1190 icon = *cachedIcon;-
1191 qtIconCache()->insert(name, cachedIcon);-
1192 }
never executed: end of block
0
1193-
1194 return icon;
never executed: return icon;
0
1195}-
1196-
1197/*!-
1198 \overload-
1199-
1200 Returns the QIcon corresponding to \a name in the current-
1201 icon theme. If no such icon is found in the current theme-
1202 \a fallback is returned instead.-
1203-
1204 If you want to provide a guaranteed fallback for platforms that-
1205 do not support theme icons, you can use the second argument:-
1206-
1207 \snippet code/src_gui_image_qicon.cpp 4-
1208*/-
1209QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)-
1210{-
1211 QIcon icon = fromTheme(name);-
1212-
1213 if (icon.isNull() || icon.availableSizes().isEmpty())
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
icon.available...es().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1214 return fallback;
never executed: return fallback;
0
1215-
1216 return icon;
never executed: return icon;
0
1217}-
1218-
1219/*!-
1220 \since 4.6-
1221-
1222 Returns \c true if there is an icon available for \a name in the-
1223 current icon theme, otherwise returns \c false.-
1224-
1225 \sa themeSearchPaths(), fromTheme(), setThemeName()-
1226*/-
1227bool QIcon::hasThemeIcon(const QString &name)-
1228{-
1229 QIcon icon = fromTheme(name);-
1230-
1231 return icon.name() == name;
never executed: return icon.name() == name;
0
1232}-
1233-
1234/*!-
1235 \since 5.6-
1236-
1237 Indicate that this icon is a mask image(boolean \a isMask), and hence can-
1238 potentially be modified based on where it's displayed.-
1239 \sa isMask()-
1240*/-
1241void QIcon::setIsMask(bool isMask)-
1242{-
1243 if (!d) {
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1244 d = new QIconPrivate;-
1245 d->engine = new QPixmapIconEngine;-
1246 } else {
never executed: end of block
0
1247 detach();-
1248 }
never executed: end of block
0
1249 d->is_mask = isMask;-
1250}
never executed: end of block
0
1251-
1252/*!-
1253 \since 5.6-
1254-
1255 Returns \c true if this icon has been marked as a mask image.-
1256 Certain platforms render mask icons differently (for example,-
1257 menu icons on \macos).-
1258-
1259 \sa setIsMask()-
1260*/-
1261bool QIcon::isMask() const-
1262{-
1263 if (!d)
!dDescription
TRUEnever evaluated
FALSEnever evaluated
0
1264 return false;
never executed: return false;
0
1265 return d->is_mask;
never executed: return d->is_mask;
0
1266}-
1267-
1268/*****************************************************************************-
1269 QIcon stream functions-
1270 *****************************************************************************/-
1271#if !defined(QT_NO_DATASTREAM)-
1272/*!-
1273 \fn QDataStream &operator<<(QDataStream &stream, const QIcon &icon)-
1274 \relates QIcon-
1275 \since 4.2-
1276-
1277 Writes the given \a icon to the given \a stream as a PNG-
1278 image. If the icon contains more than one image, all images will-
1279 be written to the stream. Note that writing the stream to a file-
1280 will not produce a valid image file.-
1281*/-
1282-
1283QDataStream &operator<<(QDataStream &s, const QIcon &icon)-
1284{-
1285 if (s.version() >= QDataStream::Qt_4_3) {
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1286 if (icon.isNull()) {
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1287 s << QString();-
1288 } else {
never executed: end of block
0
1289 s << icon.d->engine->key();-
1290 icon.d->engine->write(s);-
1291 }
never executed: end of block
0
1292 } else if (s.version() == QDataStream::Qt_4_2) {
s.version() ==...Stream::Qt_4_2Description
TRUEnever evaluated
FALSEnever evaluated
0
1293 if (icon.isNull()) {
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1294 s << 0;-
1295 } else {
never executed: end of block
0
1296 QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);-
1297 int num_entries = engine->pixmaps.size();-
1298 s << num_entries;-
1299 for (int i=0; i < num_entries; ++i) {
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1300 s << engine->pixmaps.at(i).pixmap;-
1301 s << engine->pixmaps.at(i).fileName;-
1302 s << engine->pixmaps.at(i).size;-
1303 s << (uint) engine->pixmaps.at(i).mode;-
1304 s << (uint) engine->pixmaps.at(i).state;-
1305 }
never executed: end of block
0
1306 }
never executed: end of block
0
1307 } else {-
1308 s << QPixmap(icon.pixmap(22,22));-
1309 }
never executed: end of block
0
1310 return s;
never executed: return s;
0
1311}-
1312-
1313/*!-
1314 \fn QDataStream &operator>>(QDataStream &stream, QIcon &icon)-
1315 \relates QIcon-
1316 \since 4.2-
1317-
1318 Reads an image, or a set of images, from the given \a stream into-
1319 the given \a icon.-
1320*/-
1321-
1322QDataStream &operator>>(QDataStream &s, QIcon &icon)-
1323{-
1324 if (s.version() >= QDataStream::Qt_4_3) {
s.version() >=...Stream::Qt_4_3Description
TRUEnever evaluated
FALSEnever evaluated
0
1325 icon = QIcon();-
1326 QString key;-
1327 s >> key;-
1328 if (key == QLatin1String("QPixmapIconEngine")) {
key == QLatin1...apIconEngine")Description
TRUEnever evaluated
FALSEnever evaluated
0
1329 icon.d = new QIconPrivate;-
1330 QIconEngine *engine = new QPixmapIconEngine;-
1331 icon.d->engine = engine;-
1332 engine->read(s);-
1333 } else if (key == QLatin1String("QIconLoaderEngine")) {
never executed: end of block
key == QLatin1...LoaderEngine")Description
TRUEnever evaluated
FALSEnever evaluated
0
1334 icon.d = new QIconPrivate;-
1335 QIconEngine *engine = new QIconLoaderEngine();-
1336 icon.d->engine = engine;-
1337 engine->read(s);-
1338 } else {
never executed: end of block
0
1339 const int index = loader()->indexOf(key);-
1340 if (index != -1) {
index != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1341 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
QIconEnginePlu...stance(index))Description
TRUEnever evaluated
FALSEnever evaluated
0
1342 if (QIconEngine *engine= factory->create()) {
QIconEngine *e...tory->create()Description
TRUEnever evaluated
FALSEnever evaluated
0
1343 icon.d = new QIconPrivate;-
1344 icon.d->engine = engine;-
1345 engine->read(s);-
1346 } // factory
never executed: end of block
0
1347 } // instance
never executed: end of block
0
1348 } // index
never executed: end of block
0
1349 }
never executed: end of block
0
1350 } else if (s.version() == QDataStream::Qt_4_2) {
s.version() ==...Stream::Qt_4_2Description
TRUEnever evaluated
FALSEnever evaluated
0
1351 icon = QIcon();-
1352 int num_entries;-
1353 QPixmap pm;-
1354 QString fileName;-
1355 QSize sz;-
1356 uint mode;-
1357 uint state;-
1358-
1359 s >> num_entries;-
1360 for (int i=0; i < num_entries; ++i) {
i < num_entriesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1361 s >> pm;-
1362 s >> fileName;-
1363 s >> sz;-
1364 s >> mode;-
1365 s >> state;-
1366 if (pm.isNull())
pm.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1367 icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
0
1368 else-
1369 icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
0
1370 }-
1371 } else {
never executed: end of block
0
1372 QPixmap pm;-
1373 s >> pm;-
1374 icon.addPixmap(pm);-
1375 }
never executed: end of block
0
1376 return s;
never executed: return s;
0
1377}-
1378-
1379#endif //QT_NO_DATASTREAM-
1380-
1381#ifndef QT_NO_DEBUG_STREAM-
1382QDebug operator<<(QDebug dbg, const QIcon &i)-
1383{-
1384 QDebugStateSaver saver(dbg);-
1385 dbg.resetFormat();-
1386 dbg.nospace();-
1387 dbg << "QIcon(";-
1388 if (i.isNull()) {
i.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1389 dbg << "null";-
1390 } else {
never executed: end of block
0
1391 if (!i.name().isEmpty())
!i.name().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1392 dbg << i.name() << ',';
never executed: dbg << i.name() << ',';
0
1393 dbg << "availableSizes[normal,Off]=" << i.availableSizes()-
1394 << ",cacheKey=" << showbase << hex << i.cacheKey() << dec << noshowbase;-
1395 }
never executed: end of block
0
1396 dbg << ')';-
1397 return dbg;
never executed: return dbg;
0
1398}-
1399#endif-
1400-
1401/*!-
1402 \fn DataPtr &QIcon::data_ptr()-
1403 \internal-
1404*/-
1405-
1406/*!-
1407 \typedef QIcon::DataPtr-
1408 \internal-
1409*/-
1410-
1411/*!-
1412 \internal-
1413 \since 5.6-
1414 Attempts to find a suitable @Nx file for the given \a targetDevicePixelRatio-
1415 Returns the the \a baseFileName if no such file was found.-
1416-
1417 Given base foo.png and a target dpr of 2.5, this function will look for-
1418 foo@3x.png, then foo@2x, then fall back to foo.png if not found.-
1419-
1420 \a sourceDevicePixelRatio will be set to the value of N if the argument is-
1421 a non-null pointer-
1422*/-
1423QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,-
1424 qreal *sourceDevicePixelRatio)-
1425{-
1426 if (targetDevicePixelRatio <= 1.0)
targetDevicePixelRatio <= 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
1427 return baseFileName;
never executed: return baseFileName;
0
1428-
1429 static bool disableNxImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING");-
1430 if (disableNxImageLoading)
disableNxImageLoadingDescription
TRUEnever evaluated
FALSEnever evaluated
0
1431 return baseFileName;
never executed: return baseFileName;
0
1432-
1433 int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.'));-
1434 if (dotIndex == -1) /* no dot */
dotIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1435 dotIndex = baseFileName.size(); /* append */
never executed: dotIndex = baseFileName.size();
0
1436-
1437 QString atNxfileName = baseFileName;-
1438 atNxfileName.insert(dotIndex, QLatin1String("@2x"));-
1439 // Check for @Nx, ..., @3x, @2x file versions,-
1440 for (int n = qMin(qCeil(targetDevicePixelRatio), 9); n > 1; --n) {
n > 1Description
TRUEnever evaluated
FALSEnever evaluated
0
1441 atNxfileName[dotIndex + 1] = QLatin1Char('0' + n);-
1442 if (QFile::exists(atNxfileName)) {
QFile::exists(atNxfileName)Description
TRUEnever evaluated
FALSEnever evaluated
0
1443 if (sourceDevicePixelRatio)
sourceDevicePixelRatioDescription
TRUEnever evaluated
FALSEnever evaluated
0
1444 *sourceDevicePixelRatio = n;
never executed: *sourceDevicePixelRatio = n;
0
1445 return atNxfileName;
never executed: return atNxfileName;
0
1446 }-
1447 }
never executed: end of block
0
1448-
1449 return baseFileName;
never executed: return baseFileName;
0
1450}-
1451-
1452QT_END_NAMESPACE-
1453#endif //QT_NO_ICON-
Source codeSwitch to Preprocessed file

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