Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
49 lines
2.0 KiB
QML
49 lines
2.0 KiB
QML
pragma Singleton
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import "ConfigLogic.js" as Logic
|
|
Singleton {
|
|
id: root
|
|
readonly property string directory: (Quickshell.env("XDG_CONFIG_HOME") || Quickshell.env("HOME") + "/.config") + "/glassMxrph"
|
|
property var data: ({})
|
|
property var defaults: ({})
|
|
property bool ready: false
|
|
property string error: ""
|
|
property bool writable: false
|
|
function value(path) { return path.split(".").reduce((object,key)=>object ? object[key] : undefined,data); }
|
|
function setValue(path, value) {
|
|
if (!ready || !writable) return false;
|
|
try { data = Logic.update(data, path, value); error=""; saveTimer.restart(); return true; }
|
|
catch (e) { error = String(e); return false; }
|
|
}
|
|
function readUser() {
|
|
try { data = Logic.load(defaults, JSON.parse(userFile.text())); error = ""; writable = true; }
|
|
catch (e) { error = "Configuration preserved: " + e; writable = false; }
|
|
ready = true;
|
|
}
|
|
FileView {
|
|
id: defaultsFile
|
|
path: Qt.resolvedUrl("../config/defaults.json").toString().replace("file://", "")
|
|
onLoaded: {
|
|
root.defaults = JSON.parse(text()); root.data = root.defaults;
|
|
userFile.path = root.directory + "/config.json";
|
|
}
|
|
}
|
|
FileView {
|
|
id: userFile
|
|
printErrors: false
|
|
atomicWrites: true
|
|
watchChanges: true
|
|
onLoaded: root.readUser()
|
|
onFileChanged: { saveTimer.stop(); reload(); }
|
|
onLoadFailed: error => {
|
|
root.ready = true;
|
|
if (error === FileViewError.FileNotFound) { root.writable = true; }
|
|
else { root.error = "Could not read configuration (" + error + ")"; root.writable = false; }
|
|
}
|
|
onSaveFailed: error => { root.error = "Could not save configuration (" + error + ")"; }
|
|
}
|
|
Timer { id: saveTimer; interval: 250; onTriggered: userFile.setText(JSON.stringify(root.data, null, 2) + "\n") }
|
|
}
|