6import QGroundControl.Controls
10 padding: ScreenTools.comboBoxPadding
11 topPadding: ScreenTools.controlVerticalPadding
12 bottomPadding: ScreenTools.controlVerticalPadding
14 property string labelText: qsTr("Options")
16 signal itemClicked(int index)
18 property var _controlQGCPal: QGCPalette { colorGroupEnabled: enabled }
19 property bool _flashChecked
20 property string _flashText
21 property bool _showFlash: false
23 Component.onCompleted: indicator.color = Qt.binding(function() { return _controlQGCPal.textPrimary })
25 background: Rectangle {
26 implicitWidth: ScreenTools.implicitComboBoxWidth
27 implicitHeight: ScreenTools.implicitComboBoxHeight
28 color: _controlQGCPal.windowInset
30 border.color: control.enabled && (control.hovered || control.pressed || control.popup.visible) ? _controlQGCPal.accent : _controlQGCPal.borderSubtle
31 radius: ScreenTools.defaultBorderRadius
34 /*! Adding the Combobox list item to the theme. */
36 delegate: ItemDelegate {
37 implicitHeight: modelData.visible ?
38 (Math.max(background ? background.implicitHeight : 0, Math.max(contentItem.implicitHeight, indicator ? indicator.implicitHeight : 0) + topPadding + bottomPadding)) :
42 enabled: modelData.enabled
45 property var _checkedValue: 1
46 property var _uncheckedValue: 0
47 property var _itemQGCPal: QGCPalette { colorGroupEnabled: enabled }
48 property var _control: control
50 Binding on checked { value: modelData.fact ?
51 (modelData.fact.typeIsBool ? (modelData.fact.value === false ? Qt.Unchecked : Qt.Checked) : (modelData.fact.value === 0 ? Qt.Unchecked : Qt.Checked)) :
54 contentItem: RowLayout {
55 spacing: ScreenTools.defaultFontPixelWidth
58 height: ScreenTools.defaultFontPixelHeight
60 border.color: _itemQGCPal.textPrimary
62 color: _itemQGCPal.windowCard
65 anchors.centerIn: parent
66 width: parent.width * 0.75
68 source: "/qmlimages/checkbox-check.svg"
69 color: _itemQGCPal.textPrimary
71 fillMode: Image.PreserveAspectFit
72 sourceSize.height: height
79 color: _itemQGCPal.textPrimary
84 background: Rectangle {
85 color: hovered ? _controlQGCPal.windowCard : _controlQGCPal.windowPanel
90 modelData.fact.value = (checked ? _checkedValue : _uncheckedValue)
94 _control._flashChecked = checked
95 _control._flashText = text
96 _control._showFlash = true
97 _control.popup.close()
101 /*! This defines the label of the button. */
103 implicitWidth: _showFlash ? flash.implicitWidth : text.implicitWidth
104 implicitHeight: _showFlash ? flash.implicitHeight : text.implicitHeight
108 anchors.verticalCenter: parent.verticalCenter
110 color: _controlQGCPal.textPrimary
116 anchors.verticalCenter: parent.verticalCenter
117 spacing: ScreenTools.defaultFontPixelWidth
131 onTriggered: _showFlash = false
135 height: ScreenTools.defaultFontPixelHeight
137 border.color: _controlQGCPal.textPrimary
139 color: _controlQGCPal.window
142 anchors.centerIn: parent
143 width: parent.width * 0.75
145 source: "/qmlimages/checkbox-check.svg"
146 color: _controlQGCPal.textPrimary
148 fillMode: Image.PreserveAspectFit
149 sourceSize.height: height
150 visible: _flashChecked
156 color: _controlQGCPal.textPrimary