// A boolean setting, bound to a schema key by name. // // ToggleRow { setting: "blurEnabled" } // // Label, explanation, and validation all come from PreferenceSchema, so a row // cannot drift from the setting it edits, and the writing side does not care // whether the key is stored locally or applied to the compositor first. // Override `label` or `detail` only when a page needs different wording than // the schema's default. import QtQuick import qs.config import qs.services SettingRow { id: root required property string setting readonly property var spec: PreferenceSchema.spec(root.setting) readonly property bool checked: DesktopPreferences.get(root.setting) === true label: root.spec ? root.spec.label : root.setting detail: root.spec ? root.spec.detail : "" controlWidth: 48 // Space and Enter write the same value the pointer would, through the same // verified path -- there is no second way to flip a preference here. function flip(): void { SystemSettings.commitPreference(root.setting, !root.checked); } SettingsToggle { id: toggle anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter checked: root.checked onToggled: value => SystemSettings.commitPreference(root.setting, value) activeFocusOnTab: true Accessible.role: Accessible.CheckBox Accessible.name: root.label Accessible.description: root.detail Accessible.checked: root.checked Accessible.focusable: true Accessible.focused: toggle.activeFocus Accessible.onPressAction: root.flip() Keys.onReturnPressed: root.flip() Keys.onEnterPressed: root.flip() Keys.onSpacePressed: root.flip() // Focus ring only -- the switch keeps its own border at rest. Rectangle { anchors.fill: parent anchors.margins: -3 radius: height / 2 color: "transparent" visible: toggle.activeFocus border.width: 2 border.color: Theme.accentSecondary } } }