[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/icons
From: Christoph Feck <christoph () maxiom ! de>
Date: 2009-07-02 20:57:11
Message-ID: 1246568231.663430.9858.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 990630 by cfeck:
Fix x-generic icon lookup
The problem was with icons that do not exist. When we request
"application-x-gimp", we end up trying
application-x-gimp
* application-x
application
application-x-generic
* application-x
* application
This patch eliminates the marked lookups (see BR). Also, we ended
in getting the "X" icon for a request to "x-content-foobar".
Other minor changes:
* replace split/join to QString::truncate(), saves some allocations
* add QLatin1String() where appropiate
* fix some Windows path checking code
CCBUG: 195266
CCMAIL: faure@kde.org
M +24 -15 kiconloader.cpp
--- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #990629:990630
@@ -702,9 +702,11 @@
QString KIconLoaderPrivate::removeIconExtension(const QString &name) const
{
- if (name.endsWith(".png") || name.endsWith(".xpm") || name.endsWith(".svg")) {
+ if (name.endsWith(QLatin1String(".png"))
+ || name.endsWith(QLatin1String(".xpm"))
+ || name.endsWith(QLatin1String(".svg"))) {
return name.left(name.length() - 4);
- } else if (name.endsWith(".svgz")) {
+ } else if (name.endsWith(QLatin1String(".svgz"))) {
return name.left(name.length() - 5);
}
@@ -834,12 +836,13 @@
const char * const ext[4] = { ".png", ".svgz", ".svg", ".xpm" };
#endif
+ const bool genericFallback = name.endsWith(QLatin1String("-x-generic"));
+
foreach(KIconThemeNode *themeNode, links)
{
- QStringList nameParts = name.split('-');
QString currentName = name;
- while (!nameParts.isEmpty())
+ while (!currentName.isEmpty())
{
//kDebug(264) << "Looking up" << currentName;
@@ -873,9 +876,18 @@
return icon;
}
#endif
+ if (genericFallback)
+ // we already tested the base name
+ break;
- nameParts.removeLast();
- currentName = nameParts.join("-");
+ int rindex = currentName.lastIndexOf('-');
+ if (rindex < 0)
+ break;
+
+ currentName.truncate(rindex);
+
+ if (currentName.endsWith(QLatin1String("-x")))
+ currentName.chop(2);
}
}
return icon;
@@ -906,12 +918,9 @@
if (_name.isEmpty()
#ifdef Q_OS_WIN
- || (_name.length() > 1 &&
- (_name[0].isLetter() && _name[1] == QLatin1Char(':') ||
- _name[0] == '/' && _name[1] == '/' ||
- _name[0] == '\\' && _name[1] == '\\')))
+ || !QDir::isRelativePath(_name))
#else
- || _name[0] == '/')
+ || _name.at(0) == '/')
#endif
{
// we have either an absolute path or nothing to work with
@@ -1012,10 +1021,10 @@
}
if (!name.isEmpty()
-#ifdef Q_WS_WIN
+#ifdef Q_OS_WIN
&& !QDir::isRelativePath(name))
#else
- && name[0] == '/')
+ && name.at(0) == '/')
#endif
{
absolutePath = true;
@@ -1028,7 +1037,7 @@
{
QString key;
key.reserve(200);
- key.append("$kicou_");
+ key.append(QLatin1String("$kicou_"));
key.append(name).append('_').append(QString::number(size));
key.append(overlays.join("_")); // krazy:exclude=doublequote_chars
@@ -1121,7 +1130,7 @@
QString key;
key.reserve(100);
- key.append("$kico_");
+ key.append(QLatin1String("$kico_"));
key.append(name).append('_').append(QString::number(size));
QString overlayKey = overlays.join("_"); // krazy:exclude=doublequote_chars
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic