From 53221fd43f9e3e6f3a3dc96e7f51c645552fe6b7 Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Sun, 23 Jun 2024 21:50:02 +0300 Subject: [PATCH] utils: Allow specifying XCursor theme search paths --- src/utils/xcursortheme.cpp | 12 ++++++------ src/utils/xcursortheme.h | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/utils/xcursortheme.cpp b/src/utils/xcursortheme.cpp index e30df30484..fb129271bf 100644 --- a/src/utils/xcursortheme.cpp +++ b/src/utils/xcursortheme.cpp @@ -34,7 +34,7 @@ public: KXcursorThemePrivate(); KXcursorThemePrivate(const QString &themeName, int size, qreal devicePixelRatio); - void load(); + void load(const QStringList &searchPaths); void loadCursors(const QString &packagePath); QString name; @@ -175,7 +175,7 @@ void KXcursorThemePrivate::loadCursors(const QString &packagePath) } } -static QStringList searchPaths() +static QStringList defaultSearchPaths() { static QStringList paths; if (paths.isEmpty()) { @@ -195,9 +195,9 @@ static QStringList searchPaths() return paths; } -void KXcursorThemePrivate::load() +void KXcursorThemePrivate::load(const QStringList &searchPaths) { - const QStringList paths = searchPaths(); + const QStringList paths = !searchPaths.isEmpty() ? searchPaths : defaultSearchPaths(); QStack stack; QSet loaded; @@ -236,10 +236,10 @@ KXcursorTheme::KXcursorTheme() { } -KXcursorTheme::KXcursorTheme(const QString &themeName, int size, qreal devicePixelRatio) +KXcursorTheme::KXcursorTheme(const QString &themeName, int size, qreal devicePixelRatio, const QStringList &searchPaths) : d(new KXcursorThemePrivate(themeName, size, devicePixelRatio)) { - d->load(); + d->load(searchPaths); } KXcursorTheme::KXcursorTheme(const KXcursorTheme &other) diff --git a/src/utils/xcursortheme.h b/src/utils/xcursortheme.h index 9dbffd9a6c..f5601fdd2c 100644 --- a/src/utils/xcursortheme.h +++ b/src/utils/xcursortheme.h @@ -88,8 +88,10 @@ public: * Loads the Xcursor theme with the given @ themeName and the desired @a size. * The @a dpr specifies the desired scale factor. If no theme with the provided * name exists, the cursor theme will be empty. + * + * @a searchPaths specifies where the cursor theme should be looked for. */ - KXcursorTheme(const QString &theme, int size, qreal devicePixelRatio); + KXcursorTheme(const QString &theme, int size, qreal devicePixelRatio, const QStringList &searchPaths = QStringList()); /** * Constructs a copy of the KXcursorTheme object @a other.