paths: decode urls

Fixes spaces in paths breaking things
This commit is contained in:
2 * r + 2 * t 2025-07-07 17:58:18 +10:00
parent 3221ca1858
commit 8a6679eace
7 changed files with 17 additions and 11 deletions

View file

@ -19,7 +19,7 @@ Singleton {
property alias paths: adapter.paths property alias paths: adapter.paths
FileView { FileView {
path: `${Paths.config}/shell.json` path: `${Paths.stringify(Paths.config)}/shell.json`
watchChanges: true watchChanges: true
onFileChanged: reload() onFileChanged: reload()
onAdapterUpdated: writeAdapter() onAdapterUpdated: writeAdapter()

View file

@ -3,6 +3,7 @@ pragma ComponentBehavior: Bound
import "root:/widgets" import "root:/widgets"
import "root:/services" import "root:/services"
import "root:/config" import "root:/config"
import "root:/utils"
import QtQuick import QtQuick
import QtQuick.Dialogs import QtQuick.Dialogs
@ -63,9 +64,10 @@ Item {
FileDialog { FileDialog {
id: dialog id: dialog
title: qsTr("Select a wallpaper")
acceptLabel: qsTr("Select")
nameFilters: [`Image files (${Wallpapers.extensions.map(e => `*.${e}`).join(" ")})`] nameFilters: [`Image files (${Wallpapers.extensions.map(e => `*.${e}`).join(" ")})`]
onAccepted: Wallpapers.setWallpaper(Paths.strip(selectedFile))
onAccepted: Wallpapers.setWallpaper(selectedFile.toString().replace("file://", ""))
} }
StateLayer { StateLayer {

View file

@ -36,7 +36,7 @@ Row {
id: pfp id: pfp
anchors.fill: parent anchors.fill: parent
path: `${Paths.home}/.face` path: `${Paths.stringify(Paths.home)}/.face`
} }
MouseArea { MouseArea {

View file

@ -43,7 +43,7 @@ ColumnLayout {
CachingImage { CachingImage {
anchors.fill: parent anchors.fill: parent
path: `${Paths.home}/.face` path: `${Paths.stringify(Paths.home)}/.face`
} }
} }

View file

@ -58,7 +58,7 @@ Singleton {
} }
FileView { FileView {
path: `${Paths.state}/scheme.json` path: `${Paths.stringify(Paths.state)}/scheme.json`
watchChanges: true watchChanges: true
onFileChanged: reload() onFileChanged: reload()
onLoaded: root.load(text(), false) onLoaded: root.load(text(), false)

View file

@ -16,16 +16,20 @@ Singleton {
readonly property url imagecache: `${cache}/imagecache` readonly property url imagecache: `${cache}/imagecache`
function stringify(path: url): string {
return path.toString().replace(/%20/g, " ");
}
function expandTilde(path: string): string { function expandTilde(path: string): string {
return strip(path.replace("~", root.home.toString())); return strip(path.replace("~", stringify(root.home)));
} }
function shortenHome(path: string): string { function shortenHome(path: string): string {
return path.replace(strip(root.home.toString()), "~"); return path.replace(strip(root.home), "~");
} }
function strip(path: url): string { function strip(path: url): string {
return path.toString().replace("file://", ""); return stringify(path).replace("file://", "");
} }
function mkdir(path: url): void { function mkdir(path: url): void {

View file

@ -8,7 +8,7 @@ Image {
property string path property string path
property string hash property string hash
readonly property string cachePath: `${Paths.imagecache}/${hash}@${width}x${height}.png`.slice(7) readonly property string cachePath: `${Paths.stringify(Paths.imagecache)}/${hash}@${width}x${height}.png`.slice(7)
asynchronous: true asynchronous: true
cache: false cache: false
@ -16,7 +16,7 @@ Image {
sourceSize.width: width sourceSize.width: width
sourceSize.height: height sourceSize.height: height
onPathChanged: shaProc.exec(["sha256sum", path.replace("file://", "")]) onPathChanged: shaProc.exec(["sha256sum", Paths.strip(path)])
onCachePathChanged: { onCachePathChanged: {
if (hash) if (hash)