Stack cog options so they fit narrow lanes
Each option's label sits on its own line (with a toggle or a slider's value and unit), and its dropdown, text field or slider spans the card below it, instead of squeezing fixed-width controls beside the label. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1a394955cf
commit
660fa69be6
1 file changed
+30
-22
@@ -194,26 +194,45 @@ Item {
|
|||||||
id:optionsColumn
|
id:optionsColumn
|
||||||
visible:card.expanded
|
visible:card.expanded
|
||||||
anchors {left:parent.left;right:parent.right;top:parent.top;topMargin:50;leftMargin:12;rightMargin:10}
|
anchors {left:parent.left;right:parent.right;top:parent.top;topMargin:50;leftMargin:12;rightMargin:10}
|
||||||
spacing:6
|
spacing:10
|
||||||
Repeater {
|
Repeater {
|
||||||
model:card.schema
|
model:card.schema
|
||||||
RowLayout {
|
// Label line (with a toggle or a slider's value), then the control at
|
||||||
|
// the card's full width: lanes are narrow, so nothing sits beside a field.
|
||||||
|
ColumnLayout {
|
||||||
id:optionRow
|
id:optionRow
|
||||||
required property var modelData
|
required property var modelData
|
||||||
readonly property var value:root.valueOf(card.modelData,modelData)
|
readonly property var value:root.valueOf(card.modelData,modelData)
|
||||||
|
readonly property string kind:modelData.type
|
||||||
|
readonly property bool numeric:kind==="integer" || kind==="number"
|
||||||
|
Layout.fillWidth:true
|
||||||
|
spacing:3
|
||||||
|
RowLayout {
|
||||||
Layout.fillWidth:true
|
Layout.fillWidth:true
|
||||||
spacing:8
|
spacing:8
|
||||||
Text {text:optionRow.modelData.label;color:Theme.textSecondary;font.pixelSize:11;Layout.fillWidth:true;elide:Text.ElideRight
|
Text {text:optionRow.modelData.label;color:Theme.textSecondary;font.pixelSize:11;Layout.fillWidth:true;wrapMode:Text.Wrap
|
||||||
HoverHandler {id:labelHover}
|
HoverHandler {id:labelHover}
|
||||||
GlassToolTip {
|
GlassToolTip {
|
||||||
visible: labelHover.hovered && !!optionRow.modelData.description
|
visible: labelHover.hovered && !!optionRow.modelData.description
|
||||||
delay: 600
|
delay: 600
|
||||||
text: optionRow.modelData.description || ""
|
text: optionRow.modelData.description || ""
|
||||||
}}
|
}}
|
||||||
|
GlassToggle {
|
||||||
|
visible:optionRow.kind==="boolean"
|
||||||
|
checked:optionRow.value===true
|
||||||
|
onToggled:root.setOption(card.modelData,optionRow.modelData.key,checked)
|
||||||
|
}
|
||||||
|
Text {
|
||||||
|
visible:optionRow.numeric
|
||||||
|
text:optionRow.value===undefined ? "" : String(optionRow.value)+(optionRow.modelData.unit ? " "+optionRow.modelData.unit : "")
|
||||||
|
color:Theme.text;font.pixelSize:11
|
||||||
|
horizontalAlignment:Text.AlignRight
|
||||||
|
}
|
||||||
|
}
|
||||||
GlassComboBox {
|
GlassComboBox {
|
||||||
objectName:"bar-option-"+card.modelData.id+"-"+optionRow.modelData.key
|
objectName:"bar-option-"+card.modelData.id+"-"+optionRow.modelData.key
|
||||||
visible:optionRow.modelData.type==="choice"
|
visible:optionRow.kind==="choice"
|
||||||
Layout.preferredWidth:110
|
Layout.fillWidth:true
|
||||||
implicitHeight:30
|
implicitHeight:30
|
||||||
model:(optionRow.modelData.choices || []).map((c,i)=>({text:optionRow.modelData.choiceLabels ? optionRow.modelData.choiceLabels[i] : String(c).charAt(0).toUpperCase()+String(c).slice(1),value:c}))
|
model:(optionRow.modelData.choices || []).map((c,i)=>({text:optionRow.modelData.choiceLabels ? optionRow.modelData.choiceLabels[i] : String(c).charAt(0).toUpperCase()+String(c).slice(1),value:c}))
|
||||||
textRole:"text"
|
textRole:"text"
|
||||||
@@ -221,30 +240,19 @@ Item {
|
|||||||
currentIndex:(optionRow.modelData.choices || []).indexOf(optionRow.value)
|
currentIndex:(optionRow.modelData.choices || []).indexOf(optionRow.value)
|
||||||
onActivated:root.setOption(card.modelData,optionRow.modelData.key,currentValue)
|
onActivated:root.setOption(card.modelData,optionRow.modelData.key,currentValue)
|
||||||
}
|
}
|
||||||
GlassToggle {
|
|
||||||
visible:optionRow.modelData.type==="boolean"
|
|
||||||
checked:optionRow.value===true
|
|
||||||
onToggled:root.setOption(card.modelData,optionRow.modelData.key,checked)
|
|
||||||
}
|
|
||||||
Text {
|
|
||||||
visible:optionRow.modelData.type==="integer" || optionRow.modelData.type==="number"
|
|
||||||
text:optionRow.value===undefined ? "" : String(optionRow.value)
|
|
||||||
color:Theme.text;font.pixelSize:11
|
|
||||||
Layout.preferredWidth:26;horizontalAlignment:Text.AlignRight
|
|
||||||
}
|
|
||||||
GlassSlider {
|
GlassSlider {
|
||||||
visible:optionRow.modelData.type==="integer" || optionRow.modelData.type==="number"
|
visible:optionRow.numeric
|
||||||
Layout.preferredWidth:90
|
Layout.fillWidth:true
|
||||||
implicitHeight:26
|
implicitHeight:26
|
||||||
from:Number(optionRow.modelData.min !== undefined ? optionRow.modelData.min : 0)
|
from:Number(optionRow.modelData.min !== undefined ? optionRow.modelData.min : 0)
|
||||||
to:Number(optionRow.modelData.max !== undefined ? optionRow.modelData.max : 100)
|
to:Number(optionRow.modelData.max !== undefined ? optionRow.modelData.max : 100)
|
||||||
stepSize:Number(optionRow.modelData.step || (optionRow.modelData.type==="integer" ? 1 : 0.1))
|
stepSize:Number(optionRow.modelData.step || (optionRow.kind==="integer" ? 1 : 0.1))
|
||||||
value:Number(optionRow.value || 0)
|
value:Number(optionRow.value || 0)
|
||||||
onMoved:root.setOption(card.modelData,optionRow.modelData.key,optionRow.modelData.type==="integer" ? Math.round(value) : value)
|
onMoved:root.setOption(card.modelData,optionRow.modelData.key,optionRow.kind==="integer" ? Math.round(value) : value)
|
||||||
}
|
}
|
||||||
GlassTextField {
|
GlassTextField {
|
||||||
visible:optionRow.modelData.type==="string"
|
visible:optionRow.kind==="string"
|
||||||
Layout.preferredWidth:110
|
Layout.fillWidth:true
|
||||||
implicitHeight:30
|
implicitHeight:30
|
||||||
text:optionRow.value===undefined ? "" : String(optionRow.value)
|
text:optionRow.value===undefined ? "" : String(optionRow.value)
|
||||||
onEditingFinished:root.setOption(card.modelData,optionRow.modelData.key,text)
|
onEditingFinished:root.setOption(card.modelData,optionRow.modelData.key,text)
|
||||||
|
|||||||
Reference in new issue
Block a user