diff --git a/src/core/DataPath.cpp b/src/core/DataPath.cpp index 214083cd0..2b934bf6b 100644 --- a/src/core/DataPath.cpp +++ b/src/core/DataPath.cpp @@ -29,18 +29,28 @@ QString DataPath::path(const QString& name) QIcon DataPath::applicationIcon() { - QIcon icon = QIcon::fromTheme("keepassx"); + return icon("apps", "keepassx"); +} + +QIcon DataPath::icon(const QString& category, const QString& name) +{ + QIcon icon = QIcon::fromTheme(name); -#if defined(QT_DEBUG) || defined(Q_WS_MAC) || defined(Q_WS_WIN) if (icon.isNull()) { QStringList pngSizes; pngSizes << "16" << "24" << "32" << "48" << "64" << "128"; + QString filename; Q_FOREACH (const QString& size, pngSizes) { - icon.addFile(QString("%1/icons/application/%2x%2/apps/keepassx.png").arg(m_basePath, size)); + filename = QString("%1/icons/application/%2x%2/%3/%4.png").arg(m_basePath, size, category, name); + if (QFile::exists(filename)) { + icon.addFile(filename); + } + } + filename = QString("%1/icons/application/scalable/%3/%4.svgz").arg(m_basePath, category, name); + if (QFile::exists(filename)) { + icon.addFile(filename); } - icon.addFile(QString("%1/icons/application/scalable/apps/keepassx.svgz").arg(m_basePath)); } -#endif return icon; } diff --git a/src/core/DataPath.h b/src/core/DataPath.h index 758cb8bc1..78ca52e7b 100644 --- a/src/core/DataPath.h +++ b/src/core/DataPath.h @@ -26,6 +26,7 @@ class DataPath public: QString path(const QString& name); QIcon applicationIcon(); + QIcon icon(const QString& category, const QString& name); private: DataPath();