| 1 | import QtQuick |
| 2 | import QtQuick.Layouts |
| 3 | |
| 4 | // label + segmented buttons. options: [{value, label}] (settings app) |
| 5 | RowLayout { |
| 6 | id: c |
| 7 | property string label: "" |
| 8 | property var options: [] |
| 9 | property var value |
| 10 | signal picked(var v) |
| 11 | Layout.fillWidth: true |
| 12 | spacing: 8 |
| 13 | Text { |
| 14 | Layout.preferredWidth: 150 |
| 15 | text: c.label |
| 16 | color: Theme.fg |
| 17 | elide: Text.ElideRight |
| 18 | font.family: Theme.font |
| 19 | font.pixelSize: Theme.fontSize |
| 20 | } |
| 21 | RowLayout { |
| 22 | Layout.fillWidth: true |
| 23 | spacing: 2 |
| 24 | Repeater { |
| 25 | model: c.options |
| 26 | delegate: IconBtn { |
| 27 | required property var modelData |
| 28 | Layout.fillWidth: true |
| 29 | Layout.preferredWidth: 1 // equal widths, whatever the label length |
| 30 | implicitHeight: 26 |
| 31 | label: modelData.label |
| 32 | active: c.value === modelData.value |
| 33 | onClicked: c.picked(modelData.value) |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |