Changeset View
Changeset View
Standalone View
Standalone View
src/kicontheme.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | 75 | public: | |||
---|---|---|---|---|---|
80 | int mDefSize[6]; | 80 | int mDefSize[6]; | ||
81 | QList<int> mSizes[6]; | 81 | QList<int> mSizes[6]; | ||
82 | 82 | | |||
83 | int mDepth; | 83 | int mDepth; | ||
84 | QString mDir, mName, mInternalName, mDesc; | 84 | QString mDir, mName, mInternalName, mDesc; | ||
85 | QStringList mInherits; | 85 | QStringList mInherits; | ||
86 | QStringList mExtensions; | 86 | QStringList mExtensions; | ||
87 | QVector<KIconThemeDir *> mDirs; | 87 | QVector<KIconThemeDir *> mDirs; | ||
88 | QVector<KIconThemeDir *> mScaledDirs; | ||||
88 | bool followsColorScheme : 1; | 89 | bool followsColorScheme : 1; | ||
90 | | ||||
91 | /// Searches the given dirs vector for a matching icon | ||||
92 | QString iconPath(const QVector<KIconThemeDir *> &dirs, const QString &name, int size, qreal scale, KIconLoader::MatchType match) const; | ||||
89 | }; | 93 | }; | ||
90 | Q_GLOBAL_STATIC(QString, _theme) | 94 | Q_GLOBAL_STATIC(QString, _theme) | ||
91 | Q_GLOBAL_STATIC(QStringList, _theme_list) | 95 | Q_GLOBAL_STATIC(QStringList, _theme_list) | ||
92 | 96 | | |||
93 | /** | 97 | /** | ||
94 | * A subdirectory in an icon theme. | 98 | * A subdirectory in an icon theme. | ||
95 | */ | 99 | */ | ||
96 | class KIconThemeDir | 100 | class KIconThemeDir | ||
Show All 19 Lines | 102 | public: | |||
116 | KIconLoader::Type type() const | 120 | KIconLoader::Type type() const | ||
117 | { | 121 | { | ||
118 | return mType; | 122 | return mType; | ||
119 | } | 123 | } | ||
120 | int size() const | 124 | int size() const | ||
121 | { | 125 | { | ||
122 | return mSize; | 126 | return mSize; | ||
123 | } | 127 | } | ||
128 | int scale() const | ||||
129 | { | ||||
130 | return mScale; | ||||
131 | } | ||||
124 | int minSize() const | 132 | int minSize() const | ||
125 | { | 133 | { | ||
126 | return mMinSize; | 134 | return mMinSize; | ||
127 | } | 135 | } | ||
128 | int maxSize() const | 136 | int maxSize() const | ||
129 | { | 137 | { | ||
130 | return mMaxSize; | 138 | return mMaxSize; | ||
131 | } | 139 | } | ||
132 | int threshold() const | 140 | int threshold() const | ||
133 | { | 141 | { | ||
134 | return mThreshold; | 142 | return mThreshold; | ||
135 | } | 143 | } | ||
136 | 144 | | |||
137 | private: | 145 | private: | ||
138 | bool mbValid; | 146 | bool mbValid; | ||
139 | KIconLoader::Type mType; | 147 | KIconLoader::Type mType; | ||
140 | KIconLoader::Context mContext; | 148 | KIconLoader::Context mContext; | ||
141 | int mSize, mMinSize, mMaxSize; | 149 | int mSize, mScale, mMinSize, mMaxSize; | ||
142 | int mThreshold; | 150 | int mThreshold; | ||
143 | 151 | | |||
144 | const QString mBaseDir; | 152 | const QString mBaseDir; | ||
145 | const QString mThemeDir; | 153 | const QString mThemeDir; | ||
146 | }; | 154 | }; | ||
147 | 155 | | |||
156 | QString KIconTheme::KIconThemePrivate::iconPath(const QVector<KIconThemeDir *> &dirs, const QString &name, int size, qreal scale, KIconLoader::MatchType match) const | ||||
157 | { | ||||
158 | QString path; | ||||
159 | QString tempPath; // used to cache icon path if it exists | ||||
160 | | ||||
161 | int delta = -INT_MAX; // current icon size delta of 'icon' | ||||
162 | int dw = INT_MAX; // icon size delta of current directory | ||||
163 | | ||||
164 | // Rather downsample than upsample | ||||
165 | int integerScale = 1; | ||||
166 | if (scale > 1.1) { | ||||
167 | integerScale = 2; | ||||
168 | } else if (scale > 2.1) { | ||||
169 | integerScale = 3; | ||||
cfeck: Unless the XDG spec forbids this, please add scale 4, too. Those 8K screens are everywhere ;) | |||||
170 | } | ||||
171 | | ||||
172 | // Search the directory that contains the icon which matches best to the requested | ||||
173 | // size. If there is no directory which matches exactly to the requested size, the | ||||
174 | // following criterias get applied: | ||||
175 | // - Take a directory having icons with a minimum difference to the requested size. | ||||
176 | // - Prefer directories that allow a downscaling even if the difference to | ||||
177 | // the requested size is bigger than a directory where an upscaling is required. | ||||
178 | for (KIconThemeDir *dir : dirs) { | ||||
179 | if (dir->scale() != integerScale) { | ||||
180 | continue; | ||||
181 | } | ||||
182 | | ||||
183 | if (match == KIconLoader::MatchExact) { | ||||
184 | if ((dir->type() == KIconLoader::Fixed) && (dir->size() != size)) { | ||||
185 | continue; | ||||
186 | } | ||||
187 | if ((dir->type() == KIconLoader::Scalable) && | ||||
188 | ((size < dir->minSize()) || (size > dir->maxSize()))) { | ||||
189 | continue; | ||||
190 | } | ||||
191 | if ((dir->type() == KIconLoader::Threshold) && | ||||
192 | (abs(dir->size() - size) > dir->threshold())) { | ||||
193 | continue; | ||||
194 | } | ||||
195 | } else { | ||||
196 | // dw < 0 means need to scale up to get an icon of the requested size. | ||||
197 | // Upscaling should only be done if no larger icon is available. | ||||
198 | if (dir->type() == KIconLoader::Fixed) { | ||||
199 | dw = dir->size() - size; | ||||
200 | } else if (dir->type() == KIconLoader::Scalable) { | ||||
201 | if (size < dir->minSize()) { | ||||
202 | dw = dir->minSize() - size; | ||||
203 | } else if (size > dir->maxSize()) { | ||||
204 | dw = dir->maxSize() - size; | ||||
205 | } else { | ||||
206 | dw = 0; | ||||
207 | } | ||||
208 | } else if (dir->type() == KIconLoader::Threshold) { | ||||
209 | if (size < dir->size() - dir->threshold()) { | ||||
210 | dw = dir->size() - dir->threshold() - size; | ||||
211 | } else if (size > dir->size() + dir->threshold()) { | ||||
212 | dw = dir->size() + dir->threshold() - size; | ||||
213 | } else { | ||||
214 | dw = 0; | ||||
215 | } | ||||
216 | } | ||||
217 | // Usually if the delta (= 'dw') of the current directory is | ||||
218 | // not smaller than the delta (= 'delta') of the currently best | ||||
219 | // matching icon, this candidate can be skipped. But skipping | ||||
220 | // the candidate may only be done, if this does not imply | ||||
221 | // in an upscaling of the icon (it is OK to use a directory with | ||||
222 | // smaller icons that what we've already found, however). | ||||
223 | if ((abs(dw) >= abs(delta)) && ((dw < 0) || (delta > 0))) { | ||||
224 | continue; | ||||
225 | } | ||||
226 | } | ||||
227 | | ||||
228 | // cache the result of iconPath() call which checks if file exists | ||||
229 | tempPath = dir->iconPath(name); | ||||
230 | | ||||
231 | if (tempPath.isEmpty()) { | ||||
232 | continue; | ||||
233 | } | ||||
234 | | ||||
235 | path = tempPath; | ||||
148 | 236 | | |||
237 | // if we got in MatchExact that far, we find no better | ||||
238 | if (match == KIconLoader::MatchExact) { | ||||
239 | return path; | ||||
240 | } | ||||
241 | delta = dw; | ||||
242 | if (delta == 0) { | ||||
243 | return path; // We won't find a better match anyway | ||||
244 | } | ||||
245 | } | ||||
246 | return path; | ||||
247 | } | ||||
149 | 248 | | |||
150 | KIconTheme::KIconTheme(const QString &name, const QString &appName, const QString &basePathHint) | 249 | KIconTheme::KIconTheme(const QString &name, const QString &appName, const QString &basePathHint) | ||
151 | : d(new KIconThemePrivate) | 250 | : d(new KIconThemePrivate) | ||
152 | { | 251 | { | ||
153 | d->mInternalName = name; | 252 | d->mInternalName = name; | ||
154 | 253 | | |||
155 | QStringList themeDirs; | 254 | QStringList themeDirs; | ||
156 | QSet<QString> addedDirs; // Used for avoiding duplicates. | 255 | QSet<QString> addedDirs; // Used for avoiding duplicates. | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
229 | } | 328 | } | ||
230 | 329 | | |||
231 | d->hidden = cfg.readEntry("Hidden", false); | 330 | d->hidden = cfg.readEntry("Hidden", false); | ||
232 | d->followsColorScheme = cfg.readEntry("FollowsColorScheme", false); | 331 | d->followsColorScheme = cfg.readEntry("FollowsColorScheme", false); | ||
233 | d->example = cfg.readPathEntry("Example", QString()); | 332 | d->example = cfg.readPathEntry("Example", QString()); | ||
234 | d->screenshot = cfg.readPathEntry("ScreenShot", QString()); | 333 | d->screenshot = cfg.readPathEntry("ScreenShot", QString()); | ||
235 | d->mExtensions = cfg.readEntry("KDE-Extensions", QStringList{ QStringLiteral(".png"), QStringLiteral(".svgz"), QStringLiteral(".svg"), QStringLiteral(".xpm") }); | 334 | d->mExtensions = cfg.readEntry("KDE-Extensions", QStringList{ QStringLiteral(".png"), QStringLiteral(".svgz"), QStringLiteral(".svg"), QStringLiteral(".xpm") }); | ||
236 | 335 | | |||
237 | const QStringList dirs = cfg.readPathEntry("Directories", QStringList()); | 336 | const QStringList dirs = cfg.readPathEntry("Directories", QStringList()) | ||
337 | + cfg.readPathEntry("ScaledDirectories", QStringList()); | ||||
238 | for (QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) { | 338 | for (QStringList::ConstIterator it = dirs.begin(); it != dirs.end(); ++it) { | ||
239 | KConfigGroup cg(d->sharedConfig, *it); | 339 | KConfigGroup cg(d->sharedConfig, *it); | ||
240 | for (QStringList::ConstIterator itDir = themeDirs.constBegin(); itDir != themeDirs.constEnd(); ++itDir) { | 340 | for (QStringList::ConstIterator itDir = themeDirs.constBegin(); itDir != themeDirs.constEnd(); ++itDir) { | ||
241 | const QString currentDir(*itDir + *it + QLatin1Char('/')); | 341 | const QString currentDir(*itDir + *it + QLatin1Char('/')); | ||
242 | if (!addedDirs.contains(currentDir) && QDir(currentDir).exists()) { | 342 | if (!addedDirs.contains(currentDir) && QDir(currentDir).exists()) { | ||
243 | addedDirs.insert(currentDir); | 343 | addedDirs.insert(currentDir); | ||
244 | KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg); | 344 | KIconThemeDir *dir = new KIconThemeDir(*itDir, *it, cg); | ||
245 | if (dir->isValid()) { | 345 | if (dir->isValid()) { | ||
346 | if (dir->scale() > 1) { | ||||
347 | d->mScaledDirs.append(dir); | ||||
348 | } else { | ||||
246 | d->mDirs.append(dir); | 349 | d->mDirs.append(dir); | ||
350 | } | ||||
247 | } else { | 351 | } else { | ||
248 | delete dir; | 352 | delete dir; | ||
249 | } | 353 | } | ||
250 | } | 354 | } | ||
251 | } | 355 | } | ||
252 | } | 356 | } | ||
253 | 357 | | |||
254 | QStringList groups; | 358 | QStringList groups; | ||
Show All 10 Lines | 367 | for (int i = 0; i < groups.size(); ++i) { | |||
265 | d->mDefSize[i] = cg.readEntry(group + QStringLiteral("Default"), defDefSizes[i]); | 369 | d->mDefSize[i] = cg.readEntry(group + QStringLiteral("Default"), defDefSizes[i]); | ||
266 | d->mSizes[i] = cg.readEntry(group + QStringLiteral("Sizes"), QList<int>()); | 370 | d->mSizes[i] = cg.readEntry(group + QStringLiteral("Sizes"), QList<int>()); | ||
267 | } | 371 | } | ||
268 | } | 372 | } | ||
269 | 373 | | |||
270 | KIconTheme::~KIconTheme() | 374 | KIconTheme::~KIconTheme() | ||
271 | { | 375 | { | ||
272 | qDeleteAll(d->mDirs); | 376 | qDeleteAll(d->mDirs); | ||
377 | qDeleteAll(d->mScaledDirs); | ||||
273 | delete d; | 378 | delete d; | ||
274 | } | 379 | } | ||
275 | 380 | | |||
276 | QString KIconTheme::name() const | 381 | QString KIconTheme::name() const | ||
277 | { | 382 | { | ||
278 | return d->mName; | 383 | return d->mName; | ||
279 | } | 384 | } | ||
280 | 385 | | |||
Show All 24 Lines | |||||
305 | 410 | | |||
306 | QStringList KIconTheme::inherits() const | 411 | QStringList KIconTheme::inherits() const | ||
307 | { | 412 | { | ||
308 | return d->mInherits; | 413 | return d->mInherits; | ||
309 | } | 414 | } | ||
310 | 415 | | |||
311 | bool KIconTheme::isValid() const | 416 | bool KIconTheme::isValid() const | ||
312 | { | 417 | { | ||
313 | return !d->mDirs.isEmpty(); | 418 | return !d->mDirs.isEmpty() || !d->mScaledDirs.isEmpty(); | ||
314 | } | 419 | } | ||
315 | 420 | | |||
316 | bool KIconTheme::isHidden() const | 421 | bool KIconTheme::isHidden() const | ||
317 | { | 422 | { | ||
318 | return d->hidden; | 423 | return d->hidden; | ||
319 | } | 424 | } | ||
320 | 425 | | |||
321 | int KIconTheme::depth() const | 426 | int KIconTheme::depth() const | ||
Show All 18 Lines | 441 | { | |||
340 | } | 445 | } | ||
341 | return d->mSizes[group]; | 446 | return d->mSizes[group]; | ||
342 | } | 447 | } | ||
343 | 448 | | |||
344 | QStringList KIconTheme::queryIcons(int size, KIconLoader::Context context) const | 449 | QStringList KIconTheme::queryIcons(int size, KIconLoader::Context context) const | ||
345 | { | 450 | { | ||
346 | // Try to find exact match | 451 | // Try to find exact match | ||
347 | QStringList result; | 452 | QStringList result; | ||
348 | foreach (KIconThemeDir* dir, d->mDirs) { | 453 | foreach (KIconThemeDir* dir, d->mDirs + d->mScaledDirs) { | ||
349 | if ((context != KIconLoader::Any) && (context != dir->context())) { | 454 | if ((context != KIconLoader::Any) && (context != dir->context())) { | ||
350 | continue; | 455 | continue; | ||
351 | } | 456 | } | ||
352 | if ((dir->type() == KIconLoader::Fixed) && (dir->size() == size)) { | 457 | if ((dir->type() == KIconLoader::Fixed) && (dir->size() == size)) { | ||
353 | result += dir->iconList(); | 458 | result += dir->iconList(); | ||
354 | continue; | 459 | continue; | ||
355 | } | 460 | } | ||
356 | if ((dir->type() == KIconLoader::Scalable) && | 461 | if ((dir->type() == KIconLoader::Scalable) && | ||
Show All 40 Lines | 499 | { | |||
397 | // We want all the icons for a given context, but we prefer icons | 502 | // We want all the icons for a given context, but we prefer icons | ||
398 | // of size size . Note that this may (will) include duplicate icons | 503 | // of size size . Note that this may (will) include duplicate icons | ||
399 | //QStringList iconlist[34]; // 33 == 48-16+1 | 504 | //QStringList iconlist[34]; // 33 == 48-16+1 | ||
400 | QStringList iconlist[128]; // 33 == 48-16+1 | 505 | QStringList iconlist[128]; // 33 == 48-16+1 | ||
401 | // Usually, only the 0, 6 (22-16), 10 (32-22), 16 (48-32 or 32-16), | 506 | // Usually, only the 0, 6 (22-16), 10 (32-22), 16 (48-32 or 32-16), | ||
402 | // 26 (48-22) and 32 (48-16) will be used, but who knows if someone | 507 | // 26 (48-22) and 32 (48-16) will be used, but who knows if someone | ||
403 | // will make icon themes with different icon sizes. | 508 | // will make icon themes with different icon sizes. | ||
404 | 509 | | |||
405 | foreach (KIconThemeDir *dir, d->mDirs) { | 510 | foreach (KIconThemeDir *dir, d->mDirs + d->mScaledDirs) { | ||
406 | if ((context != KIconLoader::Any) && (context != dir->context())) { | 511 | if ((context != KIconLoader::Any) && (context != dir->context())) { | ||
407 | continue; | 512 | continue; | ||
408 | } | 513 | } | ||
409 | dw = abs(dir->size() - size); | 514 | dw = abs(dir->size() - size); | ||
410 | iconlist[(dw < 127) ? dw : 127] += dir->iconList(); | 515 | iconlist[(dw < 127) ? dw : 127] += dir->iconList(); | ||
411 | } | 516 | } | ||
412 | 517 | | |||
413 | QStringList iconlistResult; | 518 | QStringList iconlistResult; | ||
414 | for (int i = 0; i < 128; i++) { | 519 | for (int i = 0; i < 128; i++) { | ||
415 | iconlistResult += iconlist[i]; | 520 | iconlistResult += iconlist[i]; | ||
416 | } | 521 | } | ||
417 | 522 | | |||
418 | return iconlistResult; | 523 | return iconlistResult; | ||
419 | } | 524 | } | ||
420 | 525 | | |||
421 | bool KIconTheme::hasContext(KIconLoader::Context context) const | 526 | bool KIconTheme::hasContext(KIconLoader::Context context) const | ||
422 | { | 527 | { | ||
423 | foreach (KIconThemeDir *dir, d->mDirs) { | 528 | foreach (KIconThemeDir *dir, d->mDirs + d->mScaledDirs) { | ||
424 | if ((context == KIconLoader::Any) || (context == dir->context())) { | 529 | if ((context == KIconLoader::Any) || (context == dir->context())) { | ||
425 | return true; | 530 | return true; | ||
426 | } | 531 | } | ||
427 | } | 532 | } | ||
428 | return false; | 533 | return false; | ||
429 | } | 534 | } | ||
430 | 535 | | |||
431 | QString KIconTheme::iconPathByName(const QString &iconName, int size, KIconLoader::MatchType match) const | 536 | QString KIconTheme::iconPathByName(const QString &iconName, int size, KIconLoader::MatchType match) const | ||
432 | { | 537 | { | ||
538 | return iconPathByName(iconName, size, match, 1 /*scale*/); | ||||
539 | } | ||||
540 | | ||||
541 | QString KIconTheme::iconPathByName(const QString &iconName, int size, KIconLoader::MatchType match, qreal scale) const | ||||
542 | { | ||||
433 | foreach(const QString ¤t, d->mExtensions) { | 543 | foreach(const QString ¤t, d->mExtensions) { | ||
434 | const QString path = iconPath(iconName + current, size, match); | 544 | const QString path = iconPath(iconName + current, size, match, scale); | ||
435 | if (!path.isEmpty()) | 545 | if (!path.isEmpty()) | ||
436 | return path; | 546 | return path; | ||
437 | } | 547 | } | ||
438 | return QString(); | 548 | return QString(); | ||
439 | } | 549 | } | ||
440 | 550 | | |||
441 | bool KIconTheme::followsColorScheme() const | 551 | bool KIconTheme::followsColorScheme() const | ||
442 | { | 552 | { | ||
443 | return d->followsColorScheme; | 553 | return d->followsColorScheme; | ||
444 | } | 554 | } | ||
445 | 555 | | |||
446 | QString KIconTheme::iconPath(const QString &name, int size, KIconLoader::MatchType match) const | 556 | QString KIconTheme::iconPath(const QString &name, int size, KIconLoader::MatchType match) const | ||
447 | { | 557 | { | ||
448 | QString path; | 558 | return iconPath(name, size, match, 1 /*scale*/); | ||
449 | QString tempPath; // used to cache icon path if it exists | | |||
450 | int delta = -INT_MAX; // current icon size delta of 'icon' | | |||
451 | int dw = INT_MAX; // icon size delta of current directory | | |||
452 | | ||||
453 | // Search the directory that contains the icon which matches best to the requested | | |||
454 | // size. If there is no directory which matches exactly to the requested size, the | | |||
455 | // following criterias get applied: | | |||
456 | // - Take a directory having icons with a minimum difference to the requested size. | | |||
457 | // - Prefer directories that allow a downscaling even if the difference to | | |||
458 | // the requested size is bigger than a directory where an upscaling is required. | | |||
459 | foreach (KIconThemeDir *dir, d->mDirs) { | | |||
460 | if (match == KIconLoader::MatchExact) { | | |||
461 | if ((dir->type() == KIconLoader::Fixed) && (dir->size() != size)) { | | |||
462 | continue; | | |||
463 | } | | |||
464 | if ((dir->type() == KIconLoader::Scalable) && | | |||
465 | ((size < dir->minSize()) || (size > dir->maxSize()))) { | | |||
466 | continue; | | |||
467 | } | | |||
468 | if ((dir->type() == KIconLoader::Threshold) && | | |||
469 | (abs(dir->size() - size) > dir->threshold())) { | | |||
470 | continue; | | |||
471 | } | | |||
472 | } else { | | |||
473 | // dw < 0 means need to scale up to get an icon of the requested size. | | |||
474 | // Upscaling should only be done if no larger icon is available. | | |||
475 | if (dir->type() == KIconLoader::Fixed) { | | |||
476 | dw = dir->size() - size; | | |||
477 | } else if (dir->type() == KIconLoader::Scalable) { | | |||
478 | if (size < dir->minSize()) { | | |||
479 | dw = dir->minSize() - size; | | |||
480 | } else if (size > dir->maxSize()) { | | |||
481 | dw = dir->maxSize() - size; | | |||
482 | } else { | | |||
483 | dw = 0; | | |||
484 | } | | |||
485 | } else if (dir->type() == KIconLoader::Threshold) { | | |||
486 | if (size < dir->size() - dir->threshold()) { | | |||
487 | dw = dir->size() - dir->threshold() - size; | | |||
488 | } else if (size > dir->size() + dir->threshold()) { | | |||
489 | dw = dir->size() + dir->threshold() - size; | | |||
490 | } else { | | |||
491 | dw = 0; | | |||
492 | } | | |||
493 | } | | |||
494 | // Usually if the delta (= 'dw') of the current directory is | | |||
495 | // not smaller than the delta (= 'delta') of the currently best | | |||
496 | // matching icon, this candidate can be skipped. But skipping | | |||
497 | // the candidate may only be done, if this does not imply | | |||
498 | // in an upscaling of the icon (it is OK to use a directory with | | |||
499 | // smaller icons that what we've already found, however). | | |||
500 | if ((abs(dw) >= abs(delta)) && ((dw < 0) || (delta > 0))) { | | |||
501 | continue; | | |||
502 | } | 559 | } | ||
503 | } | | |||
504 | | ||||
505 | // cache the result of iconPath() call which checks if file exists | | |||
506 | tempPath = dir->iconPath(name); | | |||
507 | 560 | | |||
508 | if (tempPath.isEmpty()) { | 561 | QString KIconTheme::iconPath(const QString &name, int size, KIconLoader::MatchType match, qreal scale) const | ||
509 | continue; | 562 | { | ||
510 | } | 563 | // first look for a scaled image at exactly the requested size | ||
511 | path = tempPath; | 564 | QString path = d->iconPath(d->mScaledDirs, name, size, scale, KIconLoader::MatchExact); | ||
512 | 565 | | |||
513 | // if we got in MatchExact that far, we find no better | 566 | // then look for an unscaled one but request it at larger size so it doesn't become blurry | ||
514 | if (match == KIconLoader::MatchExact) { | 567 | if (path.isEmpty()) { | ||
515 | return path; | 568 | path = d->iconPath(d->mDirs, name, size * scale, 1, match); | ||
516 | } | | |||
517 | delta = dw; | | |||
518 | if (delta == 0) { | | |||
519 | return path; // We won't find a better match anyway | | |||
520 | } | | |||
521 | } | 569 | } | ||
522 | return path; | 570 | return path; | ||
523 | } | 571 | } | ||
524 | 572 | | |||
525 | // static | 573 | // static | ||
526 | QString KIconTheme::current() | 574 | QString KIconTheme::current() | ||
527 | { | 575 | { | ||
528 | // Static pointers because of unloading problems wrt DSO's. | 576 | // Static pointers because of unloading problems wrt DSO's. | ||
▲ Show 20 Lines • Show All 124 Lines • ▼ Show 20 Line(s) | |||||
653 | } | 701 | } | ||
654 | 702 | | |||
655 | /*** KIconThemeDir ***/ | 703 | /*** KIconThemeDir ***/ | ||
656 | 704 | | |||
657 | KIconThemeDir::KIconThemeDir(const QString &basedir, const QString &themedir, const KConfigGroup &config) | 705 | KIconThemeDir::KIconThemeDir(const QString &basedir, const QString &themedir, const KConfigGroup &config) | ||
658 | : mbValid(false) | 706 | : mbValid(false) | ||
659 | , mType(KIconLoader::Fixed) | 707 | , mType(KIconLoader::Fixed) | ||
660 | , mSize(config.readEntry("Size", 0)) | 708 | , mSize(config.readEntry("Size", 0)) | ||
709 | , mScale(config.readEntry("Scale", 1)) | ||||
661 | , mMinSize(1) // just set the variables to something | 710 | , mMinSize(1) // just set the variables to something | ||
662 | , mMaxSize(50) // meaningful in case someone calls minSize or maxSize | 711 | , mMaxSize(50) // meaningful in case someone calls minSize or maxSize | ||
663 | , mThreshold(2) | 712 | , mThreshold(2) | ||
664 | , mBaseDir(basedir) | 713 | , mBaseDir(basedir) | ||
665 | , mThemeDir(themedir) | 714 | , mThemeDir(themedir) | ||
666 | { | 715 | { | ||
667 | if (mSize == 0) { | 716 | if (mSize == 0) { | ||
668 | return; | 717 | return; | ||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |
Unless the XDG spec forbids this, please add scale 4, too. Those 8K screens are everywhere ;)