From e31ff0aa27e33a3c84d1d745c681e06daca6861c Mon Sep 17 00:00:00 2001 From: inorishio Date: Wed, 11 Feb 2026 12:00:12 +0100 Subject: [PATCH] can't be working on this at work lmao --- Modules/ConfigJson.qml | 66 ++++++++++++++++++++++++++++++++++++++++++ Modules/GifsLoader.qml | 8 ++--- 2 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 Modules/ConfigJson.qml diff --git a/Modules/ConfigJson.qml b/Modules/ConfigJson.qml new file mode 100644 index 0000000..3ab5bba --- /dev/null +++ b/Modules/ConfigJson.qml @@ -0,0 +1,66 @@ +pragma Singleton + +import QtCore +import QtQuick +import Quickshell.Io +import Quickshell + +Singleton { + id: root + + property alias gifFolder: adapter.gifFolder + property alias scaling: adapter.scaling + property alias maxWidth: adapter.maxWidth + property alias maxHeight: adapter.maxHeight + property string configDir: Quickshell.env("HOME") + "/.local/state/I-DeskPet" + property string configPath: configDir + "/name.json" + + signal folderChanged() + + Process { + id: dirCheck + running: true + command: ["test", "-d", root.configDir] + + onExited: function( exitCode ) { + if (exitCode !== 0) { + dirCreate.running = true + } + } + } + + + // name + Component.onCompleted: { + var s = gifItem.modelData.split("/") + console.log(s[s.length - 1].split(".")[0].add(".json")) + } + + Process { + id: dirCreate + running: false + command: ["mkdir", "-p", root.configDir] + + onExited: function(): void { + console.log("Created config directory:", root.configDir) + } + } + + FileView { + id: watcher + path: root.configPath + + watchChanges: true + + onFileChanged: reload() + + JsonAdapter { + id: adapter + + property string gifFolder: Quickshell.shellDir + "/Gifs" + property var scaling: 1 + property int maxWidth: 1000 + property int maxHeight: 1000 + } + } +} diff --git a/Modules/GifsLoader.qml b/Modules/GifsLoader.qml index 30d9330..ef92302 100644 --- a/Modules/GifsLoader.qml +++ b/Modules/GifsLoader.qml @@ -26,18 +26,14 @@ Repeater { x: 0 y: Screen.height - height - width: Math.min( Math.floor( gif.sourceSize.width / ConfigLoader.scaling ), Math.floor( ConfigLoader.maxWidth / ConfigLoader.scaling )) - height: Math.min( Math.floor( gif.sourceSize.height / ConfigLoader.scaling ), Math.floor( ConfigLoader.maxHeight / ConfigLoader.scaling )) + width: ( Math.floor( gif.sourceSize.width / ConfigLoader.scaling ) ? gif.sourceSize.width ) + height: ( Math.floor( gif.sourceSize.height / ConfigLoader.scaling ) ? gif.sourceSize.height ) AnimatedImage { id: gif source: gifItem.modelData fillMode: Image.PreserveAspectFit anchors.fill: parent - Component.onCompleted: { - var s = gifItem.modelData.split("/") - console.log(s[s.length - 1].split(".")[0]) - } } Mouse {}