Commit 189bdf58 authored by dogmaphobic's avatar dogmaphobic

Tweaking the SliderSwitch controller.

parent bee5eb8e
...@@ -136,8 +136,10 @@ ...@@ -136,8 +136,10 @@
<file alias="AntennaRC">resources/Antenna_RC.svg</file> <file alias="AntennaRC">resources/Antenna_RC.svg</file>
<file alias="AntennaT">resources/Antenna_T.svg</file> <file alias="AntennaT">resources/Antenna_T.svg</file>
<file alias="ArrowDown.svg">resources/ArrowDown.svg</file> <file alias="ArrowDown.svg">resources/ArrowDown.svg</file>
<file alias="ArrowRight.svg">resources/ArrowRight.svg</file>
<file alias="buttonLeft.svg">resources/buttonLeft.svg</file> <file alias="buttonLeft.svg">resources/buttonLeft.svg</file>
<file alias="buttonRight.svg">resources/buttonRight.svg</file> <file alias="buttonRight.svg">resources/buttonRight.svg</file>
<file alias="cancel.svg">resources/cancel.svg</file>
<file alias="gear.svg">resources/gear.svg</file> <file alias="gear.svg">resources/gear.svg</file>
<file alias="JoystickBezel.png">resources/JoystickBezel.png</file> <file alias="JoystickBezel.png">resources/JoystickBezel.png</file>
<file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file> <file alias="JoystickBezelLight.png">resources/JoystickBezelLight.png</file>
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 72 72" style="enable-background:new 0 0 72 72;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FFFFFF;stroke-width:14.3358;stroke-miterlimit:10;}
.st1{fill:#FFFFFF;}
</style>
<g>
<g>
<line class="st0" x1="37.405" y1="36.011" x2="8.877" y2="35.789"/>
<g>
<polygon class="st1" points="32.315,18.1 63.123,36.211 32.037,53.84 "/>
</g>
</g>
</g>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 19.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 28.35 28.35" style="enable-background:new 0 0 28.35 28.35;" xml:space="preserve">
<style type="text/css">
.st0{fill:none;stroke:#FF1B00;stroke-width:2.171;stroke-miterlimit:10;}
</style>
<circle class="st0" cx="14.173" cy="14.173" r="10.63"/>
<line class="st0" x1="6.657" y1="21.69" x2="21.69" y2="6.657"/>
</svg>
...@@ -40,7 +40,7 @@ Item { ...@@ -40,7 +40,7 @@ Item {
property alias guidedModeBar: _guidedModeBar property alias guidedModeBar: _guidedModeBar
property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property bool _isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true property bool _isSatellite: _mainIsMap ? _flightMap ? _flightMap.isSatelliteMap : true : true
readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2 readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2
...@@ -330,6 +330,13 @@ Item { ...@@ -330,6 +330,13 @@ Item {
} }
} }
function rejectGuidedModeConfirm() {
guidedModeConfirm.visible = false
guidedModeBar.visible = true
altitudeSlider.visible = false
_flightMap._gotoHereCoordinate = QtPositioning.coordinate()
}
function confirmAction(actionCode) { function confirmAction(actionCode) {
confirmActionCode = actionCode confirmActionCode = actionCode
switch (confirmActionCode) { switch (confirmActionCode) {
...@@ -374,32 +381,52 @@ Item { ...@@ -374,32 +381,52 @@ Item {
spacing: _margins spacing: _margins
QGCButton { QGCButton {
text: _activeVehicle.armed ? (_activeVehicle.flying ? "Emergency Stop" : "Disarm") : "Arm" text: _activeVehicle ? (_activeVehicle.armed ? (_activeVehicle.flying ? "Emergency Stop" : "Disarm") : "Arm") : ""
onClicked: _guidedModeBar.confirmAction(_activeVehicle.armed ? (_activeVehicle.flying ? _guidedModeBar.confirmEmergencyStop : _guidedModeBar.confirmDisarm) : _guidedModeBar.confirmArm) onClicked: {
if(_activeVehicle) {
_guidedModeBar.confirmAction(_activeVehicle.armed ? (_activeVehicle.flying ? _guidedModeBar.confirmEmergencyStop : _guidedModeBar.confirmDisarm) : _guidedModeBar.confirmArm)
}
}
} }
QGCButton { QGCButton {
text: "RTL" text: "RTL"
visible: _activeVehicle.guidedModeSupported && _activeVehicle.flying visible: _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.flying
onClicked: _guidedModeBar.confirmAction(_guidedModeBar.confirmHome) onClicked: {
if(_activeVehicle) {
_guidedModeBar.confirmAction(_guidedModeBar.confirmHome)
}
}
} }
QGCButton { QGCButton {
text: _activeVehicle.flying ? "Land" : "Takeoff" text: _activeVehicle ? (_activeVehicle.flying ? "Land" : "Takeoff") : ""
visible: _activeVehicle.guidedModeSupported && _activeVehicle.armed visible: _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.armed
onClicked: _guidedModeBar.confirmAction(_activeVehicle.flying ? _guidedModeBar.confirmLand : _guidedModeBar.confirmTakeoff) onClicked: {
if(_activeVehicle) {
_guidedModeBar.confirmAction(_activeVehicle.flying ? _guidedModeBar.confirmLand : _guidedModeBar.confirmTakeoff)
}
}
} }
QGCButton { QGCButton {
text: "Pause" text: "Pause"
visible: _activeVehicle.pauseVehicleSupported && _activeVehicle.flying visible: _activeVehicle && _activeVehicle.pauseVehicleSupported && _activeVehicle.flying
onClicked: _activeVehicle.pauseVehicle() onClicked: {
if(_activeVehicle) {
_activeVehicle.pauseVehicle()
}
}
} }
QGCButton { QGCButton {
text: "Change Altitude" text: "Change Altitude"
visible: _activeVehicle.guidedModeSupported && _activeVehicle.armed visible: _activeVehicle && _activeVehicle.guidedModeSupported && _activeVehicle.armed
onClicked: _guidedModeBar.confirmAction(_guidedModeBar.confirmChangeAlt) onClicked: {
if(_activeVehicle) {
_guidedModeBar.confirmAction(_guidedModeBar.confirmChangeAlt)
}
}
} }
} }
...@@ -439,12 +466,21 @@ Item { ...@@ -439,12 +466,21 @@ Item {
}*/ }*/
} // Rectangle - Guided mode buttons } // Rectangle - Guided mode buttons
MouseArea {
anchors.fill: parent
enabled: guidedModeConfirm.visible
onClicked: {
_guidedModeBar.rejectGuidedModeConfirm()
}
}
// Action confirmation control // Action confirmation control
SliderSwitch { SliderSwitch {
id: guidedModeConfirm id: guidedModeConfirm
anchors.top: _guidedModeBar.top anchors.top: _guidedModeBar.top
anchors.bottom: _guidedModeBar.bottom anchors.bottom: _guidedModeBar.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
showReject: true
visible: false visible: false
z: QGroundControl.zOrderWidgets z: QGroundControl.zOrderWidgets
...@@ -456,10 +492,7 @@ Item { ...@@ -456,10 +492,7 @@ Item {
} }
onReject: { onReject: {
guidedModeConfirm.visible = false _guidedModeBar.rejectGuidedModeConfirm()
guidedModeBar.visible = true
altitudeSlider.visible = false
_flightMap._gotoHereCoordinate = QtPositioning.coordinate()
} }
} }
......
...@@ -8,7 +8,7 @@ import QGroundControl.Palette 1.0 ...@@ -8,7 +8,7 @@ import QGroundControl.Palette 1.0
/// control on an iPhone. /// control on an iPhone.
Rectangle { Rectangle {
id: _root id: _root
width: label.contentWidth + (_diameter * 2) + (_border * 4) width: label.contentWidth + (_diameter * 2.5) + (_border * 4)
radius: height /2 radius: height /2
color: qgcPal.window color: qgcPal.window
...@@ -16,6 +16,7 @@ Rectangle { ...@@ -16,6 +16,7 @@ Rectangle {
signal reject ///< Action rejected signal reject ///< Action rejected
property string confirmText ///< Text for slider property string confirmText ///< Text for slider
property bool showReject: false
property real _border: 4 property real _border: 4
property real _diameter: height - (_border * 2) property real _diameter: height - (_border * 2)
...@@ -39,11 +40,25 @@ Rectangle { ...@@ -39,11 +40,25 @@ Rectangle {
color: qgcPal.windowShade color: qgcPal.windowShade
opacity: 0.8 opacity: 0.8
QGCColoredImage {
anchors.centerIn: parent
width: parent.width * 0.8
height: parent.height * 0.8
fillMode: Image.PreserveAspectFit
smooth: false
mipmap: false
color: qgcPal.text
cache: false
source: "/res/ArrowRight.svg"
}
/*
QGCLabel { QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: ">" text: ">"
} }
*/
MouseArea { MouseArea {
id: sliderDragArea id: sliderDragArea
...@@ -54,7 +69,7 @@ Rectangle { ...@@ -54,7 +69,7 @@ Rectangle {
drag.minimumX: _border drag.minimumX: _border
drag.maximumX: _maxXDrag drag.maximumX: _maxXDrag
property real _maxXDrag: _root.width - ((_diameter + _border) * 2) property real _maxXDrag: _root.width - ((_diameter + _border) * (showReject ? 2 : 1))
property bool dragActive: drag.active property bool dragActive: drag.active
onDragActiveChanged: { onDragActiveChanged: {
...@@ -78,12 +93,24 @@ Rectangle { ...@@ -78,12 +93,24 @@ Rectangle {
radius: _diameter / 2 radius: _diameter / 2
color: qgcPal.windowShade color: qgcPal.windowShade
opacity: 0.8 opacity: 0.8
visible: showReject
Image {
anchors.centerIn: parent
width: parent.width * 0.8
height: parent.height * 0.8
fillMode: Image.PreserveAspectFit
smooth: true
source: "/res/cancel.svg"
}
/*
QGCLabel { QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
text: "X" text: "X"
} }
*/
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment