fix: icon theme search path
This commit is contained in:
guorongfei 2024-01-08 20:17:39 +08:00 committed by xibowen
parent 6c1baa39e7
commit fb43970942
2 changed files with 17 additions and 2 deletions

View File

@ -238,8 +238,7 @@ QVariant Qt5UKUIPlatformTheme::themeHint(ThemeHint hint) const
case QPlatformTheme::SystemIconFallbackThemeName:
return "hicolor";
case QPlatformTheme::IconThemeSearchPaths:
//FIXME:
return QStringList()<<".local/share/icons"<<"/usr/share/icons"<<"/usr/local/share/icons";
return xdgIconThemePaths();
// case WheelScrollLines:
// {
// return QVariant(1);
@ -250,6 +249,19 @@ QVariant Qt5UKUIPlatformTheme::themeHint(ThemeHint hint) const
return QPlatformTheme::themeHint(hint);
}
QStringList Qt5UKUIPlatformTheme::xdgIconThemePaths() const {
QStringList paths;
// Add home directory first in search path
const QFileInfo homeIconDir(QDir::homePath() + QLatin1String("/.icons"));
if (homeIconDir.isDir())
paths.prepend(homeIconDir.absoluteFilePath());
paths.append(QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
QStringLiteral("icons"),
QStandardPaths::LocateDirectory));
return paths;
}
QIconEngine *Qt5UKUIPlatformTheme::createIconEngine(const QString &iconName) const
{
// QPluginLoader l(XDG_ICON_ENGINE_PATH);

View File

@ -89,6 +89,9 @@ public:
public Q_SLOTS:
void slotChangeStyle(const QString& key);
private:
QStringList xdgIconThemePaths() const;
private:
QFont m_system_font;
QFont m_fixed_font;