mirror of
https://github.com/belsabbagh/dotfiles.git
synced 2026-04-11 09:36:46 +00:00
37 lines
1.2 KiB
QML
37 lines
1.2 KiB
QML
import qs.config
|
|
import Quickshell
|
|
import QtQuick
|
|
import QtQuick.Layouts
|
|
|
|
RowLayout {
|
|
id: main
|
|
property string title: "Title"
|
|
property string description: "Description"
|
|
property string prefField: ''
|
|
|
|
ColumnLayout {
|
|
StyledText { text: main.title; font.pixelSize: Metrics.fontSize(16); }
|
|
StyledText { text: main.description; font.pixelSize: Metrics.fontSize(12); }
|
|
}
|
|
Item { Layout.fillWidth: true }
|
|
|
|
StyledSwitch {
|
|
// Safely resolve nested key (e.g. "background.showClock" or "bar.modules.some.setting")
|
|
checked: {
|
|
if (!main.prefField) return false;
|
|
var parts = main.prefField.split('.');
|
|
var cur = Config.runtime;
|
|
for (var i = 0; i < parts.length; ++i) {
|
|
if (cur === undefined || cur === null) return false;
|
|
cur = cur[parts[i]];
|
|
}
|
|
// If the config value is undefined, default to false
|
|
return cur === undefined || cur === null ? false : cur;
|
|
}
|
|
|
|
onToggled: {
|
|
// Persist change (updateKey will create missing objects)
|
|
Config.updateKey(main.prefField, checked);
|
|
}
|
|
}
|
|
} |