121 lines
5.0 KiB
QML
121 lines
5.0 KiB
QML
pragma Singleton
|
|
|
|
// User choices that Panama Settings may change at runtime. This is deliberately
|
|
// separate from Settings.qml: the latter remains the stable public surface used
|
|
// by the shell, while this object owns durable mutation and shipped defaults.
|
|
|
|
import Quickshell
|
|
import Quickshell.Io
|
|
import QtQuick
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property alias use24Hour: values.use24Hour
|
|
property alias showSeconds: values.showSeconds
|
|
property alias showWeekday: values.showWeekday
|
|
property alias showCpu: values.showCpu
|
|
property alias showMemory: values.showMemory
|
|
property alias showGpu: values.showGpu
|
|
property alias dockAutohide: values.dockAutohide
|
|
property alias dockRevealDelayMs: values.dockRevealDelayMs
|
|
property alias dockHideDelayMs: values.dockHideDelayMs
|
|
property alias focusDurationMinutes: values.focusDurationMinutes
|
|
property alias autoHdr: values.autoHdr
|
|
property alias vrrPolicy: values.vrrPolicy
|
|
property alias directScanoutPolicy: values.directScanoutPolicy
|
|
property alias nightLightEnabled: values.nightLightEnabled
|
|
property alias nightLightAutomatic: values.nightLightAutomatic
|
|
property alias nightLightTemperature: values.nightLightTemperature
|
|
property alias lastPage: values.lastPage
|
|
|
|
FileView {
|
|
id: preferencesFile
|
|
|
|
path: Quickshell.stateDir + "/panama-settings.json"
|
|
blockLoading: true
|
|
printErrors: false
|
|
atomicWrites: true
|
|
|
|
JsonAdapter {
|
|
id: values
|
|
|
|
property bool use24Hour: false
|
|
property bool showSeconds: true
|
|
property bool showWeekday: true
|
|
property bool showCpu: true
|
|
property bool showMemory: true
|
|
property bool showGpu: true
|
|
property bool dockAutohide: true
|
|
property int dockRevealDelayMs: 0
|
|
property int dockHideDelayMs: 250
|
|
property int focusDurationMinutes: 45
|
|
property bool autoHdr: true
|
|
property int vrrPolicy: 3
|
|
property int directScanoutPolicy: 2
|
|
property bool nightLightEnabled: false
|
|
property bool nightLightAutomatic: false
|
|
property int nightLightTemperature: 3500
|
|
property string lastPage: "home"
|
|
}
|
|
}
|
|
|
|
// Listen after the adapter has been constructed instead of writing from
|
|
// FileView.onAdapterUpdated. The latter also fires for default-property
|
|
// initialization, which can overwrite a valid file before it is loaded.
|
|
Connections {
|
|
target: values
|
|
function onUse24HourChanged(): void { persistTimer.restart(); }
|
|
function onShowSecondsChanged(): void { persistTimer.restart(); }
|
|
function onShowWeekdayChanged(): void { persistTimer.restart(); }
|
|
function onShowCpuChanged(): void { persistTimer.restart(); }
|
|
function onShowMemoryChanged(): void { persistTimer.restart(); }
|
|
function onShowGpuChanged(): void { persistTimer.restart(); }
|
|
function onDockAutohideChanged(): void { persistTimer.restart(); }
|
|
function onDockRevealDelayMsChanged(): void { persistTimer.restart(); }
|
|
function onDockHideDelayMsChanged(): void { persistTimer.restart(); }
|
|
function onFocusDurationMinutesChanged(): void { persistTimer.restart(); }
|
|
function onAutoHdrChanged(): void { persistTimer.restart(); }
|
|
function onVrrPolicyChanged(): void { persistTimer.restart(); }
|
|
function onDirectScanoutPolicyChanged(): void { persistTimer.restart(); }
|
|
function onNightLightEnabledChanged(): void { persistTimer.restart(); }
|
|
function onNightLightAutomaticChanged(): void { persistTimer.restart(); }
|
|
function onNightLightTemperatureChanged(): void { persistTimer.restart(); }
|
|
function onLastPageChanged(): void { persistTimer.restart(); }
|
|
}
|
|
|
|
// Singleton construction can happen after FileView's preload phase when a
|
|
// test or a lazy page first references it. An explicit reload makes the
|
|
// durable state authoritative in that case as well as in the main shell.
|
|
Component.onCompleted: preferencesFile.reload()
|
|
|
|
// Coalesce a group of UI changes into one atomic write. Writing from the
|
|
// adapter's change signal itself can race a second property assignment and
|
|
// reload the older value before the batch has finished.
|
|
Timer {
|
|
id: persistTimer
|
|
interval: 0
|
|
onTriggered: preferencesFile.writeAdapter()
|
|
}
|
|
|
|
function resetDesktopDefaults(): void {
|
|
values.use24Hour = false;
|
|
values.showSeconds = true;
|
|
values.showWeekday = true;
|
|
values.showCpu = true;
|
|
values.showMemory = true;
|
|
values.showGpu = true;
|
|
values.dockAutohide = true;
|
|
values.dockRevealDelayMs = 0;
|
|
values.dockHideDelayMs = 250;
|
|
values.focusDurationMinutes = 45;
|
|
values.autoHdr = true;
|
|
values.vrrPolicy = 3;
|
|
values.directScanoutPolicy = 2;
|
|
values.nightLightEnabled = false;
|
|
values.nightLightAutomatic = false;
|
|
values.nightLightTemperature = 3500;
|
|
values.lastPage = "home";
|
|
}
|
|
}
|