[plasma/union] src: Add a method to PlatformPlugin to get the style package paths

Arjen Hiemstra <[email protected]> Wed, 5 Aug 2026 10:33:23 +0000 (UTC)
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ae55efa5f8080a129f5282f300dbd099316f78ca by Arjen Hiemstra.
Committed on 05/08/2026 at 10:24.
Pushed by ahiemstra into branch 'master'.

Add a method to PlatformPlugin to get the style package paths

This returns a list of paths where style packages can be installed. It
can be overriden if the platform needs to do something different.

M  +11   -0    src/PlatformPlugin.cpp
M  +8    -0    src/PlatformPlugin.h

https://invent.kde.org/plasma/union/-/commit/ae55efa5f8080a129f5282f300dbd099316f78ca

diff --git a/src/PlatformPlugin.cpp b/src/PlatformPlugin.cpp
index 506fcc62..2e3bf882 100644
--- a/src/PlatformPlugin.cpp
+++ b/src/PlatformPlugin.cpp
@@ -4,6 +4,7 @@
 #include "PlatformPlugin.h"
 
 #include <QIcon>
+#include <QStandardPaths>
 
 using namespace Union;
 using namespace Qt::StringLiterals;
@@ -18,6 +19,16 @@ QString PlatformPlugin::defaultInputPlugin()
     return QString{};
 }
 
+QList<std::filesystem::path> Union::PlatformPlugin::stylePackagePaths()
+{
+    const auto paths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, u"union/styles"_s, QStandardPaths::LocateDirectory);
+    QList<std::filesystem::path> result;
+    std::ranges::transform(paths, std::back_inserter(result), [](const QString &path) {
+        return std::filesystem::path(path.toStdString());
+    });
+    return result;
+}
+
 QIcon PlatformPlugin::platformIcon(const QString &name, [[maybe_unused]] const QColor &color)
 {
     return QIcon::fromTheme(name);
diff --git a/src/PlatformPlugin.h b/src/PlatformPlugin.h
index 36581adb..6429c72a 100644
--- a/src/PlatformPlugin.h
+++ b/src/PlatformPlugin.h
@@ -37,6 +37,14 @@ public:
      * Returns the platform's default style name.
      */
     virtual QString defaultStyleName() = 0;
+    /*!
+     * Returns the list of directories that should be searched for style packages.
+     *
+     * By default this will use QStandardPaths and search for the directory
+     * "union/styles" in GenericDataLocation. However, this can be overridden
+     * should the platform have a location that is not handled by QStandardPaths.
+     */
+    virtual QList<std::filesystem::path> stylePackagePaths();
     /*!
      * Returns an icon from the platform.
      *