diff --git a/zeal/main.cpp b/zeal/main.cpp index d4226e6d5..760f7cf3f 100644 --- a/zeal/main.cpp +++ b/zeal/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -82,6 +83,18 @@ int main(int argc, char *argv[]) return -1; // Exit already a process running } + // look for icons in: + // 1. user's data directory (same as docsets dir, but in icons/) + // 2. executable directory/icons + // 3. on unix, standard/legacy install location + // 4. current directory/icons + QDir::setSearchPaths("icons", QStandardPaths::locateAll(QStandardPaths::DataLocation, "icons", QStandardPaths::LocateDirectory)); + QDir::addSearchPath("icons", QDir(QCoreApplication::applicationDirPath()).absoluteFilePath("icons")); +#ifndef WIN32 + QDir::addSearchPath("icons", "/usr/share/pixmaps/zeal"); +#endif + QDir::addSearchPath("icons", "./icons"); + MainWindow w; if (!w.startHidden()) diff --git a/zeal/zealdocsetsregistry.h b/zeal/zealdocsetsregistry.h index 7354069fb..49a0f7893 100644 --- a/zeal/zealdocsetsregistry.h +++ b/zeal/zealdocsetsregistry.h @@ -76,20 +76,14 @@ class ZealDocsetsRegistry : public QObject icon = QIcon(entry->dir.absoluteFilePath("icon.png")); } if(icon.availableSizes().isEmpty()) { -#ifdef WIN32 - QDir icondir(QCoreApplication::applicationDirPath()); - icondir.cd("icons"); -#else - QDir icondir("/usr/share/pixmaps/zeal"); -#endif - icon = QIcon(icondir.filePath(bundleName+".png")); + icon = QIcon(QString("icons:%1.png").arg(bundleName)); // Fallback to identifier and docset file name. if (icon.availableSizes().isEmpty()) { - icon = QIcon(icondir.filePath(identifier+".png")); + icon = QIcon(QString("icons:%1.png").arg(identifier)); } if (icon.availableSizes().isEmpty()) { - icon = QIcon(icondir.filePath(docsetName+".png")); + icon = QIcon(QString("icons:%1.png").arg(docsetName)); } } return icon; diff --git a/zeal/zealsettingsdialog.cpp b/zeal/zealsettingsdialog.cpp index ba1d3baa9..8cce8b51e 100644 --- a/zeal/zealsettingsdialog.cpp +++ b/zeal/zealsettingsdialog.cpp @@ -280,13 +280,7 @@ void ZealSettingsDialog::downloadDocsetList() auto url_list = url.split("/"); auto iconfile = url_list[url_list.count()-1].replace(".tgz", ".png"); iconfile = iconfile.replace(".tar.bz2", ".png"); -#ifdef WIN32 - QDir icondir(QCoreApplication::applicationDirPath()); - icondir.cd("icons"); -#else - QDir icondir("/usr/share/pixmaps/zeal"); -#endif - auto *lwi = new QListWidgetItem(QIcon(icondir.filePath(iconfile)), name); + auto *lwi = new QListWidgetItem(QIcon(QString("icons:") + iconfile), name); lwi->setCheckState(Qt::Unchecked); if(docsets->names().contains(name)){