added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,44 @@
|
||||
pragma Singleton
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import "WallpaperPolicy.js" as Policy
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
property var states: ({})
|
||||
property string error: ""
|
||||
Connections {
|
||||
target: Quickshell
|
||||
function onScreensChanged() {
|
||||
const names = Quickshell.screens.map(s => s.name);
|
||||
Object.keys(root.states).filter(name => !names.includes(name)).forEach(name => root.forget(name));
|
||||
}
|
||||
}
|
||||
function sourceFor(output) { return Policy.sourceFor(Preferences.data.wallpapers, output); }
|
||||
function set(output, path) {
|
||||
if (!Preferences.writable) { error = Preferences.error || "Настройки пока недоступны"; return false; }
|
||||
try {
|
||||
const next = Object.assign({}, Preferences.data.wallpapers || {});
|
||||
next[output] = Policy.localUrl(path);
|
||||
Policy.validate(next);
|
||||
Preferences.setValue("wallpapers", next);
|
||||
error = "";
|
||||
return true;
|
||||
} catch (e) { error = String(e); return false; }
|
||||
}
|
||||
function inherit(output) {
|
||||
const next = Object.assign({}, Preferences.data.wallpapers || {});
|
||||
delete next[output];
|
||||
Preferences.setValue("wallpapers", next);
|
||||
}
|
||||
function report(output, source, state, displayed) {
|
||||
const next = Object.assign({}, states);
|
||||
next[output] = {source: source, state: state, displayed: displayed};
|
||||
states = next;
|
||||
}
|
||||
function forget(output) {
|
||||
const next = Object.assign({}, states);
|
||||
delete next[output];
|
||||
states = next;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user