From a0cc31ff581fb33c679b2016d2d00d4d86cb7031 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 24 May 2025 16:31:23 +0800 Subject: refactor: path utils --- config/Appearance.qml | 2 -- modules/dashboard/dash/User.qml | 3 +-- services/Colours.qml | 6 +++--- services/Thumbnailer.qml | 4 ++-- services/Wallpapers.qml | 6 +++--- utils/Paths.qml | 15 +++++++++++++++ 6 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 utils/Paths.qml diff --git a/config/Appearance.qml b/config/Appearance.qml index 24f98cf..633f273 100644 --- a/config/Appearance.qml +++ b/config/Appearance.qml @@ -1,9 +1,7 @@ pragma Singleton import Quickshell -import Quickshell.Io import QtQuick -import Qt.labs.platform Singleton { id: root diff --git a/modules/dashboard/dash/User.qml b/modules/dashboard/dash/User.qml index 700216f..a36536f 100644 --- a/modules/dashboard/dash/User.qml +++ b/modules/dashboard/dash/User.qml @@ -6,7 +6,6 @@ import Quickshell import Quickshell.Io import Quickshell.Widgets import QtQuick -import Qt.labs.platform Row { id: root @@ -31,7 +30,7 @@ Row { CachingImage { anchors.fill: parent - path: `${StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]}/.face` + path: `${Paths.home}/.face` } Behavior on color { diff --git a/services/Colours.qml b/services/Colours.qml index 07e2345..8b6ce00 100644 --- a/services/Colours.qml +++ b/services/Colours.qml @@ -1,10 +1,10 @@ pragma Singleton import "root:/config" +import "root:/utils" import Quickshell import Quickshell.Io import QtQuick -import Qt.labs.platform Singleton { id: root @@ -54,14 +54,14 @@ Singleton { } FileView { - path: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/scheme/current-mode.txt` + path: `${Paths.state}/scheme/current-mode.txt` watchChanges: true onFileChanged: reload() onLoaded: root.light = text() === "light" } FileView { - path: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/scheme/current.txt` + path: `${Paths.state}/scheme/current.txt` watchChanges: true onFileChanged: reload() onLoaded: root.load(text(), false) diff --git a/services/Thumbnailer.qml b/services/Thumbnailer.qml index 3d7a6c1..6a6066c 100644 --- a/services/Thumbnailer.qml +++ b/services/Thumbnailer.qml @@ -1,15 +1,15 @@ pragma Singleton pragma ComponentBehavior: Bound +import "root:/utils" import Quickshell import Quickshell.Io import QtQuick -import Qt.labs.platform Singleton { id: root - readonly property string thumbDir: `${StandardPaths.standardLocations(StandardPaths.GenericCacheLocation)[0]}/caelestia/thumbnails`.slice(7) + readonly property string thumbDir: `${Paths.cache}/thumbnails`.slice(7) function go(obj: var): var { return thumbComp.createObject(obj, { diff --git a/services/Wallpapers.qml b/services/Wallpapers.qml index 4bfa72f..1de5227 100644 --- a/services/Wallpapers.qml +++ b/services/Wallpapers.qml @@ -1,16 +1,16 @@ pragma Singleton import "root:/utils/scripts/fuzzysort.js" as Fuzzy +import "root:/utils" import Quickshell import Quickshell.Io import QtQuick -import Qt.labs.platform Singleton { id: root - readonly property string currentNamePath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7) - readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7) + readonly property string currentNamePath: `${Paths.state}/wallpaper/last.txt`.slice(7) + readonly property string path: `${Paths.pictures}/Wallpapers`.slice(7) readonly property list list: wallpapers.instances property bool showPreview: false diff --git a/utils/Paths.qml b/utils/Paths.qml new file mode 100644 index 0000000..011bb1f --- /dev/null +++ b/utils/Paths.qml @@ -0,0 +1,15 @@ +pragma Singleton + +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 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` +} -- cgit v1.2.3-freya