QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCCheckBoxSlider.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8AbstractButton {
9 id: control
10 checkable: true
11 padding: 0
12
13 property bool _showBorder: qgcPal.globalTheme === QGCPalette.Light
14 property int _sliderInset: 2
15 property bool _showHighlight: enabled && (pressed || checked)
16
17 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
18
19 contentItem: Item {
20 implicitWidth: (label.visible ? label.contentWidth + ScreenTools.defaultFontPixelWidth : 0) + indicator.width
21 implicitHeight: label.contentHeight
22
23 QGCLabel {
24 id: label
25 anchors.left: parent.left
26 text: visible ? control.text : "X"
27 visible: control.text !== ""
28 }
29
30 Rectangle {
31 id: indicator
32 anchors.right: parent.right
33 anchors.verticalCenter: parent.verticalCenter
34 height: ScreenTools.defaultFontPixelHeight
35 width: height * 2
36 radius: height / 2
37 color: checked ? qgcPal.buttonHighlight : qgcPal.button
38 border.width: _showBorder ? 1 : 0
39 border.color: qgcPal.buttonBorder
40
41 Rectangle {
42 anchors.fill: parent
43 color: qgcPal.buttonHighlight
44 opacity: _showHighlight ? 1 : control.enabled && control.hovered ? .2 : 0
45 radius: parent.radius
46 }
47
48 Rectangle {
49 anchors.verticalCenter: parent.verticalCenter
50 x: checked ? indicator.width - width - _sliderInset : _sliderInset
51 height: parent.height - (_sliderInset * 2)
52 width: height
53 radius: height / 2
54 color: qgcPal.buttonText
55 }
56 }
57 }
58}