Commit 2814c345 authored by Valentin Platzgummer's avatar Valentin Platzgummer

vertical ToolStrip.qml feature added

parent b750c08c
[Dolphin]
PreviewsShown=true
Timestamp=2020,2,21,14,47,12
Version=4
[Dolphin]
Timestamp=2020,2,21,14,48,2
Version=4
......@@ -679,6 +679,8 @@ QGCView {
maxHeight: (_flightVideo.visible ? _flightVideo.y : parent.height) - toolStrip.y
buttonVisible: [ _useChecklist, _guidedController.showTakeoff || !_guidedController.showLand, _guidedController.showLand && !_guidedController.showTakeoff, true, true, true ]
buttonEnabled: [ _useChecklist && _activeVehicle, _guidedController.showTakeoff, _guidedController.showLand, _guidedController.showRTL, _guidedController.showPause, _anyActionAvailable ]
horizontal: true
enableSwitchButton: true
property bool _anyActionAvailable: _guidedController.showStartMission || _guidedController.showResumeMission || _guidedController.showChangeAlt || _guidedController.showLandAbort
property var _actionModel: [
......
......@@ -9,6 +9,7 @@
import QtQuick 2.11
import QtQuick.Controls 1.4
import QtQuick.Layouts 1.11
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
......@@ -16,8 +17,8 @@ import QGroundControl.Palette 1.0
Rectangle {
id: _root
color: qgcPal.window
width: ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 7
height: toolStripColumn.height + (toolStripColumn.anchors.margins * 2)
width: toolStripGrid.width + (toolStripGrid.anchors.margins * 2)
height: toolStripGrid.height + (toolStripGrid.anchors.margins * 2)
radius: _radius
border.width: 1
border.color: qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(0,0,0,0.35) : Qt.rgba(1,1,1,0.35)
......@@ -30,6 +31,11 @@ Rectangle {
property var buttonEnabled ///< List of bool values, one for each button in strip - true: button enabled, false: button disabled
property var buttonVisible ///< List of bool values, one for each button in strip - true: button visible, false: button invisible
property real maxHeight ///< Maximum height for control, determines whether text is hidden to make control shorter
property bool horizontal: false /// toolstrip horizontal or vertical ?
property bool enableSwitchButton: false /// enable horizontal vertical button ?
property real _horizontal: horizontal
signal clicked(int index, bool checked)
......@@ -37,6 +43,8 @@ Rectangle {
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
readonly property real _buttonSpacing: ScreenTools.defaultFontPixelHeight / 4
readonly property real _imageWidthHeight: ScreenTools.isMobile ? ScreenTools.minTouchPixels : ScreenTools.defaultFontPixelWidth * 5
QGCPalette { id: qgcPal }
ExclusiveGroup { id: dropButtonsExclusiveGroup }
......@@ -54,40 +62,46 @@ Rectangle {
anchors.fill: parent
}
Column {
id: toolStripColumn
GridLayout {
id: toolStripGrid
anchors.margins: ScreenTools.defaultFontPixelWidth / 2
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: _buttonSpacing
columnSpacing: _buttonSpacing
rowSpacing: _buttonSpacing
rows: _horizontal ? 1 : model.length
columns: _horizontal ? model.length : 1
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter
text: title
font.pointSize: ScreenTools.mobile ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
Layout.alignment: _horizontal ? Qt.AlignVCenter : Qt.AlignHCenter
}
// separator
Rectangle {
anchors.left: parent.left
anchors.right: parent.right
height: 1
height: _horizontal ? undefined : 1
width: _horizontal ? 1 : undefined
Layout.fillWidth: _horizontal ? false : true
Layout.fillHeight: _horizontal ? true : false
color: qgcPal.text
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _buttonSpacing
GridLayout {
rows: _horizontal ? 1 : model.length
columns: _horizontal ? model.length : 1
columnSpacing: _buttonSpacing
rowSpacing: _buttonSpacing
Repeater {
id: repeater
delegate: FocusScope {
id: scope
width: toolStripColumn.width
width: buttonRect.width
height: buttonRect.height
visible: _root.buttonVisible ? _root.buttonVisible[index] : true
Layout.alignment: _horizontal ? Qt.AlignVCenter : Qt.AlignHCenter
property bool checked: false
property ExclusiveGroup exclusiveGroup: dropButtonsExclusiveGroup
......@@ -130,21 +144,21 @@ Rectangle {
Rectangle {
id: buttonRect
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
height: buttonColumn.height
width: buttonColumn.width
color: _showHighlight ? _repeaterPal.buttonHighlight : _repeaterPal.window
Column {
id: buttonColumn
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
spacing: -buttonImage.height / 8
spacing: _buttonSpacing
QGCColoredImage {
id: buttonImage
anchors.left: parent.left
anchors.right: parent.right
height: width * 0.8
height: _imageWidthHeight
width: _imageWidthHeight
//anchors.centerIn: parent
source: _source
sourceSize.height: height
......@@ -217,9 +231,81 @@ Rectangle {
}
} // Rectangle
} // FocusScope
}
} // Repeater
} // GridLayout
// separator
Rectangle {
height: _horizontal ? undefined : 1
width: _horizontal ? 1 : undefined
Layout.fillWidth: _horizontal ? false : true
Layout.fillHeight: _horizontal ? true : false
color: qgcPal.text
visible: enableSwitchButton
}
}
// switch button, tool strip horizontal <-> vertical
Rectangle {
id: switchButtonRect
height: switchButtonColumn.height
width: switchButtonColumn.width
color: _showHighlight ? _switchButtonPal.buttonHighlight : _switchButtonPal.window
visible: enableSwitchButton
property bool _hovered: false
property bool _showHighlight: (enableSwitchButton && _hovered)
QGCPalette { id: _switchButtonPal; colorGroupEnabled: enableSwitchButton }
Column {
id: switchButtonColumn
anchors.top: parent.top
anchors.left: parent.left
spacing: _buttonSpacing
QGCColoredImage {
id: switchButtonImage
height: _imageWidthHeight
width: _imageWidthHeight
//anchors.centerIn: parent
source: "/res/clockwise-arrow.svg"
sourceSize.height: height
fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true
color: switchButtonRect._showHighlight ? _switchButtonPal.buttonHighlightText : _switchButtonPal.text
}
QGCLabel {
id: switchButtonLabel
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: ScreenTools.smallFontPointSize
text: _horizontal ? "Vert" : "Hor"
color: switchButtonRect._showHighlight ? _switchButtonPal.buttonHighlightText : _switchButtonPal.text
enabled: enableSwitchButton
}
} // Column
QGCMouseArea {
anchors.fill: parent
visible: enableSwitchButton
hoverEnabled: true
preventStealing: true
onContainsMouseChanged: switchButtonRect._hovered = containsMouse
onContainsPressChanged: switchButtonRect._hovered = containsPress
onClicked: {
dropPanel.hide() // hide affects checked, so this needs to be duplicated inside not outside if
if (_root._horizontal === true) {
_root._horizontal = false
} else {
_root._horizontal = true
}
}
}
} // switchButton Rectangle
} // GridLayout
DropPanel {
id: dropPanel
......
......@@ -1425,6 +1425,7 @@ void Vehicle::_handleExtendedSysState(mavlink_message_t& message)
mavlink_extended_sys_state_t extendedState;
mavlink_msg_extended_sys_state_decode(&message, &extendedState);
qWarning() << "Vehicle::_handleExtendedSysState: land_state: " << extendedState.landed_state;
switch (extendedState.landed_state) {
case MAV_LANDED_STATE_ON_GROUND:
_setFlying(false);
......
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