Skip to content

Commit 5e084d4

Browse files
committed
DelayButton: Gradient to indicate button type, auto help text
* There is a gradient on the left to visual indicate this is a delay button * If you click and release before activating it will show "Hold to Confirm" help text within the button * The "Hold to Confirm" help text will disappear after a timeout
1 parent a9f83f1 commit 5e084d4

File tree

5 files changed

+41
-29
lines changed

5 files changed

+41
-29
lines changed

src/FlightDisplay/FlyViewGripperDropPanel.qml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ ColumnLayout {
2020
property var _buttonTitles: [qsTr("Open"), qsTr("Close"), qsTr("Stop")]
2121
property var _buttonActions: [QGCMAVLink.GripperActionOpen, QGCMAVLink.GripperActionClose, QGCMAVLink.GripperActionStop]
2222

23-
QGCLabel {
24-
Layout.fillWidth: true
25-
text: qsTr("Hold to Confirm")
26-
font.pointSize: ScreenTools.smallFontPointSize
27-
}
28-
2923
Repeater {
3024
model: _buttonTitles
3125

src/FlightDisplay/GuidedActionConfirm.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Rectangle {
9191
Layout.fillWidth: true
9292
Layout.leftMargin: closeButton.width + closeButton.anchors.rightMargin
9393
Layout.rightMargin: Layout.leftMargin
94-
text: control.title
94+
text: control.message
9595
horizontalAlignment: Text.AlignHCenter
9696
}
9797

@@ -104,7 +104,7 @@ Rectangle {
104104

105105
QGCDelayButton {
106106
Layout.fillWidth: true
107-
text: qsTr("Hold To Confirm")
107+
text: control.title
108108
enabled: _utmspEnabled === true? utmspSliderTrigger : true
109109
opacity: if(_utmspEnabled){utmspSliderTrigger === true ? 1 : 0.5} else{1}
110110

src/QmlControls/FlightModeIndicator.qml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@ Item {
141141
}
142142
}
143143

144-
QGCLabel {
145-
text: qsTr("Hold to confirm")
146-
font.pointSize: ScreenTools.smallFontPointSize
147-
Layout.fillWidth: true
148-
horizontalAlignment:Text.AlignHCenter
149-
visible: flightModeSettings.requireModeChangeConfirmation.rawValue
150-
}
151-
152144
QGCDelayButton {
153145
id: vtolTransitionButton
154146
Layout.fillWidth: true

src/QmlControls/MainStatusIndicator.qml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ RowLayout {
196196
QGCDelayButton {
197197
enabled: _armed || !_healthAndArmingChecksSupported || _activeVehicle.healthAndArmingCheckReport.canArm
198198
text: _armed ? qsTr("Disarm") : (control._allowForceArm ? qsTr("Force Arm") : qsTr("Arm"))
199-
showHelp: true
200199

201200
onActivated: {
202201
if (_armed) {

src/QmlControls/QGCDelayButton.qml

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ DelayButton {
1010
id: control
1111
hoverEnabled: !ScreenTools.isMobile
1212
topPadding: _verticalPadding
13-
bottomPadding: _verticalPadding + (showHelp ? ScreenTools.defaultFontPixelHeight : 0)
13+
bottomPadding: _verticalPadding
1414
leftPadding: _horizontalPadding
1515
rightPadding: _horizontalPadding
16-
bottomInset: showHelp ? ScreenTools.defaultFontPixelHeight : 0
1716
focusPolicy: Qt.ClickFocus
1817
font.family: ScreenTools.normalFontFamily
19-
text: ""
2018
delay: defaultDelay
2119

22-
property bool showHelp: false // true: show "Hold to Confirm" help text
2320
property bool showBorder: qgcPal.globalTheme === QGCPalette.Light
2421
property real backRadius: ScreenTools.buttonBorderRadius
2522
property real heightFactor: 0.5
@@ -33,20 +30,51 @@ DelayButton {
3330
property alias textColor: text.color
3431

3532
property bool _showHighlight: enabled && pressed
36-
37-
property int _horizontalPadding: ScreenTools.defaultFontPixelWidth * 2
38-
property int _verticalPadding: Math.round(ScreenTools.defaultFontPixelHeight * heightFactor)
33+
property int _horizontalPadding: ScreenTools.defaultFontPixelWidth * 2
34+
property int _verticalPadding: Math.round(ScreenTools.defaultFontPixelHeight * heightFactor)
35+
property bool _showHelp: false
36+
property bool _activated: false
3937

4038
QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
4139

40+
Timer {
41+
id: helpTimeout
42+
interval: 3000
43+
repeat: false
44+
onTriggered: control._showHelp = false
45+
}
46+
47+
onActivated: {
48+
_activated = true
49+
_showHelp = false
50+
}
51+
onPressed: {
52+
_activated = false
53+
}
54+
onReleased: {
55+
_showHelp = !_activated
56+
_activated = false
57+
if (_showHelp) {
58+
helpTimeout.start()
59+
} else {
60+
helpTimeout.stop()
61+
}
62+
}
63+
4264
background: Rectangle {
4365
id: backRect
4466
radius: backRadius
45-
implicitWidth: Math.max(control.showHelp ? helpText.contentWidth : 0, ScreenTools.implicitButtonWidth)
67+
implicitWidth: Math.max(control._showHelp ? helpText.contentWidth : 0, ScreenTools.implicitButtonWidth)
4668
implicitHeight: ScreenTools.implicitButtonHeight
4769
border.width: showBorder ? 1 : 0
4870
border.color: qgcPal.buttonBorder
49-
color: qgcPal.button
71+
72+
gradient: Gradient {
73+
orientation: Gradient.Horizontal
74+
75+
GradientStop { position: 0.0; color: qgcPal.buttonHighlight }
76+
GradientStop { position: 0.15; color: qgcPal.button }
77+
}
5078

5179
Rectangle {
5280
anchors.fill: parent
@@ -60,10 +88,9 @@ DelayButton {
6088
id: helpText
6189
text: qsTr("Hold to Confirm")
6290
anchors.bottom: parent.bottom
63-
anchors.bottomMargin: -contentHeight
6491
anchors.horizontalCenter: parent.horizontalCenter
6592
font.pointSize: ScreenTools.smallFontPointSize
66-
visible: control.showHelp
93+
visible: control._showHelp
6794
}
6895
}
6996

@@ -73,7 +100,7 @@ DelayButton {
73100
text: control.text
74101
font.pointSize: control.pointSize
75102
font.family: control.font.family
76-
font.weight: fontWeight
103+
font.weight: control.fontWeight
77104
color: qgcPal.buttonText
78105
}
79106
}

0 commit comments

Comments
 (0)