| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/image/qiconloader.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | namespace { namespace Q_QGS_iconLoaderInstance { typedef QIconLoader 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<QIconLoader, Q_QGS_iconLoaderInstance::innerFunction, Q_QGS_iconLoaderInstance::guard> iconLoaderInstance;return &holder.value; | 0 | ||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | static QString fallbackTheme() | - | ||||||||||||||||||
| 11 | { | - | ||||||||||||||||||
| 12 | if (const
| 0 | ||||||||||||||||||
| 13 | const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconFallbackThemeName); | - | ||||||||||||||||||
| 14 | if (themeHint.isValid()
| 0 | ||||||||||||||||||
| 15 | return never executed: themeHint.toString();return themeHint.toString();never executed: return themeHint.toString(); | 0 | ||||||||||||||||||
| 16 | } never executed: end of block | 0 | ||||||||||||||||||
| 17 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 18 | } | - | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | QIconLoader::QIconLoader() : | - | ||||||||||||||||||
| 21 | m_themeKey(1), m_supportsSvg(false), m_initialized(false) | - | ||||||||||||||||||
| 22 | { | - | ||||||||||||||||||
| 23 | } never executed: end of block | 0 | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | static inline QString systemThemeName() | - | ||||||||||||||||||
| 26 | { | - | ||||||||||||||||||
| 27 | if (const
| 0 | ||||||||||||||||||
| 28 | const QVariant themeHint = theme->themeHint(QPlatformTheme::SystemIconThemeName); | - | ||||||||||||||||||
| 29 | if (themeHint.isValid()
| 0 | ||||||||||||||||||
| 30 | return never executed: themeHint.toString();return themeHint.toString();never executed: return themeHint.toString(); | 0 | ||||||||||||||||||
| 31 | } never executed: end of block | 0 | ||||||||||||||||||
| 32 | return never executed: QString();return QString();never executed: return QString(); | 0 | ||||||||||||||||||
| 33 | } | - | ||||||||||||||||||
| 34 | - | |||||||||||||||||||
| 35 | static inline QStringList systemIconSearchPaths() | - | ||||||||||||||||||
| 36 | { | - | ||||||||||||||||||
| 37 | if (const
| 0 | ||||||||||||||||||
| 38 | const QVariant themeHint = theme->themeHint(QPlatformTheme::IconThemeSearchPaths); | - | ||||||||||||||||||
| 39 | if (themeHint.isValid()
| 0 | ||||||||||||||||||
| 40 | return never executed: themeHint.toStringList();return themeHint.toStringList();never executed: return themeHint.toStringList(); | 0 | ||||||||||||||||||
| 41 | } never executed: end of block | 0 | ||||||||||||||||||
| 42 | return never executed: QStringList();return QStringList();never executed: return QStringList(); | 0 | ||||||||||||||||||
| 43 | } | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | extern QFactoryLoader *qt_iconEngineFactoryLoader(); | - | ||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | void QIconLoader::ensureInitialized() | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | if (!m_initialized
| 0 | ||||||||||||||||||
| 50 | m_initialized = true; | - | ||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | ((!((static_cast<QGuiApplication *>(QCoreApplication::instance())))) ? qt_assert("qApp",__FILE__,104) : qt_noop()); | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | m_systemTheme = systemThemeName(); | - | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | if (m_systemTheme.isEmpty()
| 0 | ||||||||||||||||||
| 57 | m_systemTheme = fallbackTheme(); never executed: m_systemTheme = fallbackTheme(); | 0 | ||||||||||||||||||
| 58 | if (qt_iconEngineFactoryLoader()->keyMap().key(QLatin1String("svg"), -1) != -1
| 0 | ||||||||||||||||||
| 59 | m_supportsSvg = true; never executed: m_supportsSvg = true; | 0 | ||||||||||||||||||
| 60 | } never executed: end of block | 0 | ||||||||||||||||||
| 61 | } never executed: end of block | 0 | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | QIconLoader *QIconLoader::instance() | - | ||||||||||||||||||
| 64 | { | - | ||||||||||||||||||
| 65 | iconLoaderInstance()->ensureInitialized(); | - | ||||||||||||||||||
| 66 | return never executed: iconLoaderInstance();return iconLoaderInstance();never executed: return iconLoaderInstance(); | 0 | ||||||||||||||||||
| 67 | } | - | ||||||||||||||||||
| 68 | - | |||||||||||||||||||
| 69 | - | |||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | void QIconLoader::updateSystemTheme() | - | ||||||||||||||||||
| 72 | { | - | ||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | if (m_userTheme.isEmpty()
| 0 | ||||||||||||||||||
| 75 | QString theme = systemThemeName(); | - | ||||||||||||||||||
| 76 | if (theme.isEmpty()
| 0 | ||||||||||||||||||
| 77 | theme = fallbackTheme(); never executed: theme = fallbackTheme(); | 0 | ||||||||||||||||||
| 78 | if (theme != m_systemTheme
| 0 | ||||||||||||||||||
| 79 | m_systemTheme = theme; | - | ||||||||||||||||||
| 80 | invalidateKey(); | - | ||||||||||||||||||
| 81 | } never executed: end of block | 0 | ||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||
| 83 | } never executed: end of block | 0 | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | void QIconLoader::setThemeName(const QString &themeName) | - | ||||||||||||||||||
| 86 | { | - | ||||||||||||||||||
| 87 | m_userTheme = themeName; | - | ||||||||||||||||||
| 88 | invalidateKey(); | - | ||||||||||||||||||
| 89 | } never executed: end of block | 0 | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | void QIconLoader::setThemeSearchPath(const QStringList &searchPaths) | - | ||||||||||||||||||
| 92 | { | - | ||||||||||||||||||
| 93 | m_iconDirs = searchPaths; | - | ||||||||||||||||||
| 94 | themeList.clear(); | - | ||||||||||||||||||
| 95 | invalidateKey(); | - | ||||||||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | QStringList QIconLoader::themeSearchPaths() const | - | ||||||||||||||||||
| 99 | { | - | ||||||||||||||||||
| 100 | if (m_iconDirs.isEmpty()
| 0 | ||||||||||||||||||
| 101 | m_iconDirs = systemIconSearchPaths(); | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | m_iconDirs.append(QLatin1String(":/icons")); | - | ||||||||||||||||||
| 104 | } never executed: end of block | 0 | ||||||||||||||||||
| 105 | return never executed: m_iconDirs;return m_iconDirs;never executed: return m_iconDirs; | 0 | ||||||||||||||||||
| 106 | } | - | ||||||||||||||||||
| 107 | class QIconCacheGtkReader | - | ||||||||||||||||||
| 108 | { | - | ||||||||||||||||||
| 109 | public: | - | ||||||||||||||||||
| 110 | explicit QIconCacheGtkReader(const QString &themeDir); | - | ||||||||||||||||||
| 111 | QVector<const char *> lookup(const QString &); | - | ||||||||||||||||||
| 112 | bool isValid() const { return never executed: m_isValid;return m_isValid;never executed: }return m_isValid; | 0 | ||||||||||||||||||
| 113 | private: | - | ||||||||||||||||||
| 114 | QFile m_file; | - | ||||||||||||||||||
| 115 | const unsigned char *m_data; | - | ||||||||||||||||||
| 116 | quint64 m_size; | - | ||||||||||||||||||
| 117 | bool m_isValid; | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | quint16 read16(uint offset) | - | ||||||||||||||||||
| 120 | { | - | ||||||||||||||||||
| 121 | if (offset > m_size - 2
| 0 | ||||||||||||||||||
| 122 | m_isValid = false; | - | ||||||||||||||||||
| 123 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 124 | } | - | ||||||||||||||||||
| 125 | return never executed: m_data[offset+1] | m_data[offset] << 8;return m_data[offset+1] | m_data[offset] << 8;never executed: return m_data[offset+1] | m_data[offset] << 8; | 0 | ||||||||||||||||||
| 126 | } | - | ||||||||||||||||||
| 127 | quint32 read32(uint offset) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | if (offset > m_size - 4
| 0 | ||||||||||||||||||
| 130 | m_isValid = false; | - | ||||||||||||||||||
| 131 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | return never executed: m_data[offset+3] | m_data[offset+2] << 8return m_data[offset+3] | m_data[offset+2] << 8 | m_data[offset+1] << 16 | m_data[offset] << 24;never executed: return m_data[offset+3] | m_data[offset+2] << 8 | m_data[offset+1] << 16 | m_data[offset] << 24; | 0 | ||||||||||||||||||
| 134 | | m_data[offset+1] << 16 | m_data[offset] << 24; never executed: return m_data[offset+3] | m_data[offset+2] << 8 | m_data[offset+1] << 16 | m_data[offset] << 24; | 0 | ||||||||||||||||||
| 135 | } | - | ||||||||||||||||||
| 136 | }; | - | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | - | |||||||||||||||||||
| 139 | QIconCacheGtkReader::QIconCacheGtkReader(const QString &dirName) | - | ||||||||||||||||||
| 140 | : m_isValid(false) | - | ||||||||||||||||||
| 141 | { | - | ||||||||||||||||||
| 142 | QFileInfo info(dirName + QLatin1Literal("/icon-theme.cache")); | - | ||||||||||||||||||
| 143 | if (!info.exists()
| 0 | ||||||||||||||||||
| 144 | return; never executed: return; | 0 | ||||||||||||||||||
| 145 | m_file.setFileName(info.absoluteFilePath()); | - | ||||||||||||||||||
| 146 | if (!m_file.open(QFile::ReadOnly)
| 0 | ||||||||||||||||||
| 147 | return; never executed: return; | 0 | ||||||||||||||||||
| 148 | m_size = m_file.size(); | - | ||||||||||||||||||
| 149 | m_data = m_file.map(0, m_size); | - | ||||||||||||||||||
| 150 | if (!m_data
| 0 | ||||||||||||||||||
| 151 | return; never executed: return; | 0 | ||||||||||||||||||
| 152 | if (read16(0) != 1
| 0 | ||||||||||||||||||
| 153 | return; never executed: return; | 0 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | m_isValid = true; | - | ||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | - | |||||||||||||||||||
| 158 | auto lastModified = info.lastModified(); | - | ||||||||||||||||||
| 159 | quint32 dirListOffset = read32(8); | - | ||||||||||||||||||
| 160 | quint32 dirListLen = read32(dirListOffset); | - | ||||||||||||||||||
| 161 | for (uint i = 0; i < dirListLen
| 0 | ||||||||||||||||||
| 162 | quint32 offset = read32(dirListOffset + 4 + 4 * i); | - | ||||||||||||||||||
| 163 | if (!m_isValid
| 0 | ||||||||||||||||||
| 164 | + QString::fromUtf8(reinterpret_cast<const char*>(m_data + offset))).lastModified()
| 0 | ||||||||||||||||||
| 165 | m_isValid = false; | - | ||||||||||||||||||
| 166 | return; never executed: return; | 0 | ||||||||||||||||||
| 167 | } | - | ||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||
| 169 | } never executed: end of block | 0 | ||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | static quint32 icon_name_hash(const char *p) | - | ||||||||||||||||||
| 172 | { | - | ||||||||||||||||||
| 173 | quint32 h = static_cast<signed char>(*p); | - | ||||||||||||||||||
| 174 | for (p += 1; *
| 0 | ||||||||||||||||||
| 175 | h = (h << 5) - h + *p; never executed: h = (h << 5) - h + *p; | 0 | ||||||||||||||||||
| 176 | return never executed: h;return h;never executed: return h; | 0 | ||||||||||||||||||
| 177 | } | - | ||||||||||||||||||
| 178 | - | |||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | QVector<const char *> QIconCacheGtkReader::lookup(const QString &name) | - | ||||||||||||||||||
| 185 | { | - | ||||||||||||||||||
| 186 | QVector<const char *> ret; | - | ||||||||||||||||||
| 187 | if (!isValid()
| 0 | ||||||||||||||||||
| 188 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | QByteArray nameUtf8 = name.toUtf8(); | - | ||||||||||||||||||
| 191 | quint32 hash = icon_name_hash(nameUtf8); | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | quint32 hashOffset = read32(4); | - | ||||||||||||||||||
| 194 | quint32 hashBucketCount = read32(hashOffset); | - | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | if (!isValid()
| 0 | ||||||||||||||||||
| 197 | m_isValid = false; | - | ||||||||||||||||||
| 198 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 199 | } | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | quint32 bucketIndex = hash % hashBucketCount; | - | ||||||||||||||||||
| 202 | quint32 bucketOffset = read32(hashOffset + 4 + bucketIndex * 4); | - | ||||||||||||||||||
| 203 | while (bucketOffset > 0
| 0 | ||||||||||||||||||
| 204 | quint32 nameOff = read32(bucketOffset + 4); | - | ||||||||||||||||||
| 205 | if (nameOff < m_size
| 0 | ||||||||||||||||||
| 206 | quint32 dirListOffset = read32(8); | - | ||||||||||||||||||
| 207 | quint32 dirListLen = read32(dirListOffset); | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | quint32 listOffset = read32(bucketOffset+8); | - | ||||||||||||||||||
| 210 | quint32 listLen = read32(listOffset); | - | ||||||||||||||||||
| 211 | - | |||||||||||||||||||
| 212 | if (!m_isValid
| 0 | ||||||||||||||||||
| 213 | m_isValid = false; | - | ||||||||||||||||||
| 214 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 215 | } | - | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | ret.reserve(listLen); | - | ||||||||||||||||||
| 218 | for (uint j = 0; j < listLen
| 0 | ||||||||||||||||||
| 219 | quint32 dirIndex = read16(listOffset + 4 + 8 * j); | - | ||||||||||||||||||
| 220 | quint32 o = read32(dirListOffset + 4 + dirIndex*4); | - | ||||||||||||||||||
| 221 | if (!m_isValid
| 0 | ||||||||||||||||||
| 222 | m_isValid = false; | - | ||||||||||||||||||
| 223 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 224 | } | - | ||||||||||||||||||
| 225 | ret.append(reinterpret_cast<const char*>(m_data) + o); | - | ||||||||||||||||||
| 226 | } never executed: end of block | 0 | ||||||||||||||||||
| 227 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 228 | } | - | ||||||||||||||||||
| 229 | bucketOffset = read32(bucketOffset); | - | ||||||||||||||||||
| 230 | } never executed: end of block | 0 | ||||||||||||||||||
| 231 | return never executed: ret;return ret;never executed: return ret; | 0 | ||||||||||||||||||
| 232 | } | - | ||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | QIconTheme::QIconTheme(const QString &themeName) | - | ||||||||||||||||||
| 235 | : m_valid(false) | - | ||||||||||||||||||
| 236 | { | - | ||||||||||||||||||
| 237 | QFile themeIndex; | - | ||||||||||||||||||
| 238 | - | |||||||||||||||||||
| 239 | const QStringList iconDirs = QIcon::themeSearchPaths(); | - | ||||||||||||||||||
| 240 | for ( int i = 0 ; i < iconDirs.size()
| 0 | ||||||||||||||||||
| 241 | QDir iconDir(iconDirs[i]); | - | ||||||||||||||||||
| 242 | QString themeDir = iconDir.path() + QLatin1Char('/') + themeName; | - | ||||||||||||||||||
| 243 | QFileInfo themeDirInfo(themeDir); | - | ||||||||||||||||||
| 244 | - | |||||||||||||||||||
| 245 | if (themeDirInfo.isDir()
| 0 | ||||||||||||||||||
| 246 | m_contentDirs << themeDir; | - | ||||||||||||||||||
| 247 | m_gtkCaches << QSharedPointer<QIconCacheGtkReader>::create(themeDir); | - | ||||||||||||||||||
| 248 | } never executed: end of block | 0 | ||||||||||||||||||
| 249 | - | |||||||||||||||||||
| 250 | if (!m_valid
| 0 | ||||||||||||||||||
| 251 | themeIndex.setFileName(themeDir + QLatin1String("/index.theme")); | - | ||||||||||||||||||
| 252 | if (themeIndex.exists()
| 0 | ||||||||||||||||||
| 253 | m_valid = true; never executed: m_valid = true; | 0 | ||||||||||||||||||
| 254 | } never executed: end of block | 0 | ||||||||||||||||||
| 255 | } never executed: end of block | 0 | ||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | if (themeIndex.exists()
| 0 | ||||||||||||||||||
| 258 | const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat); | - | ||||||||||||||||||
| 259 | QStringListIterator keyIterator(indexReader.allKeys()); | - | ||||||||||||||||||
| 260 | while (keyIterator.hasNext()
| 0 | ||||||||||||||||||
| 261 | - | |||||||||||||||||||
| 262 | const QString key = keyIterator.next(); | - | ||||||||||||||||||
| 263 | if (key.endsWith(QLatin1String("/Size"))
| 0 | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | if (int size = indexReader.value(key).toInt()
| 0 | ||||||||||||||||||
| 267 | QString directoryKey = key.left(key.size() - 5); | - | ||||||||||||||||||
| 268 | QIconDirInfo dirInfo(directoryKey); | - | ||||||||||||||||||
| 269 | dirInfo.size = size; | - | ||||||||||||||||||
| 270 | QString type = indexReader.value(directoryKey + | - | ||||||||||||||||||
| 271 | QLatin1String("/Type") | - | ||||||||||||||||||
| 272 | ).toString(); | - | ||||||||||||||||||
| 273 | - | |||||||||||||||||||
| 274 | if (type == QLatin1String("Fixed")
| 0 | ||||||||||||||||||
| 275 | dirInfo.type = QIconDirInfo::Fixed; never executed: dirInfo.type = QIconDirInfo::Fixed; | 0 | ||||||||||||||||||
| 276 | else if (type == QLatin1String("Scalable")
| 0 | ||||||||||||||||||
| 277 | dirInfo.type = QIconDirInfo::Scalable; never executed: dirInfo.type = QIconDirInfo::Scalable; | 0 | ||||||||||||||||||
| 278 | else | - | ||||||||||||||||||
| 279 | dirInfo.type = QIconDirInfo::Threshold; never executed: dirInfo.type = QIconDirInfo::Threshold; | 0 | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | dirInfo.threshold = indexReader.value(directoryKey + | - | ||||||||||||||||||
| 282 | QLatin1String("/Threshold"), | - | ||||||||||||||||||
| 283 | 2).toInt(); | - | ||||||||||||||||||
| 284 | - | |||||||||||||||||||
| 285 | dirInfo.minSize = indexReader.value(directoryKey + | - | ||||||||||||||||||
| 286 | QLatin1String("/MinSize"), | - | ||||||||||||||||||
| 287 | size).toInt(); | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | dirInfo.maxSize = indexReader.value(directoryKey + | - | ||||||||||||||||||
| 290 | QLatin1String("/MaxSize"), | - | ||||||||||||||||||
| 291 | size).toInt(); | - | ||||||||||||||||||
| 292 | m_keyList.append(dirInfo); | - | ||||||||||||||||||
| 293 | } never executed: end of block | 0 | ||||||||||||||||||
| 294 | } never executed: end of block | 0 | ||||||||||||||||||
| 295 | } never executed: end of block | 0 | ||||||||||||||||||
| 296 | - | |||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | m_parents = indexReader.value( | - | ||||||||||||||||||
| 299 | QLatin1String("Icon Theme/Inherits")).toStringList(); | - | ||||||||||||||||||
| 300 | m_parents.removeAll(QString()); | - | ||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | if (m_parents.isEmpty()
| 0 | ||||||||||||||||||
| 304 | const QString fallback = fallbackTheme(); | - | ||||||||||||||||||
| 305 | if (!fallback.isEmpty()
| 0 | ||||||||||||||||||
| 306 | m_parents.append(fallback); never executed: m_parents.append(fallback); | 0 | ||||||||||||||||||
| 307 | } never executed: end of block | 0 | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | if (!m_parents.contains(QLatin1String("hicolor"))
| 0 | ||||||||||||||||||
| 311 | m_parents.append(QLatin1String("hicolor")); never executed: m_parents.append(QLatin1String("hicolor")); | 0 | ||||||||||||||||||
| 312 | } never executed: end of block | 0 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | } never executed: end of block | 0 | ||||||||||||||||||
| 315 | - | |||||||||||||||||||
| 316 | QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName, | - | ||||||||||||||||||
| 317 | const QString &iconName, | - | ||||||||||||||||||
| 318 | QStringList &visited) const | - | ||||||||||||||||||
| 319 | { | - | ||||||||||||||||||
| 320 | QThemeIconInfo info; | - | ||||||||||||||||||
| 321 | ((!(!themeName.isEmpty())) ? qt_assert("!themeName.isEmpty()",__FILE__,381) : qt_noop()); | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | visited << themeName; | - | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| 326 | QIconTheme theme = themeList.value(themeName); | - | ||||||||||||||||||
| 327 | if (!theme.isValid()
| 0 | ||||||||||||||||||
| 328 | theme = QIconTheme(themeName); | - | ||||||||||||||||||
| 329 | if (!theme.isValid()
| 0 | ||||||||||||||||||
| 330 | theme = QIconTheme(fallbackTheme()); never executed: theme = QIconTheme(fallbackTheme()); | 0 | ||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | themeList.insert(themeName, theme); | - | ||||||||||||||||||
| 333 | } never executed: end of block | 0 | ||||||||||||||||||
| 334 | - | |||||||||||||||||||
| 335 | const QStringList contentDirs = theme.contentDirs(); | - | ||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | QString iconNameFallback = iconName; | - | ||||||||||||||||||
| 338 | - | |||||||||||||||||||
| 339 | - | |||||||||||||||||||
| 340 | while (info.entries.isEmpty()
| 0 | ||||||||||||||||||
| 341 | const QString svgIconName = iconNameFallback + QLatin1String(".svg"); | - | ||||||||||||||||||
| 342 | const QString pngIconName = iconNameFallback + QLatin1String(".png"); | - | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | for (int i = 0; i < contentDirs.size()
| 0 | ||||||||||||||||||
| 346 | QVector<QIconDirInfo> subDirs = theme.keyList(); | - | ||||||||||||||||||
| 347 | - | |||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | - | |||||||||||||||||||
| 350 | auto cache = theme.m_gtkCaches.at(i); | - | ||||||||||||||||||
| 351 | if (cache->isValid()
| 0 | ||||||||||||||||||
| 352 | const auto result = cache->lookup(iconNameFallback); | - | ||||||||||||||||||
| 353 | if (cache->isValid()
| 0 | ||||||||||||||||||
| 354 | const QVector<QIconDirInfo> subDirsCopy = subDirs; | - | ||||||||||||||||||
| 355 | subDirs.clear(); | - | ||||||||||||||||||
| 356 | subDirs.reserve(result.count()); | - | ||||||||||||||||||
| 357 | for (const char *s : result) { | - | ||||||||||||||||||
| 358 | QString path = QString::fromUtf8(s); | - | ||||||||||||||||||
| 359 | auto it = std::find_if(subDirsCopy.cbegin(), subDirsCopy.cend(), | - | ||||||||||||||||||
| 360 | [&](const QIconDirInfo &info) { | - | ||||||||||||||||||
| 361 | return never executed: info.path == path;return info.path == path;never executed: } );return info.path == path; | 0 | ||||||||||||||||||
| 362 | if (it != subDirsCopy.cend()
| 0 | ||||||||||||||||||
| 363 | subDirs.append(*it); | - | ||||||||||||||||||
| 364 | } never executed: end of block | 0 | ||||||||||||||||||
| 365 | } never executed: end of block | 0 | ||||||||||||||||||
| 366 | } never executed: end of block | 0 | ||||||||||||||||||
| 367 | } never executed: end of block | 0 | ||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | QString contentDir = contentDirs.at(i) + QLatin1Char('/'); | - | ||||||||||||||||||
| 370 | for (int j = 0; j < subDirs.size()
| 0 | ||||||||||||||||||
| 371 | const QIconDirInfo &dirInfo = subDirs.at(j); | - | ||||||||||||||||||
| 372 | QString subdir = dirInfo.path; | - | ||||||||||||||||||
| 373 | QDir currentDir(contentDir + subdir); | - | ||||||||||||||||||
| 374 | if (currentDir.exists(pngIconName)
| 0 | ||||||||||||||||||
| 375 | PixmapEntry *iconEntry = new PixmapEntry; | - | ||||||||||||||||||
| 376 | iconEntry->dir = dirInfo; | - | ||||||||||||||||||
| 377 | iconEntry->filename = currentDir.filePath(pngIconName); | - | ||||||||||||||||||
| 378 | - | |||||||||||||||||||
| 379 | - | |||||||||||||||||||
| 380 | info.entries.prepend(iconEntry); | - | ||||||||||||||||||
| 381 | } never executed: else if (m_supportsSvgend of block
| 0 | ||||||||||||||||||
| 382 | currentDir.exists(svgIconName)
| 0 | ||||||||||||||||||
| 383 | ScalableEntry *iconEntry = new ScalableEntry; | - | ||||||||||||||||||
| 384 | iconEntry->dir = dirInfo; | - | ||||||||||||||||||
| 385 | iconEntry->filename = currentDir.filePath(svgIconName); | - | ||||||||||||||||||
| 386 | info.entries.append(iconEntry); | - | ||||||||||||||||||
| 387 | } never executed: end of block | 0 | ||||||||||||||||||
| 388 | } never executed: end of block | 0 | ||||||||||||||||||
| 389 | } never executed: end of block | 0 | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | if (!info.entries.isEmpty()
| 0 | ||||||||||||||||||
| 392 | info.iconName = iconNameFallback; | - | ||||||||||||||||||
| 393 | break; never executed: break; | 0 | ||||||||||||||||||
| 394 | } | - | ||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | const int indexOfDash = iconNameFallback.lastIndexOf(QLatin1Char('-')); | - | ||||||||||||||||||
| 398 | if (indexOfDash == -1
| 0 | ||||||||||||||||||
| 399 | break; never executed: break; | 0 | ||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | iconNameFallback.truncate(indexOfDash); | - | ||||||||||||||||||
| 402 | } never executed: end of block | 0 | ||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | if (info.entries.isEmpty()
| 0 | ||||||||||||||||||
| 405 | const QStringList parents = theme.parents(); | - | ||||||||||||||||||
| 406 | - | |||||||||||||||||||
| 407 | for (int i = 0 ; i < parents.size()
| 0 | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | const QString parentTheme = parents.at(i).trimmed(); | - | ||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | if (!visited.contains(parentTheme)
| 0 | ||||||||||||||||||
| 412 | info = findIconHelper(parentTheme, iconName, visited); never executed: info = findIconHelper(parentTheme, iconName, visited); | 0 | ||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | if (!info.entries.isEmpty()
| 0 | ||||||||||||||||||
| 415 | break; never executed: break; | 0 | ||||||||||||||||||
| 416 | } never executed: end of block | 0 | ||||||||||||||||||
| 417 | } never executed: end of block | 0 | ||||||||||||||||||
| 418 | return never executed: info;return info;never executed: return info; | 0 | ||||||||||||||||||
| 419 | } | - | ||||||||||||||||||
| 420 | - | |||||||||||||||||||
| 421 | QThemeIconInfo QIconLoader::loadIcon(const QString &name) const | - | ||||||||||||||||||
| 422 | { | - | ||||||||||||||||||
| 423 | if (!themeName().isEmpty()
| 0 | ||||||||||||||||||
| 424 | QStringList visited; | - | ||||||||||||||||||
| 425 | return never executed: findIconHelper(themeName(), name, visited);return findIconHelper(themeName(), name, visited);never executed: return findIconHelper(themeName(), name, visited); | 0 | ||||||||||||||||||
| 426 | } | - | ||||||||||||||||||
| 427 | - | |||||||||||||||||||
| 428 | return never executed: QThemeIconInfo();return QThemeIconInfo();never executed: return QThemeIconInfo(); | 0 | ||||||||||||||||||
| 429 | } | - | ||||||||||||||||||
| 430 | - | |||||||||||||||||||
| 431 | - | |||||||||||||||||||
| 432 | - | |||||||||||||||||||
| 433 | - | |||||||||||||||||||
| 434 | - | |||||||||||||||||||
| 435 | QIconLoaderEngine::QIconLoaderEngine(const QString& iconName) | - | ||||||||||||||||||
| 436 | : m_iconName(iconName), m_key(0) | - | ||||||||||||||||||
| 437 | { | - | ||||||||||||||||||
| 438 | } never executed: end of block | 0 | ||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | QIconLoaderEngine::~QIconLoaderEngine() | - | ||||||||||||||||||
| 441 | { | - | ||||||||||||||||||
| 442 | qDeleteAll(m_info.entries); | - | ||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | QIconLoaderEngine::QIconLoaderEngine(const QIconLoaderEngine &other) | - | ||||||||||||||||||
| 446 | : QIconEngine(other), | - | ||||||||||||||||||
| 447 | m_iconName(other.m_iconName), | - | ||||||||||||||||||
| 448 | m_key(0) | - | ||||||||||||||||||
| 449 | { | - | ||||||||||||||||||
| 450 | } never executed: end of block | 0 | ||||||||||||||||||
| 451 | - | |||||||||||||||||||
| 452 | QIconEngine *QIconLoaderEngine::clone() const | - | ||||||||||||||||||
| 453 | { | - | ||||||||||||||||||
| 454 | return never executed: new QIconLoaderEngine(*this);return new QIconLoaderEngine(*this);never executed: return new QIconLoaderEngine(*this); | 0 | ||||||||||||||||||
| 455 | } | - | ||||||||||||||||||
| 456 | - | |||||||||||||||||||
| 457 | bool QIconLoaderEngine::read(QDataStream &in) { | - | ||||||||||||||||||
| 458 | in >> m_iconName; | - | ||||||||||||||||||
| 459 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 460 | } | - | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | bool QIconLoaderEngine::write(QDataStream &out) const | - | ||||||||||||||||||
| 463 | { | - | ||||||||||||||||||
| 464 | out << m_iconName; | - | ||||||||||||||||||
| 465 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 466 | } | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | bool QIconLoaderEngine::hasIcon() const | - | ||||||||||||||||||
| 469 | { | - | ||||||||||||||||||
| 470 | return never executed: !(m_info.entries.isEmpty());return !(m_info.entries.isEmpty());never executed: return !(m_info.entries.isEmpty()); | 0 | ||||||||||||||||||
| 471 | } | - | ||||||||||||||||||
| 472 | - | |||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | void QIconLoaderEngine::ensureLoaded() | - | ||||||||||||||||||
| 475 | { | - | ||||||||||||||||||
| 476 | if (!(QIconLoader::instance()->themeKey() == m_key)
| 0 | ||||||||||||||||||
| 477 | qDeleteAll(m_info.entries); | - | ||||||||||||||||||
| 478 | m_info.entries.clear(); | - | ||||||||||||||||||
| 479 | m_info.iconName.clear(); | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | ((!(m_info.entries.size() == 0)) ? qt_assert("m_info.entries.size() == 0",__FILE__,541) : qt_noop()); | - | ||||||||||||||||||
| 482 | m_info = QIconLoader::instance()->loadIcon(m_iconName); | - | ||||||||||||||||||
| 483 | m_key = QIconLoader::instance()->themeKey(); | - | ||||||||||||||||||
| 484 | } never executed: end of block | 0 | ||||||||||||||||||
| 485 | } never executed: end of block | 0 | ||||||||||||||||||
| 486 | - | |||||||||||||||||||
| 487 | void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect, | - | ||||||||||||||||||
| 488 | QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||
| 489 | { | - | ||||||||||||||||||
| 490 | QSize pixmapSize = rect.size(); | - | ||||||||||||||||||
| 491 | painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); | - | ||||||||||||||||||
| 492 | } never executed: end of block | 0 | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | - | |||||||||||||||||||
| 495 | - | |||||||||||||||||||
| 496 | - | |||||||||||||||||||
| 497 | - | |||||||||||||||||||
| 498 | static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize) | - | ||||||||||||||||||
| 499 | { | - | ||||||||||||||||||
| 500 | if (dir.type == QIconDirInfo::Fixed
| 0 | ||||||||||||||||||
| 501 | return never executed: dir.size == iconsize;return dir.size == iconsize;never executed: return dir.size == iconsize; | 0 | ||||||||||||||||||
| 502 | - | |||||||||||||||||||
| 503 | } else if (dir.type == QIconDirInfo::Scalable
| 0 | ||||||||||||||||||
| 504 | return never executed: iconsize <= dir.maxSize &&return iconsize <= dir.maxSize && iconsize >= dir.minSize;never executed: return iconsize <= dir.maxSize && iconsize >= dir.minSize; | 0 | ||||||||||||||||||
| 505 | iconsize >= dir.minSize; never executed: return iconsize <= dir.maxSize && iconsize >= dir.minSize; | 0 | ||||||||||||||||||
| 506 | - | |||||||||||||||||||
| 507 | } else if (dir.type == QIconDirInfo::Threshold
| 0 | ||||||||||||||||||
| 508 | return never executed: iconsize >= dir.size - dir.threshold &&return iconsize >= dir.size - dir.threshold && iconsize <= dir.size + dir.threshold;never executed: return iconsize >= dir.size - dir.threshold && iconsize <= dir.size + dir.threshold; | 0 | ||||||||||||||||||
| 509 | iconsize <= dir.size + dir.threshold; never executed: return iconsize >= dir.size - dir.threshold && iconsize <= dir.size + dir.threshold; | 0 | ||||||||||||||||||
| 510 | } | - | ||||||||||||||||||
| 511 | - | |||||||||||||||||||
| 512 | ((!(1)) ? qt_assert("1",__FILE__,572) : qt_noop()); | - | ||||||||||||||||||
| 513 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 514 | } | - | ||||||||||||||||||
| 515 | - | |||||||||||||||||||
| 516 | - | |||||||||||||||||||
| 517 | - | |||||||||||||||||||
| 518 | - | |||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | static int directorySizeDistance(const QIconDirInfo &dir, int iconsize) | - | ||||||||||||||||||
| 521 | { | - | ||||||||||||||||||
| 522 | if (dir.type == QIconDirInfo::Fixed
| 0 | ||||||||||||||||||
| 523 | return never executed: qAbs(dir.size - iconsize);return qAbs(dir.size - iconsize);never executed: return qAbs(dir.size - iconsize); | 0 | ||||||||||||||||||
| 524 | - | |||||||||||||||||||
| 525 | } else if (dir.type == QIconDirInfo::Scalable
| 0 | ||||||||||||||||||
| 526 | if (iconsize < dir.minSize
| 0 | ||||||||||||||||||
| 527 | return never executed: dir.minSize - iconsize;return dir.minSize - iconsize;never executed: return dir.minSize - iconsize; | 0 | ||||||||||||||||||
| 528 | else if (iconsize > dir.maxSize
| 0 | ||||||||||||||||||
| 529 | return never executed: iconsize - dir.maxSize;return iconsize - dir.maxSize;never executed: return iconsize - dir.maxSize; | 0 | ||||||||||||||||||
| 530 | else | - | ||||||||||||||||||
| 531 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 532 | - | |||||||||||||||||||
| 533 | } else if (dir.type == QIconDirInfo::Threshold
| 0 | ||||||||||||||||||
| 534 | if (iconsize < dir.size - dir.threshold
| 0 | ||||||||||||||||||
| 535 | return never executed: dir.minSize - iconsize;return dir.minSize - iconsize;never executed: return dir.minSize - iconsize; | 0 | ||||||||||||||||||
| 536 | else if (iconsize > dir.size + dir.threshold
| 0 | ||||||||||||||||||
| 537 | return never executed: iconsize - dir.maxSize;return iconsize - dir.maxSize;never executed: return iconsize - dir.maxSize; | 0 | ||||||||||||||||||
| 538 | else return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 539 | } | - | ||||||||||||||||||
| 540 | - | |||||||||||||||||||
| 541 | ((!(1)) ? qt_assert("1",__FILE__,601) : qt_noop()); | - | ||||||||||||||||||
| 542 | return never executed: 2147483647;return 2147483647;never executed: return 2147483647; | 0 | ||||||||||||||||||
| 543 | } | - | ||||||||||||||||||
| 544 | - | |||||||||||||||||||
| 545 | QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size) | - | ||||||||||||||||||
| 546 | { | - | ||||||||||||||||||
| 547 | int iconsize = qMin(size.width(), size.height()); | - | ||||||||||||||||||
| 548 | - | |||||||||||||||||||
| 549 | - | |||||||||||||||||||
| 550 | - | |||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | const int numEntries = m_info.entries.size(); | - | ||||||||||||||||||
| 553 | - | |||||||||||||||||||
| 554 | - | |||||||||||||||||||
| 555 | for (int i = 0; i < numEntries
| 0 | ||||||||||||||||||
| 556 | QIconLoaderEngineEntry *entry = m_info.entries.at(i); | - | ||||||||||||||||||
| 557 | if (directoryMatchesSize(entry->dir, iconsize)
| 0 | ||||||||||||||||||
| 558 | return never executed: entry;return entry;never executed: return entry; | 0 | ||||||||||||||||||
| 559 | } | - | ||||||||||||||||||
| 560 | } never executed: end of block | 0 | ||||||||||||||||||
| 561 | - | |||||||||||||||||||
| 562 | - | |||||||||||||||||||
| 563 | int minimalSize = 2147483647; | - | ||||||||||||||||||
| 564 | QIconLoaderEngineEntry *closestMatch = 0; | - | ||||||||||||||||||
| 565 | for (int i = 0; i < numEntries
| 0 | ||||||||||||||||||
| 566 | QIconLoaderEngineEntry *entry = m_info.entries.at(i); | - | ||||||||||||||||||
| 567 | int distance = directorySizeDistance(entry->dir, iconsize); | - | ||||||||||||||||||
| 568 | if (distance < minimalSize
| 0 | ||||||||||||||||||
| 569 | minimalSize = distance; | - | ||||||||||||||||||
| 570 | closestMatch = entry; | - | ||||||||||||||||||
| 571 | } never executed: end of block | 0 | ||||||||||||||||||
| 572 | } never executed: end of block | 0 | ||||||||||||||||||
| 573 | return never executed: closestMatch;return closestMatch;never executed: return closestMatch; | 0 | ||||||||||||||||||
| 574 | } | - | ||||||||||||||||||
| 575 | - | |||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | - | |||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | - | |||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | - | |||||||||||||||||||
| 582 | QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode, | - | ||||||||||||||||||
| 583 | QIcon::State state) | - | ||||||||||||||||||
| 584 | { | - | ||||||||||||||||||
| 585 | ensureLoaded(); | - | ||||||||||||||||||
| 586 | - | |||||||||||||||||||
| 587 | QIconLoaderEngineEntry *entry = entryForSize(size); | - | ||||||||||||||||||
| 588 | if (entry
| 0 | ||||||||||||||||||
| 589 | const QIconDirInfo &dir = entry->dir; | - | ||||||||||||||||||
| 590 | if (dir.type == QIconDirInfo::Scalable
| 0 | ||||||||||||||||||
| 591 | return never executed: size;return size;never executed: return size; | 0 | ||||||||||||||||||
| 592 | else { | - | ||||||||||||||||||
| 593 | int result = qMin<int>(dir.size, qMin(size.width(), size.height())); | - | ||||||||||||||||||
| 594 | return never executed: QSize(result, result);return QSize(result, result);never executed: return QSize(result, result); | 0 | ||||||||||||||||||
| 595 | } | - | ||||||||||||||||||
| 596 | } | - | ||||||||||||||||||
| 597 | return never executed: QIconEngine::actualSize(size, mode, state);return QIconEngine::actualSize(size, mode, state);never executed: return QIconEngine::actualSize(size, mode, state); | 0 | ||||||||||||||||||
| 598 | } | - | ||||||||||||||||||
| 599 | - | |||||||||||||||||||
| 600 | QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||
| 601 | { | - | ||||||||||||||||||
| 602 | (void)state;; | - | ||||||||||||||||||
| 603 | - | |||||||||||||||||||
| 604 | - | |||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | if (basePixmap.isNull()
| 0 | ||||||||||||||||||
| 607 | basePixmap.load(filename); never executed: basePixmap.load(filename); | 0 | ||||||||||||||||||
| 608 | - | |||||||||||||||||||
| 609 | QSize actualSize = basePixmap.size(); | - | ||||||||||||||||||
| 610 | if (!actualSize.isNull()
| 0 | ||||||||||||||||||
| 611 | actualSize.scale(size, Qt::KeepAspectRatio); never executed: actualSize.scale(size, Qt::KeepAspectRatio); | 0 | ||||||||||||||||||
| 612 | - | |||||||||||||||||||
| 613 | QString key = QLatin1String("$qt_theme_") | - | ||||||||||||||||||
| 614 | % HexString<qint64>(basePixmap.cacheKey()) | - | ||||||||||||||||||
| 615 | % HexString<int>(mode) | - | ||||||||||||||||||
| 616 | % HexString<qint64>(QGuiApplication::palette().cacheKey()) | - | ||||||||||||||||||
| 617 | % HexString<int>(actualSize.width()) | - | ||||||||||||||||||
| 618 | % HexString<int>(actualSize.height()); | - | ||||||||||||||||||
| 619 | - | |||||||||||||||||||
| 620 | QPixmap cachedPixmap; | - | ||||||||||||||||||
| 621 | if (QPixmapCache::find(key, &cachedPixmap)
| 0 | ||||||||||||||||||
| 622 | return never executed: cachedPixmap;return cachedPixmap;never executed: return cachedPixmap; | 0 | ||||||||||||||||||
| 623 | } else { | - | ||||||||||||||||||
| 624 | if (basePixmap.size() != actualSize
| 0 | ||||||||||||||||||
| 625 | cachedPixmap = basePixmap.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); never executed: cachedPixmap = basePixmap.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); | 0 | ||||||||||||||||||
| 626 | else | - | ||||||||||||||||||
| 627 | cachedPixmap = basePixmap; never executed: cachedPixmap = basePixmap; | 0 | ||||||||||||||||||
| 628 | if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
| 0 | ||||||||||||||||||
| 629 | cachedPixmap = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, cachedPixmap); never executed: cachedPixmap = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, cachedPixmap); | 0 | ||||||||||||||||||
| 630 | QPixmapCache::insert(key, cachedPixmap); | - | ||||||||||||||||||
| 631 | } never executed: end of block | 0 | ||||||||||||||||||
| 632 | return never executed: cachedPixmap;return cachedPixmap;never executed: return cachedPixmap; | 0 | ||||||||||||||||||
| 633 | } | - | ||||||||||||||||||
| 634 | - | |||||||||||||||||||
| 635 | QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) | - | ||||||||||||||||||
| 636 | { | - | ||||||||||||||||||
| 637 | if (svgIcon.isNull()
| 0 | ||||||||||||||||||
| 638 | svgIcon = QIcon(filename); never executed: svgIcon = QIcon(filename); | 0 | ||||||||||||||||||
| 639 | - | |||||||||||||||||||
| 640 | - | |||||||||||||||||||
| 641 | return never executed: svgIcon.pixmap(size, mode, state);return svgIcon.pixmap(size, mode, state);never executed: return svgIcon.pixmap(size, mode, state); | 0 | ||||||||||||||||||
| 642 | } | - | ||||||||||||||||||
| 643 | - | |||||||||||||||||||
| 644 | QPixmap QIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode, | - | ||||||||||||||||||
| 645 | QIcon::State state) | - | ||||||||||||||||||
| 646 | { | - | ||||||||||||||||||
| 647 | ensureLoaded(); | - | ||||||||||||||||||
| 648 | - | |||||||||||||||||||
| 649 | QIconLoaderEngineEntry *entry = entryForSize(size); | - | ||||||||||||||||||
| 650 | if (entry
| 0 | ||||||||||||||||||
| 651 | return never executed: entry->pixmap(size, mode, state);return entry->pixmap(size, mode, state);never executed: return entry->pixmap(size, mode, state); | 0 | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | return never executed: QPixmap();return QPixmap();never executed: return QPixmap(); | 0 | ||||||||||||||||||
| 654 | } | - | ||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | QString QIconLoaderEngine::key() const | - | ||||||||||||||||||
| 657 | { | - | ||||||||||||||||||
| 658 | return never executed: QLatin1String("QIconLoaderEngine");return QLatin1String("QIconLoaderEngine");never executed: return QLatin1String("QIconLoaderEngine"); | 0 | ||||||||||||||||||
| 659 | } | - | ||||||||||||||||||
| 660 | - | |||||||||||||||||||
| 661 | void QIconLoaderEngine::virtual_hook(int id, void *data) | - | ||||||||||||||||||
| 662 | { | - | ||||||||||||||||||
| 663 | ensureLoaded(); | - | ||||||||||||||||||
| 664 | - | |||||||||||||||||||
| 665 | switch (id) { | - | ||||||||||||||||||
| 666 | case never executed: QIconEngine::AvailableSizesHook:case QIconEngine::AvailableSizesHook:never executed: case QIconEngine::AvailableSizesHook: | 0 | ||||||||||||||||||
| 667 | { | - | ||||||||||||||||||
| 668 | QIconEngine::AvailableSizesArgument &arg | - | ||||||||||||||||||
| 669 | = *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data); | - | ||||||||||||||||||
| 670 | const int N = m_info.entries.size(); | - | ||||||||||||||||||
| 671 | QList<QSize> sizes; | - | ||||||||||||||||||
| 672 | sizes.reserve(N); | - | ||||||||||||||||||
| 673 | - | |||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | for (int i = 0; i < N
| 0 | ||||||||||||||||||
| 676 | int size = m_info.entries.at(i)->dir.size; | - | ||||||||||||||||||
| 677 | sizes.append(QSize(size, size)); | - | ||||||||||||||||||
| 678 | } never executed: end of block | 0 | ||||||||||||||||||
| 679 | arg.sizes.swap(sizes); | - | ||||||||||||||||||
| 680 | } | - | ||||||||||||||||||
| 681 | break; never executed: break; | 0 | ||||||||||||||||||
| 682 | case never executed: QIconEngine::IconNameHook:case QIconEngine::IconNameHook:never executed: case QIconEngine::IconNameHook: | 0 | ||||||||||||||||||
| 683 | { | - | ||||||||||||||||||
| 684 | QString &name = *reinterpret_cast<QString*>(data); | - | ||||||||||||||||||
| 685 | name = m_info.iconName; | - | ||||||||||||||||||
| 686 | } | - | ||||||||||||||||||
| 687 | break; never executed: break; | 0 | ||||||||||||||||||
| 688 | case never executed: QIconEngine::IsNullHook:case QIconEngine::IsNullHook:never executed: case QIconEngine::IsNullHook: | 0 | ||||||||||||||||||
| 689 | { | - | ||||||||||||||||||
| 690 | *reinterpret_cast<bool*>(data) = m_info.entries.isEmpty(); | - | ||||||||||||||||||
| 691 | } | - | ||||||||||||||||||
| 692 | break; never executed: break; | 0 | ||||||||||||||||||
| 693 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 694 | QIconEngine::virtual_hook(id, data); | - | ||||||||||||||||||
| 695 | } never executed: end of block | 0 | ||||||||||||||||||
| 696 | } | - | ||||||||||||||||||
| 697 | - | |||||||||||||||||||
| 698 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |