QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCColumnButton.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7
8QGCButton {
9 id: control //This is a button rework from DonLakeFlyer's QGCButton that allows to contain a text and an Icon with a column look and the same capabilites
10
11 background: Rectangle {
12 id: backRect
13 width: control.width
14 height: control.height
15 radius: backRadius
16 border.width: showBorder ? 1 : 0
17 border.color: qgcPal.buttonText
18 color: _showHighlight ?
19 qgcPal.buttonHighlight :
20 (primary ? qgcPal.primaryButton : qgcPal.button)
21 }
22
23 contentItem: Item {
24 id: contItem
25 implicitWidth: Math.max(textLabel.implicitWidth , icon.implicitWidth ) * 1.1
26 implicitHeight: iconSource === "" ? textLabel.implicitHeight : textLabel.implicitHeight * 2.5
27 ColumnLayout {
28 anchors.fill: parent
29 QGCColoredImage {
30 id: icon
31 Layout.fillWidth: true
32 Layout.fillHeight: true
33 Layout.maximumHeight: parent.height - textLabelContainer.height
34 Layout.alignment: control.text !== "" ? Qt.AlignTop : Qt.AlignHCenter | Qt.AlignVCenter
35 source: control.iconSource
36 color: qgcPal.text
37 fillMode: Image.PreserveAspectFit
38 sourceSize.height: height
39 sourceSize.width: width
40 visible: control.iconSource !== "" ? true : false
41 }
42
43 Item {
44 id: textLabelContainer
45 Layout.alignment: icon.visible ? Qt.AlignBottom | Qt.AlignHCenter : Qt.AlignCenter
46 visible: control.text !== "" ? true : false
47 Layout.preferredWidth: parent.width
48 Layout.preferredHeight: textLabel.baselineOffset
49 QGCLabel {
50 id: textLabel
51 text: control.text
52 font.family: control.font.family
53 font.pointSize: control.font.pointSize
54 color: _showHighlight ? qgcPal.buttonHighlightText : (primary ? qgcPal.primaryButtonText : qgcPal.buttonText)
55 anchors.baseline: iconSource !== "" ? parent.bottom : undefined
56 anchors.centerIn: iconSource === "" ? parent : undefined
57 anchors.horizontalCenter: parent.horizontalCenter
58 }
59 }
60 }
61 }
62}