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 ButtonGroup buttonGroup: null
23
24 property bool _noText: text === ""
25
26 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
27
28 onButtonGroupChanged: {
29 if (buttonGroup) {
30 buttonGroup.addButton(control)
31 }
32 }
33
34 contentItem: Text {
35 //implicitWidth: _noText ? 0 : text.implicitWidth + ScreenTools.defaultFontPixelWidth * 0.25
36 //implicitHeight: _noText ? 0 : Math.max(text.implicitHeight, ScreenTools.checkBoxIndicatorSize)
37 leftPadding: control.indicator.width + control.spacing
38 verticalAlignment: Text.AlignVCenter
39 text: control.text
40 font.pointSize: textFontPointSize
41 font.bold: control.textBold
42 font.family: ScreenTools.normalFontFamily
43 color: control.textColor
44 }
45
46 indicator: Rectangle {
47 implicitWidth: ScreenTools.implicitCheckBoxHeight
48 implicitHeight: implicitWidth
49 x: control.leftPadding
50 y: parent.height / 2 - height / 2
51 color: control.enabled ? "white" : "transparent"
52 border.color: qgcPal.buttonBorder
53 border.width: 1
54 radius: ScreenTools.defaultBorderRadius
55 opacity: control.checkedState === Qt.PartiallyChecked ? 0.5 : 1
56
57 Rectangle {
58 anchors.fill: parent
59 color: qgcPal.buttonHighlight
60 opacity: control.hovered ? .2 : 0
61 radius: parent.radius
62 }
63
64 QGCColoredImage {
65 source: "/qmlimages/checkbox-check.svg"
66 color: qgcPal.buttonHighlight
67 mipmap: true
68 fillMode: Image.PreserveAspectFit
69 width: parent.implicitWidth * 0.75
70 height: width
71 sourceSize.height: height
72 visible: control.checked
73 anchors.centerIn: parent
74 }
75 }
76}