refactor: path utils

This commit is contained in:
2 * r + 2 * t 2025-05-24 16:31:23 +08:00
parent cb3444a266
commit a0cc31ff58
6 changed files with 24 additions and 12 deletions

View file

@ -1,9 +1,7 @@
pragma Singleton pragma Singleton
import Quickshell import Quickshell
import Quickshell.Io
import QtQuick import QtQuick
import Qt.labs.platform
Singleton { Singleton {
id: root id: root

View file

@ -6,7 +6,6 @@ import Quickshell
import Quickshell.Io import Quickshell.Io
import Quickshell.Widgets import Quickshell.Widgets
import QtQuick import QtQuick
import Qt.labs.platform
Row { Row {
id: root id: root
@ -31,7 +30,7 @@ Row {
CachingImage { CachingImage {
anchors.fill: parent anchors.fill: parent
path: `${StandardPaths.standardLocations(StandardPaths.HomeLocation)[0]}/.face` path: `${Paths.home}/.face`
} }
Behavior on color { Behavior on color {

View file

@ -1,10 +1,10 @@
pragma Singleton pragma Singleton
import "root:/config" import "root:/config"
import "root:/utils"
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import QtQuick import QtQuick
import Qt.labs.platform
Singleton { Singleton {
id: root id: root
@ -54,14 +54,14 @@ Singleton {
} }
FileView { FileView {
path: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/scheme/current-mode.txt` path: `${Paths.state}/scheme/current-mode.txt`
watchChanges: true watchChanges: true
onFileChanged: reload() onFileChanged: reload()
onLoaded: root.light = text() === "light" onLoaded: root.light = text() === "light"
} }
FileView { FileView {
path: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/scheme/current.txt` path: `${Paths.state}/scheme/current.txt`
watchChanges: true watchChanges: true
onFileChanged: reload() onFileChanged: reload()
onLoaded: root.load(text(), false) onLoaded: root.load(text(), false)

View file

@ -1,15 +1,15 @@
pragma Singleton pragma Singleton
pragma ComponentBehavior: Bound pragma ComponentBehavior: Bound
import "root:/utils"
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import QtQuick import QtQuick
import Qt.labs.platform
Singleton { Singleton {
id: root 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 { function go(obj: var): var {
return thumbComp.createObject(obj, { return thumbComp.createObject(obj, {

View file

@ -1,16 +1,16 @@
pragma Singleton pragma Singleton
import "root:/utils/scripts/fuzzysort.js" as Fuzzy import "root:/utils/scripts/fuzzysort.js" as Fuzzy
import "root:/utils"
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import QtQuick import QtQuick
import Qt.labs.platform
Singleton { Singleton {
id: root id: root
readonly property string currentNamePath: `${StandardPaths.standardLocations(StandardPaths.GenericStateLocation)[0]}/caelestia/wallpaper/last.txt`.slice(7) readonly property string currentNamePath: `${Paths.state}/wallpaper/last.txt`.slice(7)
readonly property string path: `${StandardPaths.standardLocations(StandardPaths.PicturesLocation)[0]}/Wallpapers`.slice(7) readonly property string path: `${Paths.pictures}/Wallpapers`.slice(7)
readonly property list<Wallpaper> list: wallpapers.instances readonly property list<Wallpaper> list: wallpapers.instances
property bool showPreview: false property bool showPreview: false

15
utils/Paths.qml Normal file
View file

@ -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`
}