6import QGroundControl.Controls
8/// Standard push button control:
9/// If there is both an icon and text the icon will be to the left of the text
10/// If icon only, icon will be centered
12 property bool primary: false
13 property bool showBorder: qgcPal.globalTheme === QGCPalette.Light
14 property real backRadius: ScreenTools.defaultBorderRadius
15 property real heightFactor: 0.5
16 property string iconSource: ""
17 property real fontWeight: Font.Normal // default for qml Text
18 property real pointSize: ScreenTools.defaultFontPointSize
20 property alias wrapMode: text.wrapMode
21 property alias horizontalAlignment: text.horizontalAlignment
22 property alias backgroundColor: backRect.color
23 property alias textColor: text.color
26 hoverEnabled: !ScreenTools.isMobile
27 topPadding: _verticalPadding
28 bottomPadding: _verticalPadding
29 leftPadding: _horizontalPadding
30 rightPadding: _horizontalPadding
31 focusPolicy: Qt.ClickFocus
32 font.family: ScreenTools.normalFontFamily
35 property bool _showHighlight: enabled && (pressed | checked)
36 property int _horizontalPadding: ScreenTools.defaultFontPixelWidth * 2
37 property int _verticalPadding: Math.round(ScreenTools.defaultFontPixelHeight * heightFactor) - (iconSource === "" ? 0 : (_iconHeight - ScreenTools.defaultFontPixelHeight) / 2)
38 property real _iconHeight: text.height * 1.5
40 QGCPalette { id: qgcPal; colorGroupEnabled: control.enabled }
42 background: Rectangle {
45 implicitWidth: ScreenTools.implicitButtonWidth
46 implicitHeight: ScreenTools.implicitButtonHeight
47 border.width: showBorder ? 1 : 0
48 border.color: qgcPal.buttonBorder
49 color: primary ? qgcPal.primaryButton : qgcPal.button
53 color: qgcPal.buttonHighlight
54 opacity: _showHighlight ? 1 : control.enabled && control.hovered ? .2 : 0
59 contentItem: RowLayout {
60 spacing: ScreenTools.defaultFontPixelWidth
64 Layout.alignment: Qt.AlignHCenter
65 source: control.iconSource
69 fillMode: Image.PreserveAspectFit
70 sourceSize.height: height
71 visible: control.iconSource !== ""
76 Layout.alignment: Qt.AlignHCenter
78 font.pointSize: control.pointSize
79 font.family: control.font.family
80 font.weight: fontWeight
81 color: _showHighlight ? qgcPal.buttonHighlightText : (primary ? qgcPal.primaryButtonText : qgcPal.buttonText)
82 visible: control.text !== ""