diff options
| -rw-r--r-- | components/filedialog/FolderContents.qml | 2 | ||||
| -rw-r--r-- | components/images/CachingIconImage.qml | 2 | ||||
| -rw-r--r-- | components/images/CachingImage.qml | 2 | ||||
| -rw-r--r-- | config/Config.qml | 2 | ||||
| -rw-r--r-- | config/UserPaths.qml | 2 | ||||
| -rw-r--r-- | modules/dashboard/Media.qml | 2 | ||||
| -rw-r--r-- | modules/dashboard/dash/Media.qml | 2 | ||||
| -rw-r--r-- | modules/dashboard/dash/User.qml | 2 | ||||
| -rw-r--r-- | modules/lock/Center.qml | 2 | ||||
| -rw-r--r-- | modules/session/Content.qml | 2 | ||||
| -rw-r--r-- | plugin/src/Caelestia/cutils.cpp | 9 | ||||
| -rw-r--r-- | plugin/src/Caelestia/cutils.hpp | 2 | ||||
| -rw-r--r-- | services/Colours.qml | 2 | ||||
| -rw-r--r-- | services/Wallpapers.qml | 4 | ||||
| -rw-r--r-- | utils/Paths.qml | 38 |
15 files changed, 39 insertions, 36 deletions
diff --git a/components/filedialog/FolderContents.qml b/components/filedialog/FolderContents.qml index 7765a6a..3efa697 100644 --- a/components/filedialog/FolderContents.qml +++ b/components/filedialog/FolderContents.qml @@ -97,7 +97,7 @@ Item { model: FileSystemModel { path: { if (root.dialog.cwd[0] === "Home") - return `${Paths.strip(Paths.home)}/${root.dialog.cwd.slice(1).join("/")}`; + return `${Paths.home}/${root.dialog.cwd.slice(1).join("/")}`; else return root.dialog.cwd.join("/"); } diff --git a/components/images/CachingIconImage.qml b/components/images/CachingIconImage.qml index 715d379..1acc6a1 100644 --- a/components/images/CachingIconImage.qml +++ b/components/images/CachingIconImage.qml @@ -26,7 +26,7 @@ Item { id: cachingImage CachingImage { - path: Paths.strip(root.source) + path: Paths.toLocalFile(root.source) fillMode: Image.PreserveAspectFit } } diff --git a/components/images/CachingImage.qml b/components/images/CachingImage.qml index a8916ae..3511345 100644 --- a/components/images/CachingImage.qml +++ b/components/images/CachingImage.qml @@ -23,6 +23,6 @@ Image { id: manager item: root - cacheDir: Paths.imagecache + cacheDir: Qt.resolvedUrl(Paths.imagecache) } } diff --git a/config/Config.qml b/config/Config.qml index 24fb00b..b5218be 100644 --- a/config/Config.qml +++ b/config/Config.qml @@ -24,7 +24,7 @@ Singleton { property alias paths: adapter.paths FileView { - path: `${Paths.stringify(Paths.config)}/shell.json` + path: `${Paths.config}/shell.json` watchChanges: true onFileChanged: reload() diff --git a/config/UserPaths.qml b/config/UserPaths.qml index 2876d98..f8de267 100644 --- a/config/UserPaths.qml +++ b/config/UserPaths.qml @@ -2,7 +2,7 @@ import qs.utils import Quickshell.Io JsonObject { - property string wallpaperDir: Paths.strip(`${Paths.pictures}/Wallpapers`) + property string wallpaperDir: `${Paths.pictures}/Wallpapers` property string sessionGif: "root:/assets/kurukuru.gif" property string mediaGif: "root:/assets/bongocat.gif" } diff --git a/modules/dashboard/Media.qml b/modules/dashboard/Media.qml index 5817d3e..937e07e 100644 --- a/modules/dashboard/Media.qml +++ b/modules/dashboard/Media.qml @@ -526,7 +526,7 @@ Item { playing: Players.active?.isPlaying ?? false speed: BeatDetector.bpm / 300 - source: Paths.expandTilde(Config.paths.mediaGif) + source: Paths.absolutePath(Config.paths.mediaGif) asynchronous: true fillMode: AnimatedImage.PreserveAspectFit } diff --git a/modules/dashboard/dash/Media.qml b/modules/dashboard/dash/Media.qml index eda44d5..7cb9e3e 100644 --- a/modules/dashboard/dash/Media.qml +++ b/modules/dashboard/dash/Media.qml @@ -209,7 +209,7 @@ Item { playing: Players.active?.isPlaying ?? false speed: BeatDetector.bpm / 300 - source: Paths.expandTilde(Config.paths.mediaGif) + source: Paths.absolutePath(Config.paths.mediaGif) asynchronous: true fillMode: AnimatedImage.PreserveAspectFit } diff --git a/modules/dashboard/dash/User.qml b/modules/dashboard/dash/User.qml index 2576e3e..db12d01 100644 --- a/modules/dashboard/dash/User.qml +++ b/modules/dashboard/dash/User.qml @@ -36,7 +36,7 @@ Row { id: pfp anchors.fill: parent - path: `${Paths.stringify(Paths.home)}/.face` + path: `${Paths.home}/.face` } MouseArea { diff --git a/modules/lock/Center.qml b/modules/lock/Center.qml index b76b7f4..ce5db92 100644 --- a/modules/lock/Center.qml +++ b/modules/lock/Center.qml @@ -105,7 +105,7 @@ ColumnLayout { id: pfp anchors.fill: parent - path: `${Paths.stringify(Paths.home)}/.face` + path: `${Paths.home}/.face` } } diff --git a/modules/session/Content.qml b/modules/session/Content.qml index ca6bf17..41ecb3b 100644 --- a/modules/session/Content.qml +++ b/modules/session/Content.qml @@ -61,7 +61,7 @@ Column { playing: visible asynchronous: true speed: 0.7 - source: Paths.expandTilde(Config.paths.sessionGif) + source: Paths.absolutePath(Config.paths.sessionGif) } SessionButton { diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index 29cf7ce..d64530d 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -337,3 +337,12 @@ qreal CUtils::findAverageLuminance(const QImage& image, int rescaleSize) const { return count == 0 ? 0.0 : totalLuminance / count; } + +QString CUtils::toLocalFile(const QUrl& url) const { + if (!url.isLocalFile()) { + qWarning() << "CUtils::toLocalFile: given url is not a local file" << url; + return QString(); + } + + return url.toLocalFile(); +} diff --git a/plugin/src/Caelestia/cutils.hpp b/plugin/src/Caelestia/cutils.hpp index cac5d7c..42d4418 100644 --- a/plugin/src/Caelestia/cutils.hpp +++ b/plugin/src/Caelestia/cutils.hpp @@ -31,6 +31,8 @@ public: Q_INVOKABLE void getAverageLuminance(const QString& path, QJSValue callback); Q_INVOKABLE void getAverageLuminance(const QString& path, int rescaleSize, QJSValue callback); + Q_INVOKABLE QString toLocalFile(const QUrl& url) const; + private: QColor findDominantColour(const QImage& image, int rescaleSize) const; qreal findAverageLuminance(const QImage& image, int rescaleSize) const; diff --git a/services/Colours.qml b/services/Colours.qml index ca78abc..df0d4b6 100644 --- a/services/Colours.qml +++ b/services/Colours.qml @@ -79,7 +79,7 @@ Singleton { } FileView { - path: `${Paths.stringify(Paths.state)}/scheme.json` + path: `${Paths.state}/scheme.json` watchChanges: true onFileChanged: reload() onLoaded: root.load(text(), false) diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index 39cbfb8..209ce1b 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -10,7 +10,7 @@ import QtQuick Searcher { id: root - readonly property string currentNamePath: Paths.strip(`${Paths.state}/wallpaper/path.txt`) + readonly property string currentNamePath: `${Paths.state}/wallpaper/path.txt` readonly property list<string> smartArg: Config.services.smartScheme ? [] : ["--no-smart"] property bool showPreview: false @@ -74,7 +74,7 @@ Searcher { id: wallpapers recursive: true - path: Paths.expandTilde(Paths.wallsdir) + path: Paths.wallsdir filter: FileSystemModel.Images } diff --git a/utils/Paths.qml b/utils/Paths.qml index 6000486..f0dfa4d 100644 --- a/utils/Paths.qml +++ b/utils/Paths.qml @@ -1,42 +1,34 @@ pragma Singleton import qs.config +import Caelestia import Quickshell -import Qt.labs.platform Singleton { id: root - readonly property url home: StandardPaths.standardLocations(StandardPaths.HomeLocation)[0] - readonly property url pictures: StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0] + readonly property string home: Quickshell.env("HOME") + readonly property string pictures: Quickshell.env("XDG_PICTURES_DIR") || `${home}/Pictures` - readonly property url data: `${StandardPaths.standardLocations(StandardPaths.GenericDataLocation)[0]}/caelestia` - readonly property url state: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia` - readonly property url cache: `${StandardPaths.standardLocations(StandardPaths.GenericCacheLocation)[0]}/caelestia` - readonly property url config: `${StandardPaths.standardLocations(StandardPaths.GenericConfigLocation)[0]}/caelestia` + readonly property string data: `${Quickshell.env("XDG_DATA_HOME") || `${home}/.local/share`}/caelestia` + readonly property string state: `${Quickshell.env("XDG_STATE_HOME") || `${home}/.local/state`}/caelestia` + readonly property string cache: `${Quickshell.env("XDG_CACHE_HOME") || `${home}/.cache`}/caelestia` + readonly property string config: `${Quickshell.env("XDG_CONFIG_HOME") || `${home}/.config`}/caelestia` - readonly property url imagecache: `${cache}/imagecache` - readonly property string wallsdir: Quickshell.env("CAELESTIA_WALLPAPERS_DIR") || Config.paths.wallpaperDir + readonly property string imagecache: `${cache}/imagecache` + readonly property string wallsdir: Quickshell.env("CAELESTIA_WALLPAPERS_DIR") || absolutePath(Config.paths.wallpaperDir) readonly property string libdir: Quickshell.env("CAELESTIA_LIB_DIR") || "/usr/lib/caelestia" - function stringify(path: url): string { - let str = path.toString(); - if (str.startsWith("root:/")) - str = `file://${Quickshell.shellDir}/${str.slice(6)}`; - else if (str.startsWith("/")) - str = `file://${str}`; - return new URL(str).pathname; + function toLocalFile(path: url): string { + path = Qt.resolvedUrl(path); + return path.toString() ? CUtils.toLocalFile(path) : ""; } - function expandTilde(path: string): string { - return strip(path.replace("~", stringify(root.home))); + function absolutePath(path: string): string { + return toLocalFile(path.replace("~", home)); } function shortenHome(path: string): string { - return path.replace(strip(root.home), "~"); - } - - function strip(path: url): string { - return stringify(path).replace("file://", ""); + return path.replace(home, "~"); } } |