QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCRoundButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3
4import QGroundControl
5import QGroundControl.Controls
6
7Item {
8 id: _root
9
10 signal clicked()
11 property alias buttonImage: button.source
12 property real radius: ScreenTools.isMobile ? ScreenTools.defaultFontPixelHeight * 1.75 : ScreenTools.defaultFontPixelHeight * 1.25
13 property bool rotateImage: false
14 property bool lightBorders: true
15
16 width: radius * 2
17 height: radius * 2
18
19 property bool checked: false
20 property ButtonGroup buttonGroup: null
21
22 QGCPalette { id: qgcPal }
23
24 onButtonGroupChanged: {
25 if (buttonGroup) {
26 buttonGroup.addButton(_root)
27 }
28 }
29
30 onRotateImageChanged: {
31 if (rotateImage) {
32 imageRotation.running = true
33 } else {
34 imageRotation.running = false
35 button.rotation = 0
36 }
37 }
38
39 Rectangle {
40 anchors.fill: parent
41 radius: width / 2
42 border.width: ScreenTools.defaultFontPixelHeight * 0.0625
43 border.color: lightBorders ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark
44 color: checked ? qgcPal.buttonHighlight : qgcPal.button
45
46 QGCColoredImage {
47 id: button
48 anchors.fill: parent
49 sourceSize.height: parent.height
50 fillMode: Image.PreserveAspectFit
51 mipmap: true
52 smooth: true
53 color: checked ? qgcPal.buttonHighlightText : qgcPal.buttonText
54
55 RotationAnimation on rotation {
56 id: imageRotation
57 loops: Animation.Infinite
58 from: 0
59 to: 360
60 duration: 500
61 running: false
62 }
63
64 MouseArea {
65 anchors.fill: parent
66 onClicked: {
67 checked = !checked
68 _root.clicked()
69 }
70 }
71 }
72 }
73}