QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCCheckBox.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7CheckBox {
8 id: control
9 spacing: _noText ? 0 : ScreenTools.defaultFontPixelWidth
10 focusPolicy: Qt.ClickFocus
11 leftPadding: 0
12
13 Component.onCompleted: {
14 if (_noText) {
15 rightPadding = 0
16 }
17 }
18
19 property color textColor: qgcPal.buttonText
20 property bool textBold: false
21 property real textFontPointSize: ScreenTools.defaultFontPointSize
22 property int wrapMode: Text.NoWrap
23 property ButtonGroup buttonGroup: null
24
25 property bool _noText: text === ""
26
27 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
28
29 onButtonGroupChanged: {
30 if (buttonGroup) {
31 buttonGroup.addButton(control)
32 }
33 }
34
35 contentItem: Text {
36 //implicitWidth: _noText ? 0 : text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
37 //implicitHeight: _noText ? 0 : Math.max(text.implicitHeight, ScreenTools.checkBoxIndicatorSize)
38 leftPadding: control.indicator.width + control.spacing
39 verticalAlignment: Text.AlignVCenter
40 text: control.text
41 font.pointSize: textFontPointSize
42 font.bold: control.textBold
43 font.family: ScreenTools.normalFontFamily
44 color: control.textColor
45 wrapMode: control.wrapMode
46 }
47
48 indicator: Rectangle {
49 implicitWidth: ScreenTools.implicitCheckBoxHeight
50 implicitHeight: implicitWidth
51 x: control.leftPadding
52 y: parent.height / 2 - height / 2
53 color: control.enabled ? "white" : "transparent"
54 border.color: qgcPal.buttonBorder
55 border.width: 1
56 radius: ScreenTools.defaultBorderRadius
57 opacity: control.checkedState === Qt.PartiallyChecked ? 0.5 : 1
58
59 Rectangle {
60 anchors.fill: parent
61 color: qgcPal.buttonHighlight
62 opacity: control.hovered ? .2 : 0
63 radius: parent.radius
64 }
65
66 QGCColoredImage {
67 source: "/qmlimages/checkbox-check.svg"
68 color: qgcPal.buttonHighlight
69 mipmap: true
70 fillMode: Image.PreserveAspectFit
71 width: parent.implicitWidth * 0.75
72 height: width
73 sourceSize.height: height
74 visible: control.checked
75 anchors.centerIn: parent
76 }
77 }
78}