- // System theme in $data/icons/$theme
- foreach(QString dir, dataDirNames) {
- path = QString("%1/icons/%2").arg(dir, theme);
- if(QFile::exists(path))
- _themedIconDirNames.append(path);
+ // First, look for a system theme
+ // This is supposed to only work on Unix, though other platforms might set $XDG_DATA_DIRS if they please.
+ QStringList iconDirNames = QString(qgetenv("XDG_DATA_DIRS")).split(':', QString::SkipEmptyParts);
+ if(!iconDirNames.isEmpty()) {
+ for(int i = 0; i < iconDirNames.count(); i++)
+ iconDirNames[i].append(QString("/icons/"));
+ }
+#ifdef Q_OS_UNIX
+ else {
+ // Provide a fallback
+ iconDirNames << "/usr/share/icons/";
+ }
+ // Add our prefix too
+ QString appDir = QCoreApplication::applicationDirPath();
+ int binpos = appDir.lastIndexOf("/bin");
+ if(binpos >= 0) {
+ appDir.replace(binpos, 4, "/share");
+ appDir.append("/icons/");
+ if(!iconDirNames.contains(appDir))
+ iconDirNames.append(appDir);