mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
80 lines
2.3 KiB
QML
80 lines
2.3 KiB
QML
pragma Singleton
|
|
pragma ComponentBehavior: Bound
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
|
|
Singleton {
|
|
id: root
|
|
property alias states: persistentStatesJsonAdapter
|
|
property string fileDir: Directories.state
|
|
property string fileName: "states.json"
|
|
property string filePath: `${root.fileDir}/${root.fileName}`
|
|
|
|
Timer {
|
|
id: fileReloadTimer
|
|
interval: 100
|
|
repeat: false
|
|
onTriggered: {
|
|
persistentStatesFileView.reload()
|
|
}
|
|
}
|
|
|
|
Timer {
|
|
id: fileWriteTimer
|
|
interval: 100
|
|
repeat: false
|
|
onTriggered: {
|
|
persistentStatesFileView.writeAdapter()
|
|
}
|
|
}
|
|
|
|
FileView {
|
|
id: persistentStatesFileView
|
|
path: root.filePath
|
|
|
|
watchChanges: true
|
|
onFileChanged: fileReloadTimer.restart()
|
|
onAdapterUpdated: fileWriteTimer.restart()
|
|
onLoadFailed: error => {
|
|
console.log("Failed to load persistent states file:", error);
|
|
if (error == FileViewError.FileNotFound) {
|
|
fileWriteTimer.restart();
|
|
}
|
|
}
|
|
|
|
adapter: JsonAdapter {
|
|
id: persistentStatesJsonAdapter
|
|
property JsonObject ai: JsonObject {
|
|
property string model
|
|
property real temperature: 0.5
|
|
}
|
|
|
|
property JsonObject sidebar: JsonObject {
|
|
property JsonObject bottomGroup: JsonObject {
|
|
property bool collapsed: false
|
|
property int tab: 0
|
|
}
|
|
}
|
|
|
|
property JsonObject booru: JsonObject {
|
|
property bool allowNsfw: false
|
|
property string provider: "yandere"
|
|
}
|
|
|
|
property JsonObject timer: JsonObject {
|
|
property JsonObject pomodoro: JsonObject {
|
|
property bool running: false
|
|
property int start: 0
|
|
property bool isBreak: false
|
|
property int cycle: 0
|
|
}
|
|
property JsonObject stopwatch: JsonObject {
|
|
property bool running: false
|
|
property int start: 0
|
|
property list<var> laps: []
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|