// 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

    SettingsToggle {
        anchors.right: parent.right
        anchors.verticalCenter: parent.verticalCenter
        checked: root.checked
        onToggled: value => SystemSettings.commitPreference(root.setting, value)
    }
}
