fix: icon theme search path
This commit is contained in:
guorongfei 2024-01-08 20:17:39 +08:00 committed by openkylin-cibot
parent 380a960bb5
commit 316093e5d1
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,59 @@
From: guorongfei <guorongfei@cvte.com>
Date: Mon, 8 Jan 2024 20:17:39 +0800
Subject: fixed a0625c7 from
https://gitee.com/yangxibowen/qt5-ukui-platformtheme/pulls/87 fix: icon
theme search path
---
qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp | 16 ++++++++++++++--
qt5-ukui-platformtheme/qt5-ukui-platform-theme.h | 3 +++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp
index f70e313..5f4e69a 100644
--- a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp
+++ b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.cpp
@@ -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);
diff --git a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h
index a1b4cbe..086271c 100644
--- a/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h
+++ b/qt5-ukui-platformtheme/qt5-ukui-platform-theme.h
@@ -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;

View File

@ -21,3 +21,4 @@
0021-Update-changelog-4.1.0.0-0k23.patch
0022-Add-rounded-corners-for-tabbar-hover-state.patch
0023-Refresh-update-changelog-4.1.0.0-0k24.patch
0024-fixed-a0625c7-from-https-gitee.com-yangxibowen-qt5-u.patch