| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qicon.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||||||||
| 2 | - | |||||||||||||||||||||||||
| 3 | - | |||||||||||||||||||||||||
| 4 | - | |||||||||||||||||||||||||
| 5 | static QBasicAtomicInt serialNumCounter = { 1 }; | - | ||||||||||||||||||||||||
| 6 | - | |||||||||||||||||||||||||
| 7 | static void qt_cleanup_icon_cache(); | - | ||||||||||||||||||||||||
| 8 | namespace { | - | ||||||||||||||||||||||||
| 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 | - | |||||||||||||||||||||||||
| 19 | namespace { 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
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<IconCache, Q_QGS_qtIconCache::innerFunction, Q_QGS_qtIconCache::guard> qtIconCache;return &holder.value; | 0 | ||||||||||||||||||||||||
| 20 | - | |||||||||||||||||||||||||
| 21 | static void qt_cleanup_icon_cache() | - | ||||||||||||||||||||||||
| 22 | { | - | ||||||||||||||||||||||||
| 23 | qtIconCache()->clear(); | - | ||||||||||||||||||||||||
| 24 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 25 | static qreal qt_effective_device_pixel_ratio(QWindow *window = 0) | - | ||||||||||||||||||||||||
| 26 | { | - | ||||||||||||||||||||||||
| 27 | if (!(static_cast<QGuiApplication *>(QCoreApplication::instance()))->testAttribute(Qt::AA_UseHighDpiPixmaps)
| 0 | ||||||||||||||||||||||||
| 28 | return never executed: qreal(1.0);return qreal(1.0);never executed: return qreal(1.0); | 0 | ||||||||||||||||||||||||
| 29 | - | |||||||||||||||||||||||||
| 30 | if (window
| 0 | ||||||||||||||||||||||||
| 31 | return never executed: window->devicePixelRatio();return window->devicePixelRatio();never executed: return window->devicePixelRatio(); | 0 | ||||||||||||||||||||||||
| 32 | - | |||||||||||||||||||||||||
| 33 | return never executed: (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio();never executed: return (static_cast<QGuiApplication *>(QCoreApplication::instance()))->devicePixelRatio(); | 0 | ||||||||||||||||||||||||
| 34 | } | - | ||||||||||||||||||||||||
| 35 | - | |||||||||||||||||||||||||
| 36 | QIconPrivate::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 | ||||||||||||||||||||||||
| 43 | qreal 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: qMax(qreal(1.0), displayDevicePixelRatio *scale);return qMax(qreal(1.0), displayDevicePixelRatio *scale);never executed: return qMax(qreal(1.0), displayDevicePixelRatio *scale); | 0 | ||||||||||||||||||||||||
| 49 | } | - | ||||||||||||||||||||||||
| 50 | - | |||||||||||||||||||||||||
| 51 | QPixmapIconEngine::QPixmapIconEngine() | - | ||||||||||||||||||||||||
| 52 | { | - | ||||||||||||||||||||||||
| 53 | } | - | ||||||||||||||||||||||||
| 54 | - | |||||||||||||||||||||||||
| 55 | QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other) | - | ||||||||||||||||||||||||
| 56 | : QIconEngine(other), pixmaps(other.pixmaps) | - | ||||||||||||||||||||||||
| 57 | { | - | ||||||||||||||||||||||||
| 58 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 59 | - | |||||||||||||||||||||||||
| 60 | QPixmapIconEngine::~QPixmapIconEngine() | - | ||||||||||||||||||||||||
| 61 | { | - | ||||||||||||||||||||||||
| 62 | } | - | ||||||||||||||||||||||||
| 63 | - | |||||||||||||||||||||||||
| 64 | void 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 | - | |||||||||||||||||||||||||
| 71 | static inline int area(const QSize &s) { return never executed: s.width() * s.height();return s.width() * s.height();never executed: }return s.width() * s.height(); | 0 | ||||||||||||||||||||||||
| 72 | - | |||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb) | - | ||||||||||||||||||||||||
| 75 | { | - | ||||||||||||||||||||||||
| 76 | int s = area(size); | - | ||||||||||||||||||||||||
| 77 | if (pa->size == QSize()
| 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()
| 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
| 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
| 0 | ||||||||||||||||||||||||
| 93 | return never executed: pa;return pa;never executed: return pa; | 0 | ||||||||||||||||||||||||
| 94 | return never executed: pb;return pb;never executed: return pb; | 0 | ||||||||||||||||||||||||
| 95 | } | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||||||||
| 98 | { | - | ||||||||||||||||||||||||
| 99 | QPixmapIconEngineEntry *pe = 0; | - | ||||||||||||||||||||||||
| 100 | for (int i = 0; i < pixmaps.count()
| 0 | ||||||||||||||||||||||||
| 101 | if (pixmaps.at(i).mode == mode
| 0 | ||||||||||||||||||||||||
| 102 | if (pe
| 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: pe;return pe;never executed: return pe; | 0 | ||||||||||||||||||||||||
| 108 | } | - | ||||||||||||||||||||||||
| 109 | - | |||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly) | - | ||||||||||||||||||||||||
| 112 | { | - | ||||||||||||||||||||||||
| 113 | QPixmapIconEngineEntry *pe = tryMatch(size, mode, state); | - | ||||||||||||||||||||||||
| 114 | while (!pe
| 0 | ||||||||||||||||||||||||
| 115 | QIcon::State oppositeState = (
| 0 | ||||||||||||||||||||||||
| 116 | if (mode == QIcon::Disabled
| 0 | ||||||||||||||||||||||||
| 117 | QIcon::Mode oppositeMode = (
| 0 | ||||||||||||||||||||||||
| 118 | if ((
| 0 | ||||||||||||||||||||||||
| 119 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 120 | if ((
| 0 | ||||||||||||||||||||||||
| 121 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 122 | if ((
| 0 | ||||||||||||||||||||||||
| 123 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 124 | if ((
| 0 | ||||||||||||||||||||||||
| 125 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 126 | if ((
| 0 | ||||||||||||||||||||||||
| 127 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 128 | if ((
| 0 | ||||||||||||||||||||||||
| 129 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 130 | if ((
| 0 | ||||||||||||||||||||||||
| 131 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 132 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 133 | QIcon::Mode oppositeMode = (
| 0 | ||||||||||||||||||||||||
| 134 | if ((
| 0 | ||||||||||||||||||||||||
| 135 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 136 | if ((
| 0 | ||||||||||||||||||||||||
| 137 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 138 | if ((
| 0 | ||||||||||||||||||||||||
| 139 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 140 | if ((
| 0 | ||||||||||||||||||||||||
| 141 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 142 | if ((
| 0 | ||||||||||||||||||||||||
| 143 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 144 | if ((
| 0 | ||||||||||||||||||||||||
| 145 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 146 | if ((
| 0 | ||||||||||||||||||||||||
| 147 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 148 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | if (!pe
| 0 | ||||||||||||||||||||||||
| 151 | return never executed: pe;return pe;never executed: return pe; | 0 | ||||||||||||||||||||||||
| 152 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 153 | - | |||||||||||||||||||||||||
| 154 | if (sizeOnly
| 0 | ||||||||||||||||||||||||
| 155 | pe->pixmap = QPixmap(pe->fileName); | - | ||||||||||||||||||||||||
| 156 | if (!pe->pixmap.isNull()
| 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: pe;return pe;never executed: return pe; | 0 | ||||||||||||||||||||||||
| 161 | } | - | ||||||||||||||||||||||||
| 162 | - | |||||||||||||||||||||||||
| 163 | QPixmap 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
| 0 | ||||||||||||||||||||||||
| 168 | pm = pe->pixmap; never executed: pm = pe->pixmap; | 0 | ||||||||||||||||||||||||
| 169 | - | |||||||||||||||||||||||||
| 170 | if (pm.isNull()
| 0 | ||||||||||||||||||||||||
| 171 | int idx = pixmaps.count(); | - | ||||||||||||||||||||||||
| 172 | while (--
| 0 | ||||||||||||||||||||||||
| 173 | if (pe == &pixmaps.at(idx)
| 0 | ||||||||||||||||||||||||
| 174 | pixmaps.remove(idx); | - | ||||||||||||||||||||||||
| 175 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 176 | } | - | ||||||||||||||||||||||||
| 177 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 178 | if (pixmaps.isEmpty()
| 0 | ||||||||||||||||||||||||
| 179 | return never executed: pm;return pm;never executed: return pm; | 0 | ||||||||||||||||||||||||
| 180 | else | - | ||||||||||||||||||||||||
| 181 | return never executed: pixmap(size, mode, state);return pixmap(size, mode, state);never executed: return pixmap(size, mode, state); | 0 | ||||||||||||||||||||||||
| 182 | } | - | ||||||||||||||||||||||||
| 183 | - | |||||||||||||||||||||||||
| 184 | QSize actualSize = pm.size(); | - | ||||||||||||||||||||||||
| 185 | if (!actualSize.isNull()
| 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
| 0 | ||||||||||||||||||||||||
| 196 | if (QPixmapCache::find(key % HexString<uint>(mode), pm)
| 0 | ||||||||||||||||||||||||
| 197 | return never executed: pm;return pm;never executed: return pm; | 0 | ||||||||||||||||||||||||
| 198 | if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)
| 0 | ||||||||||||||||||||||||
| 199 | QPixmap active = pm; | - | ||||||||||||||||||||||||
| 200 | if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
| 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()
| 0 | ||||||||||||||||||||||||
| 203 | return never executed: pm;return 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)
| 0 | ||||||||||||||||||||||||
| 208 | if (pm.size() != actualSize
| 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
| 0 | ||||||||||||||||||||||||
| 211 | QPixmap generated = pm; | - | ||||||||||||||||||||||||
| 212 | if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
| 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()
| 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: pm;return pm;never executed: return pm; | 0 | ||||||||||||||||||||||||
| 220 | } | - | ||||||||||||||||||||||||
| 221 | - | |||||||||||||||||||||||||
| 222 | QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||||||||
| 223 | { | - | ||||||||||||||||||||||||
| 224 | QSize actualSize; | - | ||||||||||||||||||||||||
| 225 | if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true)
| 0 | ||||||||||||||||||||||||
| 226 | actualSize = pe->size; never executed: actualSize = pe->size; | 0 | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | if (actualSize.isNull()
| 0 | ||||||||||||||||||||||||
| 229 | return never executed: actualSize;return actualSize;never executed: return actualSize; | 0 | ||||||||||||||||||||||||
| 230 | - | |||||||||||||||||||||||||
| 231 | if (!actualSize.isNull()
| 0 | ||||||||||||||||||||||||
| 232 | actualSize.scale(size, Qt::KeepAspectRatio); never executed: actualSize.scale(size, Qt::KeepAspectRatio); | 0 | ||||||||||||||||||||||||
| 233 | return never executed: actualSize;return actualSize;never executed: return actualSize; | 0 | ||||||||||||||||||||||||
| 234 | } | - | ||||||||||||||||||||||||
| 235 | - | |||||||||||||||||||||||||
| 236 | void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||||||||
| 237 | { | - | ||||||||||||||||||||||||
| 238 | if (!pixmap.isNull()
| 0 | ||||||||||||||||||||||||
| 239 | QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state); | - | ||||||||||||||||||||||||
| 240 | if(pe
| 0 | ||||||||||||||||||||||||
| 241 | pe->pixmap = pixmap; | - | ||||||||||||||||||||||||
| 242 | pe->fileName.clear(); | - | ||||||||||||||||||||||||
| 243 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 244 | pixmaps += QPixmapIconEngineEntry(pixmap, mode, state); | - | ||||||||||||||||||||||||
| 245 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 246 | } | - | ||||||||||||||||||||||||
| 247 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 248 | - | |||||||||||||||||||||||||
| 249 | - | |||||||||||||||||||||||||
| 250 | static 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: qstring_literal_temp;return qstring_literal_temp;never executed: }()));return qstring_literal_temp; | 0 | ||||||||||||||||||||||||
| 253 | return never executed: s.isEmpty() ? 32 : s.toInt();return s.isEmpty() ? 32 : s.toInt();never executed: return s.isEmpty() ? 32 : s.toInt(); | 0 | ||||||||||||||||||||||||
| 254 | } | - | ||||||||||||||||||||||||
| 255 | - | |||||||||||||||||||||||||
| 256 | static inline int findBySize(const QVector<QImage> &images, const QSize &size) | - | ||||||||||||||||||||||||
| 257 | { | - | ||||||||||||||||||||||||
| 258 | for (int i = 0; i < images.size()
| 0 | ||||||||||||||||||||||||
| 259 | if (images.at(i).size() == size
| 0 | ||||||||||||||||||||||||
| 260 | return never executed: i;return i;never executed: return i; | 0 | ||||||||||||||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 262 | return never executed: -1;return -1;never executed: return -1; | 0 | ||||||||||||||||||||||||
| 263 | } | - | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | - | |||||||||||||||||||||||||
| 266 | namespace { | - | ||||||||||||||||||||||||
| 267 | class ImageReader | - | ||||||||||||||||||||||||
| 268 | { | - | ||||||||||||||||||||||||
| 269 | public: | - | ||||||||||||||||||||||||
| 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: m_reader.format();return m_reader.format();never executed: }return m_reader.format(); | 0 | ||||||||||||||||||||||||
| 273 | - | |||||||||||||||||||||||||
| 274 | bool read(QImage *image) | - | ||||||||||||||||||||||||
| 275 | { | - | ||||||||||||||||||||||||
| 276 | if (m_atEnd
| 0 | ||||||||||||||||||||||||
| 277 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 278 | *image = m_reader.read(); | - | ||||||||||||||||||||||||
| 279 | if (!image->size().isValid()
| 0 | ||||||||||||||||||||||||
| 280 | m_atEnd = true; | - | ||||||||||||||||||||||||
| 281 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 282 | } | - | ||||||||||||||||||||||||
| 283 | m_atEnd = !m_reader.jumpToNextImage(); | - | ||||||||||||||||||||||||
| 284 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 285 | } | - | ||||||||||||||||||||||||
| 286 | - | |||||||||||||||||||||||||
| 287 | private: | - | ||||||||||||||||||||||||
| 288 | QImageReader m_reader; | - | ||||||||||||||||||||||||
| 289 | bool m_atEnd; | - | ||||||||||||||||||||||||
| 290 | }; | - | ||||||||||||||||||||||||
| 291 | } | - | ||||||||||||||||||||||||
| 292 | - | |||||||||||||||||||||||||
| 293 | void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||||||||
| 294 | { | - | ||||||||||||||||||||||||
| 295 | if (fileName.isEmpty()
| 0 | ||||||||||||||||||||||||
| 296 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 297 | const QString abs = fileName.startsWith(QLatin1Char(':'))
| 0 | ||||||||||||||||||||||||
| 298 | const bool ignoreSize = !size.isValid(); | - | ||||||||||||||||||||||||
| 299 | ImageReader imageReader(abs); | - | ||||||||||||||||||||||||
| 300 | const QByteArray format = imageReader.format(); | - | ||||||||||||||||||||||||
| 301 | if (format.isEmpty()
| 0 | ||||||||||||||||||||||||
| 302 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 303 | QImage image; | - | ||||||||||||||||||||||||
| 304 | if (format != "ico"
| 0 | ||||||||||||||||||||||||
| 305 | if (ignoreSize
| 0 | ||||||||||||||||||||||||
| 306 | while (imageReader.read(&image)
| 0 | ||||||||||||||||||||||||
| 307 | pixmaps += QPixmapIconEngineEntry(abs, image, mode, state); never executed: pixmaps += QPixmapIconEngineEntry(abs, image, mode, state); | 0 | ||||||||||||||||||||||||
| 308 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | while (imageReader.read(&image)
never executed: end of block | 0 | ||||||||||||||||||||||||
| 311 | pixmaps += image.size() == size
| 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)
| 0 | ||||||||||||||||||||||||
| 322 | if (ignoreSize
| 0 | ||||||||||||||||||||||||
| 323 | const int position = findBySize(icoImages, image.size()); | - | ||||||||||||||||||||||||
| 324 | if (position >= 0
| 0 | ||||||||||||||||||||||||
| 325 | if (origIcoDepth(image) > origIcoDepth(icoImages.at(position))
| 0 | ||||||||||||||||||||||||
| 326 | icoImages[position] = image; never executed: icoImages[position] = image; | 0 | ||||||||||||||||||||||||
| 327 | } never executed: else {end of block | 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()
| 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 | - | |||||||||||||||||||||||||
| 338 | QString QPixmapIconEngine::key() const | - | ||||||||||||||||||||||||
| 339 | { | - | ||||||||||||||||||||||||
| 340 | return never executed: QLatin1String("QPixmapIconEngine");return QLatin1String("QPixmapIconEngine");never executed: return QLatin1String("QPixmapIconEngine"); | 0 | ||||||||||||||||||||||||
| 341 | } | - | ||||||||||||||||||||||||
| 342 | - | |||||||||||||||||||||||||
| 343 | QIconEngine *QPixmapIconEngine::clone() const | - | ||||||||||||||||||||||||
| 344 | { | - | ||||||||||||||||||||||||
| 345 | return never executed: new QPixmapIconEngine(*this);return new QPixmapIconEngine(*this);never executed: return new QPixmapIconEngine(*this); | 0 | ||||||||||||||||||||||||
| 346 | } | - | ||||||||||||||||||||||||
| 347 | - | |||||||||||||||||||||||||
| 348 | bool 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
| 0 | ||||||||||||||||||||||||
| 359 | if (in.atEnd()
| 0 | ||||||||||||||||||||||||
| 360 | pixmaps.clear(); | - | ||||||||||||||||||||||||
| 361 | return never executed: false;return 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()
| 0 | ||||||||||||||||||||||||
| 369 | addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state)); | - | ||||||||||||||||||||||||
| 370 | } never executed: else {end of block | 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: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 377 | } | - | ||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | bool QPixmapIconEngine::write(QDataStream &out) const | - | ||||||||||||||||||||||||
| 380 | { | - | ||||||||||||||||||||||||
| 381 | int num_entries = pixmaps.size(); | - | ||||||||||||||||||||||||
| 382 | out << num_entries; | - | ||||||||||||||||||||||||
| 383 | for (int i=0; i < num_entries
| 0 | ||||||||||||||||||||||||
| 384 | if (pixmaps.at(i).pixmap.isNull()
| 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: true;return true;never executed: return true; | 0 | ||||||||||||||||||||||||
| 394 | } | - | ||||||||||||||||||||||||
| 395 | - | |||||||||||||||||||||||||
| 396 | void QPixmapIconEngine::virtual_hook(int id, void *data) | - | ||||||||||||||||||||||||
| 397 | { | - | ||||||||||||||||||||||||
| 398 | switch (id) { | - | ||||||||||||||||||||||||
| 399 | case never executed: QIconEngine::AvailableSizesHook:case 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()
| 0 | ||||||||||||||||||||||||
| 404 | QPixmapIconEngineEntry &pe = pixmaps[i]; | - | ||||||||||||||||||||||||
| 405 | if (pe.size == QSize()
| 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
| 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 | - | |||||||||||||||||||||||||
| 419 | namespace { 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
never executed: }guard.store(QtGlobalStatic::Destroyed);never executed: }; 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; returnend of blocknever executed: &holder.value;return &holder.value;never executed: } } } static QGlobalStatic<QFactoryLoader, Q_QGS_loader::innerFunction, Q_QGS_loader::guard> loader;return &holder.value; | 0 | ||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | - | |||||||||||||||||||||||||
| 422 | QFactoryLoader *qt_iconEngineFactoryLoader() | - | ||||||||||||||||||||||||
| 423 | { | - | ||||||||||||||||||||||||
| 424 | return never executed: loader();return loader();never executed: return loader(); | 0 | ||||||||||||||||||||||||
| 425 | } | - | ||||||||||||||||||||||||
| 426 | QIcon::QIcon() noexcept | - | ||||||||||||||||||||||||
| 427 | : d(0) | - | ||||||||||||||||||||||||
| 428 | { | - | ||||||||||||||||||||||||
| 429 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | - | |||||||||||||||||||||||||
| 432 | - | |||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | QIcon::QIcon(const QPixmap &pixmap) | - | ||||||||||||||||||||||||
| 435 | :d(0) | - | ||||||||||||||||||||||||
| 436 | { | - | ||||||||||||||||||||||||
| 437 | addPixmap(pixmap); | - | ||||||||||||||||||||||||
| 438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 439 | - | |||||||||||||||||||||||||
| 440 | - | |||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | - | |||||||||||||||||||||||||
| 443 | QIcon::QIcon(const QIcon &other) | - | ||||||||||||||||||||||||
| 444 | :d(other.d) | - | ||||||||||||||||||||||||
| 445 | { | - | ||||||||||||||||||||||||
| 446 | if (d
| 0 | ||||||||||||||||||||||||
| 447 | d->ref.ref(); never executed: d->ref.ref(); | 0 | ||||||||||||||||||||||||
| 448 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 449 | QIcon::QIcon(const QString &fileName) | - | ||||||||||||||||||||||||
| 450 | : d(0) | - | ||||||||||||||||||||||||
| 451 | { | - | ||||||||||||||||||||||||
| 452 | addFile(fileName); | - | ||||||||||||||||||||||||
| 453 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | - | |||||||||||||||||||||||||
| 456 | - | |||||||||||||||||||||||||
| 457 | - | |||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | - | |||||||||||||||||||||||||
| 460 | QIcon::QIcon(QIconEngine *engine) | - | ||||||||||||||||||||||||
| 461 | :d(new QIconPrivate) | - | ||||||||||||||||||||||||
| 462 | { | - | ||||||||||||||||||||||||
| 463 | d->engine = engine; | - | ||||||||||||||||||||||||
| 464 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 465 | - | |||||||||||||||||||||||||
| 466 | - | |||||||||||||||||||||||||
| 467 | - | |||||||||||||||||||||||||
| 468 | - | |||||||||||||||||||||||||
| 469 | QIcon::~QIcon() | - | ||||||||||||||||||||||||
| 470 | { | - | ||||||||||||||||||||||||
| 471 | if (d
| 0 | ||||||||||||||||||||||||
| 472 | delete d; never executed: delete d; | 0 | ||||||||||||||||||||||||
| 473 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | - | |||||||||||||||||||||||||
| 476 | - | |||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | - | |||||||||||||||||||||||||
| 479 | QIcon &QIcon::operator=(const QIcon &other) | - | ||||||||||||||||||||||||
| 480 | { | - | ||||||||||||||||||||||||
| 481 | if (other.d
| 0 | ||||||||||||||||||||||||
| 482 | other.d->ref.ref(); never executed: other.d->ref.ref(); | 0 | ||||||||||||||||||||||||
| 483 | if (d
| 0 | ||||||||||||||||||||||||
| 484 | delete d; never executed: delete d; | 0 | ||||||||||||||||||||||||
| 485 | d = other.d; | - | ||||||||||||||||||||||||
| 486 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||||||||
| 487 | } | - | ||||||||||||||||||||||||
| 488 | QIcon::operator QVariant() const | - | ||||||||||||||||||||||||
| 489 | { | - | ||||||||||||||||||||||||
| 490 | return never executed: QVariant(QVariant::Icon, this);return QVariant(QVariant::Icon, this);never executed: return QVariant(QVariant::Icon, this); | 0 | ||||||||||||||||||||||||
| 491 | } | - | ||||||||||||||||||||||||
| 492 | qint64 QIcon::cacheKey() const | - | ||||||||||||||||||||||||
| 493 | { | - | ||||||||||||||||||||||||
| 494 | if (!d
| 0 | ||||||||||||||||||||||||
| 495 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||||||||
| 496 | return never executed: (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));never executed: return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no)); | 0 | ||||||||||||||||||||||||
| 497 | } | - | ||||||||||||||||||||||||
| 498 | QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const | - | ||||||||||||||||||||||||
| 499 | { | - | ||||||||||||||||||||||||
| 500 | if (!d
| 0 | ||||||||||||||||||||||||
| 501 | return never executed: QPixmap();return QPixmap();never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||
| 502 | return never executed: pixmap(0, size, mode, state);return pixmap(0, size, mode, state);never executed: return pixmap(0, size, mode, state); | 0 | ||||||||||||||||||||||||
| 503 | } | - | ||||||||||||||||||||||||
| 504 | QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const | - | ||||||||||||||||||||||||
| 505 | { | - | ||||||||||||||||||||||||
| 506 | if (!d
| 0 | ||||||||||||||||||||||||
| 507 | return never executed: QSize();return QSize();never executed: return QSize(); | 0 | ||||||||||||||||||||||||
| 508 | return never executed: actualSize(0, size, mode, state);return actualSize(0, size, mode, state);never executed: return actualSize(0, size, mode, state); | 0 | ||||||||||||||||||||||||
| 509 | } | - | ||||||||||||||||||||||||
| 510 | QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state) const | - | ||||||||||||||||||||||||
| 511 | { | - | ||||||||||||||||||||||||
| 512 | if (!d
| 0 | ||||||||||||||||||||||||
| 513 | return never executed: QPixmap();return QPixmap();never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); | - | ||||||||||||||||||||||||
| 516 | - | |||||||||||||||||||||||||
| 517 | - | |||||||||||||||||||||||||
| 518 | if (!(devicePixelRatio > 1.0)
| 0 | ||||||||||||||||||||||||
| 519 | QPixmap pixmap = d->engine->pixmap(size, mode, state); | - | ||||||||||||||||||||||||
| 520 | pixmap.setDevicePixelRatio(1.0); | - | ||||||||||||||||||||||||
| 521 | return never executed: pixmap;return 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: pixmap;return pixmap;never executed: return pixmap; | 0 | ||||||||||||||||||||||||
| 528 | } | - | ||||||||||||||||||||||||
| 529 | QSize QIcon::actualSize(QWindow *window, const QSize &size, Mode mode, State state) const | - | ||||||||||||||||||||||||
| 530 | { | - | ||||||||||||||||||||||||
| 531 | if (!d
| 0 | ||||||||||||||||||||||||
| 532 | return never executed: QSize();return QSize();never executed: return QSize(); | 0 | ||||||||||||||||||||||||
| 533 | - | |||||||||||||||||||||||||
| 534 | qreal devicePixelRatio = qt_effective_device_pixel_ratio(window); | - | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | - | |||||||||||||||||||||||||
| 537 | if (!(devicePixelRatio > 1.0)
| 0 | ||||||||||||||||||||||||
| 538 | return never executed: d->engine->actualSize(size, mode, state);return 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: actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize);never executed: return actualSize / d->pixmapDevicePixelRatio(devicePixelRatio, size, actualSize); | 0 | ||||||||||||||||||||||||
| 542 | } | - | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | - | |||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | - | |||||||||||||||||||||||||
| 547 | - | |||||||||||||||||||||||||
| 548 | - | |||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const | - | ||||||||||||||||||||||||
| 551 | { | - | ||||||||||||||||||||||||
| 552 | if (!d
| 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 ((
| 0 | ||||||||||||||||||||||||
| 563 | y += rect.size().height()/2 - h/2; never executed: y += rect.size().height()/2 - h/2; | 0 | ||||||||||||||||||||||||
| 564 | else if ((
| 0 | ||||||||||||||||||||||||
| 565 | y += rect.size().height() - h; never executed: y += rect.size().height() - h; | 0 | ||||||||||||||||||||||||
| 566 | if ((
| 0 | ||||||||||||||||||||||||
| 567 | x += rect.size().width() - w; never executed: x += rect.size().width() - w; | 0 | ||||||||||||||||||||||||
| 568 | else if ((
| 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 | ||||||||||||||||||||||||
| 574 | bool QIcon::isNull() const | - | ||||||||||||||||||||||||
| 575 | { | - | ||||||||||||||||||||||||
| 576 | return never executed: !d || d->engine->isNull();return !d || d->engine->isNull();never executed: return !d || d->engine->isNull(); | 0 | ||||||||||||||||||||||||
| 577 | } | - | ||||||||||||||||||||||||
| 578 | - | |||||||||||||||||||||||||
| 579 | - | |||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | bool QIcon::isDetached() const | - | ||||||||||||||||||||||||
| 582 | { | - | ||||||||||||||||||||||||
| 583 | return never executed: !d || d->ref.load() == 1;return !d || d->ref.load() == 1;never executed: return !d || d->ref.load() == 1; | 0 | ||||||||||||||||||||||||
| 584 | } | - | ||||||||||||||||||||||||
| 585 | - | |||||||||||||||||||||||||
| 586 | - | |||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | void QIcon::detach() | - | ||||||||||||||||||||||||
| 589 | { | - | ||||||||||||||||||||||||
| 590 | if (d
| 0 | ||||||||||||||||||||||||
| 591 | if (d->engine->isNull()
| 0 | ||||||||||||||||||||||||
| 592 | if (!d->ref.deref()
| 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
| 0 | ||||||||||||||||||||||||
| 597 | QIconPrivate *x = new QIconPrivate; | - | ||||||||||||||||||||||||
| 598 | x->engine = d->engine->clone(); | - | ||||||||||||||||||||||||
| 599 | if (!d->ref.deref()
| 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 | ||||||||||||||||||||||||
| 606 | void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state) | - | ||||||||||||||||||||||||
| 607 | { | - | ||||||||||||||||||||||||
| 608 | if (pixmap.isNull()
| 0 | ||||||||||||||||||||||||
| 609 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 610 | detach(); | - | ||||||||||||||||||||||||
| 611 | if (!d
| 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 | - | |||||||||||||||||||||||||
| 618 | static QIconEngine *iconEngineFromSuffix(const QString &fileName, const QString &suffix) | - | ||||||||||||||||||||||||
| 619 | { | - | ||||||||||||||||||||||||
| 620 | if (!suffix.isEmpty()
| 0 | ||||||||||||||||||||||||
| 621 | const int index = loader()->indexOf(suffix); | - | ||||||||||||||||||||||||
| 622 | if (index != -1
| 0 | ||||||||||||||||||||||||
| 623 | if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
| 0 | ||||||||||||||||||||||||
| 624 | return never executed: factory->create(fileName);return 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: nullptr;return nullptr;never executed: return nullptr; | 0 | ||||||||||||||||||||||||
| 629 | } | - | ||||||||||||||||||||||||
| 630 | void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state) | - | ||||||||||||||||||||||||
| 631 | { | - | ||||||||||||||||||||||||
| 632 | if (fileName.isEmpty()
| 0 | ||||||||||||||||||||||||
| 633 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 634 | detach(); | - | ||||||||||||||||||||||||
| 635 | if (!d
| 0 | ||||||||||||||||||||||||
| 636 | - | |||||||||||||||||||||||||
| 637 | QFileInfo info(fileName); | - | ||||||||||||||||||||||||
| 638 | QIconEngine *engine = iconEngineFromSuffix(fileName, info.suffix()); | - | ||||||||||||||||||||||||
| 639 | - | |||||||||||||||||||||||||
| 640 | if (!engine
| 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
| 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
| 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 | - | |||||||||||||||||||||||||
| 661 | QList<QSize> QIcon::availableSizes(Mode mode, State state) const | - | ||||||||||||||||||||||||
| 662 | { | - | ||||||||||||||||||||||||
| 663 | if (!d
| 0 | ||||||||||||||||||||||||
| 664 | return never executed: QList<QSize>();return QList<QSize>();never executed: return QList<QSize>(); | 0 | ||||||||||||||||||||||||
| 665 | return never executed: d->engine->availableSizes(mode, state);return d->engine->availableSizes(mode, state);never executed: return d->engine->availableSizes(mode, state); | 0 | ||||||||||||||||||||||||
| 666 | } | - | ||||||||||||||||||||||||
| 667 | QString QIcon::name() const | - | ||||||||||||||||||||||||
| 668 | { | - | ||||||||||||||||||||||||
| 669 | if (!d
| 0 | ||||||||||||||||||||||||
| 670 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||||||||
| 671 | return never executed: d->engine->iconName();return d->engine->iconName();never executed: return d->engine->iconName(); | 0 | ||||||||||||||||||||||||
| 672 | } | - | ||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||
| 674 | - | |||||||||||||||||||||||||
| 675 | - | |||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | - | |||||||||||||||||||||||||
| 678 | - | |||||||||||||||||||||||||
| 679 | - | |||||||||||||||||||||||||
| 680 | void QIcon::setThemeSearchPaths(const QStringList &paths) | - | ||||||||||||||||||||||||
| 681 | { | - | ||||||||||||||||||||||||
| 682 | QIconLoader::instance()->setThemeSearchPath(paths); | - | ||||||||||||||||||||||||
| 683 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 684 | QStringList QIcon::themeSearchPaths() | - | ||||||||||||||||||||||||
| 685 | { | - | ||||||||||||||||||||||||
| 686 | return never executed: QIconLoader::instance()->themeSearchPaths();return QIconLoader::instance()->themeSearchPaths();never executed: return QIconLoader::instance()->themeSearchPaths(); | 0 | ||||||||||||||||||||||||
| 687 | } | - | ||||||||||||||||||||||||
| 688 | void QIcon::setThemeName(const QString &name) | - | ||||||||||||||||||||||||
| 689 | { | - | ||||||||||||||||||||||||
| 690 | QIconLoader::instance()->setThemeName(name); | - | ||||||||||||||||||||||||
| 691 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 692 | QString QIcon::themeName() | - | ||||||||||||||||||||||||
| 693 | { | - | ||||||||||||||||||||||||
| 694 | return never executed: QIconLoader::instance()->themeName();return QIconLoader::instance()->themeName();never executed: return QIconLoader::instance()->themeName(); | 0 | ||||||||||||||||||||||||
| 695 | } | - | ||||||||||||||||||||||||
| 696 | QIcon QIcon::fromTheme(const QString &name) | - | ||||||||||||||||||||||||
| 697 | { | - | ||||||||||||||||||||||||
| 698 | QIcon icon; | - | ||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | if (qtIconCache()->contains(name)
| 0 | ||||||||||||||||||||||||
| 701 | icon = *qtIconCache()->object(name); | - | ||||||||||||||||||||||||
| 702 | } never executed: else if (QDir::isAbsolutePath(name)end of block
| 0 | ||||||||||||||||||||||||
| 703 | return never executed: QIcon(name);return 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
| 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: icon;return icon;never executed: return icon; | 0 | ||||||||||||||||||||||||
| 715 | } | - | ||||||||||||||||||||||||
| 716 | QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) | - | ||||||||||||||||||||||||
| 717 | { | - | ||||||||||||||||||||||||
| 718 | QIcon icon = fromTheme(name); | - | ||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||
| 720 | if (icon.isNull()
| 0 | ||||||||||||||||||||||||
| 721 | return never executed: fallback;return fallback;never executed: return fallback; | 0 | ||||||||||||||||||||||||
| 722 | - | |||||||||||||||||||||||||
| 723 | return never executed: icon;return icon;never executed: return icon; | 0 | ||||||||||||||||||||||||
| 724 | } | - | ||||||||||||||||||||||||
| 725 | bool QIcon::hasThemeIcon(const QString &name) | - | ||||||||||||||||||||||||
| 726 | { | - | ||||||||||||||||||||||||
| 727 | QIcon icon = fromTheme(name); | - | ||||||||||||||||||||||||
| 728 | - | |||||||||||||||||||||||||
| 729 | return never executed: icon.name() == name;return icon.name() == name;never executed: return icon.name() == name; | 0 | ||||||||||||||||||||||||
| 730 | } | - | ||||||||||||||||||||||||
| 731 | void QIcon::setIsMask(bool isMask) | - | ||||||||||||||||||||||||
| 732 | { | - | ||||||||||||||||||||||||
| 733 | if (!d
| 0 | ||||||||||||||||||||||||
| 734 | d = new QIconPrivate; | - | ||||||||||||||||||||||||
| 735 | d->engine = new QPixmapIconEngine; | - | ||||||||||||||||||||||||
| 736 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 737 | detach(); | - | ||||||||||||||||||||||||
| 738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 739 | d->is_mask = isMask; | - | ||||||||||||||||||||||||
| 740 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 741 | bool QIcon::isMask() const | - | ||||||||||||||||||||||||
| 742 | { | - | ||||||||||||||||||||||||
| 743 | if (!d
| 0 | ||||||||||||||||||||||||
| 744 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||||||||
| 745 | return never executed: d->is_mask;return d->is_mask;never executed: return d->is_mask; | 0 | ||||||||||||||||||||||||
| 746 | } | - | ||||||||||||||||||||||||
| 747 | QDataStream &operator<<(QDataStream &s, const QIcon &icon) | - | ||||||||||||||||||||||||
| 748 | { | - | ||||||||||||||||||||||||
| 749 | if (s.version() >= QDataStream::Qt_4_3
| 0 | ||||||||||||||||||||||||
| 750 | if (icon.isNull()
| 0 | ||||||||||||||||||||||||
| 751 | s << QString(); | - | ||||||||||||||||||||||||
| 752 | } never executed: else {end of block | 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
| 0 | ||||||||||||||||||||||||
| 757 | if (icon.isNull()
| 0 | ||||||||||||||||||||||||
| 758 | s << 0; | - | ||||||||||||||||||||||||
| 759 | } never executed: else {end of block | 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
| 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: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||
| 775 | } | - | ||||||||||||||||||||||||
| 776 | QDataStream &operator>>(QDataStream &s, QIcon &icon) | - | ||||||||||||||||||||||||
| 777 | { | - | ||||||||||||||||||||||||
| 778 | if (s.version() >= QDataStream::Qt_4_3
| 0 | ||||||||||||||||||||||||
| 779 | icon = QIcon(); | - | ||||||||||||||||||||||||
| 780 | QString key; | - | ||||||||||||||||||||||||
| 781 | s >> key; | - | ||||||||||||||||||||||||
| 782 | if (key == QLatin1String("QPixmapIconEngine")
| 0 | ||||||||||||||||||||||||
| 783 | icon.d = new QIconPrivate; | - | ||||||||||||||||||||||||
| 784 | QIconEngine *engine = new QPixmapIconEngine; | - | ||||||||||||||||||||||||
| 785 | icon.d->engine = engine; | - | ||||||||||||||||||||||||
| 786 | engine->read(s); | - | ||||||||||||||||||||||||
| 787 | } never executed: else if (key == QLatin1String("QIconLoaderEngine")end of block
| 0 | ||||||||||||||||||||||||
| 788 | icon.d = new QIconPrivate; | - | ||||||||||||||||||||||||
| 789 | QIconEngine *engine = new QIconLoaderEngine(); | - | ||||||||||||||||||||||||
| 790 | icon.d->engine = engine; | - | ||||||||||||||||||||||||
| 791 | engine->read(s); | - | ||||||||||||||||||||||||
| 792 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 793 | const int index = loader()->indexOf(key); | - | ||||||||||||||||||||||||
| 794 | if (index != -1
| 0 | ||||||||||||||||||||||||
| 795 | if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
| 0 | ||||||||||||||||||||||||
| 796 | if (QIconEngine *engine= factory->create()
| 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
| 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
| 0 | ||||||||||||||||||||||||
| 815 | s >> pm; | - | ||||||||||||||||||||||||
| 816 | s >> fileName; | - | ||||||||||||||||||||||||
| 817 | s >> sz; | - | ||||||||||||||||||||||||
| 818 | s >> mode; | - | ||||||||||||||||||||||||
| 819 | s >> state; | - | ||||||||||||||||||||||||
| 820 | if (pm.isNull()
| 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: else {end of block | 0 | ||||||||||||||||||||||||
| 826 | QPixmap pm; | - | ||||||||||||||||||||||||
| 827 | s >> pm; | - | ||||||||||||||||||||||||
| 828 | icon.addPixmap(pm); | - | ||||||||||||||||||||||||
| 829 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 830 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||||||||
| 831 | } | - | ||||||||||||||||||||||||
| 832 | - | |||||||||||||||||||||||||
| 833 | - | |||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||
| 835 | - | |||||||||||||||||||||||||
| 836 | QDebug operator<<(QDebug dbg, const QIcon &i) | - | ||||||||||||||||||||||||
| 837 | { | - | ||||||||||||||||||||||||
| 838 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||||||||
| 839 | dbg.resetFormat(); | - | ||||||||||||||||||||||||
| 840 | dbg.nospace(); | - | ||||||||||||||||||||||||
| 841 | dbg << "QIcon("; | - | ||||||||||||||||||||||||
| 842 | if (i.isNull()
| 0 | ||||||||||||||||||||||||
| 843 | dbg << "null"; | - | ||||||||||||||||||||||||
| 844 | } never executed: else {end of block | 0 | ||||||||||||||||||||||||
| 845 | if (!i.name().isEmpty()
| 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: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||||||||||||||
| 852 | } | - | ||||||||||||||||||||||||
| 853 | QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio, | - | ||||||||||||||||||||||||
| 854 | qreal *sourceDevicePixelRatio) | - | ||||||||||||||||||||||||
| 855 | { | - | ||||||||||||||||||||||||
| 856 | if (targetDevicePixelRatio <= 1.0
| 0 | ||||||||||||||||||||||||
| 857 | return never executed: baseFileName;return baseFileName;never executed: return baseFileName; | 0 | ||||||||||||||||||||||||
| 858 | - | |||||||||||||||||||||||||
| 859 | static bool disableNxImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING"); | - | ||||||||||||||||||||||||
| 860 | if (disableNxImageLoading
| 0 | ||||||||||||||||||||||||
| 861 | return never executed: baseFileName;return baseFileName;never executed: return baseFileName; | 0 | ||||||||||||||||||||||||
| 862 | - | |||||||||||||||||||||||||
| 863 | int dotIndex = baseFileName.lastIndexOf(QLatin1Char('.')); | - | ||||||||||||||||||||||||
| 864 | if (dotIndex == -1
| 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
| 0 | ||||||||||||||||||||||||
| 871 | atNxfileName[dotIndex + 1] = QLatin1Char('0' + n); | - | ||||||||||||||||||||||||
| 872 | if (QFile::exists(atNxfileName)
| 0 | ||||||||||||||||||||||||
| 873 | if (sourceDevicePixelRatio
| 0 | ||||||||||||||||||||||||
| 874 | * never executed: sourceDevicePixelRatio = n;*sourceDevicePixelRatio = n;never executed: *sourceDevicePixelRatio = n; | 0 | ||||||||||||||||||||||||
| 875 | return never executed: atNxfileName;return atNxfileName;never executed: return atNxfileName; | 0 | ||||||||||||||||||||||||
| 876 | } | - | ||||||||||||||||||||||||
| 877 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 878 | - | |||||||||||||||||||||||||
| 879 | return never executed: baseFileName;return baseFileName;never executed: return baseFileName; | 0 | ||||||||||||||||||||||||
| 880 | } | - | ||||||||||||||||||||||||
| 881 | - | |||||||||||||||||||||||||
| 882 | - | |||||||||||||||||||||||||
| Switch to Source code | Preprocessed file |