50 lines
1.6 KiB
QML
50 lines
1.6 KiB
QML
// A choice with more options, or wider labels, than a segmented control can
|
|
// carry: collapsed to its current value, expanding to the list.
|
|
//
|
|
// ChoiceRow puts every option on one line, which works for two or three short
|
|
// ones and falls apart at four with sentences under them -- and on this page
|
|
// two cards sit side by side, so a row has half the width it used to.
|
|
//
|
|
// Not schema-bound. Some of these choices are Panama settings and some are
|
|
// display state that has to go through a keep-or-revert transaction, so the
|
|
// caller says what to do with the value rather than this writing it.
|
|
|
|
import QtQuick
|
|
import qs.config
|
|
|
|
PickerRow {
|
|
id: root
|
|
|
|
// [{ value, label, detail }]
|
|
property var options: []
|
|
property var current: null
|
|
|
|
signal picked(var value)
|
|
|
|
readonly property var currentOption:
|
|
root.options.find(option => option.value === root.current) ?? null
|
|
|
|
value: root.currentOption ? String(root.currentOption.label ?? "") : ""
|
|
|
|
Repeater {
|
|
model: root.options
|
|
|
|
TextRow {
|
|
required property var modelData
|
|
required property int index
|
|
|
|
width: parent.width
|
|
label: String(modelData.label ?? "")
|
|
detail: String(modelData.detail ?? "")
|
|
value: modelData.value === root.current ? "Current" : ""
|
|
controlWidth: 90
|
|
divider: index < root.options.length - 1
|
|
activatable: modelData.value !== root.current
|
|
onActivated: {
|
|
root.picked(modelData.value);
|
|
root.collapse();
|
|
}
|
|
}
|
|
}
|
|
}
|