Don't search more generic icons in Applications and MimeTypes contexts
According to the specification https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html#guidelines 1) "the dash “-” character is used to separate levels of specificity in icon names, for all contexts other than MimeTypes" 2) "the “Applications” context should not use this method of falling back to more generic icons" Change-Id: Ia3536141158a4b6c1c4f85db8ad890514cf19e84 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> (cherry picked from commit e0c435cbfeaf1b82f759910fbf05d13e55d4f95f) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 79aa84aec200b3287e7948aa6c32c1ccb848c4d9)
This commit is contained in:
parent
30d093b0e8
commit
062e1bfacd
@ -392,6 +392,17 @@ QIconTheme::QIconTheme(const QString &themeName)
|
|||||||
dirInfo.maxSize = indexReader.value(directoryKey + "/MaxSize"_L1, size).toInt();
|
dirInfo.maxSize = indexReader.value(directoryKey + "/MaxSize"_L1, size).toInt();
|
||||||
|
|
||||||
dirInfo.scale = indexReader.value(directoryKey + "/Scale"_L1, 1).toInt();
|
dirInfo.scale = indexReader.value(directoryKey + "/Scale"_L1, 1).toInt();
|
||||||
|
|
||||||
|
const QString context = indexReader.value(directoryKey + "/Context"_L1).toString();
|
||||||
|
dirInfo.context = [context]() {
|
||||||
|
if (context == "Applications"_L1)
|
||||||
|
return QIconDirInfo::Applications;
|
||||||
|
else if (context == "MimeTypes"_L1)
|
||||||
|
return QIconDirInfo::MimeTypes;
|
||||||
|
else
|
||||||
|
return QIconDirInfo::UnknownContext;
|
||||||
|
}();
|
||||||
|
|
||||||
m_keyList.append(dirInfo);
|
m_keyList.append(dirInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -453,6 +464,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
const QStringList contentDirs = theme.contentDirs();
|
const QStringList contentDirs = theme.contentDirs();
|
||||||
|
|
||||||
QStringView iconNameFallback(iconName);
|
QStringView iconNameFallback(iconName);
|
||||||
|
bool searchingGenericFallback = false;
|
||||||
|
|
||||||
// Iterate through all icon's fallbacks in current theme
|
// Iterate through all icon's fallbacks in current theme
|
||||||
while (info.entries.empty()) {
|
while (info.entries.empty()) {
|
||||||
@ -487,6 +499,11 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
QString contentDir = contentDirs.at(i) + u'/';
|
QString contentDir = contentDirs.at(i) + u'/';
|
||||||
for (int j = 0; j < subDirs.size() ; ++j) {
|
for (int j = 0; j < subDirs.size() ; ++j) {
|
||||||
const QIconDirInfo &dirInfo = subDirs.at(j);
|
const QIconDirInfo &dirInfo = subDirs.at(j);
|
||||||
|
if (searchingGenericFallback &&
|
||||||
|
(dirInfo.context == QIconDirInfo::Applications ||
|
||||||
|
dirInfo.context == QIconDirInfo::MimeTypes))
|
||||||
|
continue;
|
||||||
|
|
||||||
const QString subDir = contentDir + dirInfo.path + u'/';
|
const QString subDir = contentDir + dirInfo.path + u'/';
|
||||||
const QString pngPath = subDir + pngIconName;
|
const QString pngPath = subDir + pngIconName;
|
||||||
if (QFile::exists(pngPath)) {
|
if (QFile::exists(pngPath)) {
|
||||||
@ -519,6 +536,7 @@ QThemeIconInfo QIconLoader::findIconHelper(const QString &themeName,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
iconNameFallback.truncate(indexOfDash);
|
iconNameFallback.truncate(indexOfDash);
|
||||||
|
searchingGenericFallback = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.entries.empty()) {
|
if (info.entries.empty()) {
|
||||||
|
@ -38,6 +38,7 @@ class QIconLoader;
|
|||||||
struct QIconDirInfo
|
struct QIconDirInfo
|
||||||
{
|
{
|
||||||
enum Type { Fixed, Scalable, Threshold, Fallback };
|
enum Type { Fixed, Scalable, Threshold, Fallback };
|
||||||
|
enum Context { UnknownContext, Applications, MimeTypes };
|
||||||
QIconDirInfo(const QString &_path = QString()) :
|
QIconDirInfo(const QString &_path = QString()) :
|
||||||
path(_path),
|
path(_path),
|
||||||
size(0),
|
size(0),
|
||||||
@ -45,7 +46,8 @@ struct QIconDirInfo
|
|||||||
minSize(0),
|
minSize(0),
|
||||||
threshold(0),
|
threshold(0),
|
||||||
scale(1),
|
scale(1),
|
||||||
type(Threshold) {}
|
type(Threshold),
|
||||||
|
context(UnknownContext) {}
|
||||||
QString path;
|
QString path;
|
||||||
short size;
|
short size;
|
||||||
short maxSize;
|
short maxSize;
|
||||||
@ -53,6 +55,7 @@ struct QIconDirInfo
|
|||||||
short threshold;
|
short threshold;
|
||||||
short scale;
|
short scale;
|
||||||
Type type;
|
Type type;
|
||||||
|
Context context;
|
||||||
};
|
};
|
||||||
Q_DECLARE_TYPEINFO(QIconDirInfo, Q_RELOCATABLE_TYPE);
|
Q_DECLARE_TYPEINFO(QIconDirInfo, Q_RELOCATABLE_TYPE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user