Browse Source

Merge pull request #8112 from DonLakeFlyer/PreventViewSwitch

View switch prevention support
QGC4.4
Don Gagne 6 years ago committed by GitHub
parent
commit
72fd8342e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/QmlControls/QGCToolBarButton.qml
  2. 7
      src/QmlControls/SubMenuButton.qml
  3. 44
      src/VehicleSetup/SetupView.qml
  4. 3
      src/ui/AppSettings.qml
  5. 5
      src/ui/MainRootWindow.qml
  6. 36
      src/ui/toolbar/MainToolBar.qml

9
src/QmlControls/QGCToolBarButton.qml

@ -14,20 +14,25 @@ import QGroundControl.Controls 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
// Important Note: Toolbar buttons must manage their checked state manually in order to support
// view switch prevention. This means they can't be checkable or autoExclusive.
Button { Button {
id: button id: button
height: ScreenTools.defaultFontPixelHeight * 3 height: ScreenTools.defaultFontPixelHeight * 3
leftPadding: _horizontalMargin leftPadding: _horizontalMargin
rightPadding: _horizontalMargin rightPadding: _horizontalMargin
autoExclusive: true checkable: false
property bool logo: false property bool logo: false
property real _horizontalMargin: ScreenTools.defaultFontPixelWidth property real _horizontalMargin: ScreenTools.defaultFontPixelWidth
onCheckedChanged: checkable = false
background: Rectangle { background: Rectangle {
anchors.fill: parent anchors.fill: parent
color: logo ? qgcPal.brandingPurple : (checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0)) color: logo ? qgcPal.brandingPurple : (button.checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0))
} }
contentItem: Row { contentItem: Row {

7
src/QmlControls/SubMenuButton.qml

@ -6,6 +6,9 @@ import QtGraphicalEffects 1.0
import QGroundControl.Palette 1.0 import QGroundControl.Palette 1.0
import QGroundControl.ScreenTools 1.0 import QGroundControl.ScreenTools 1.0
// Important Note: SubMenuButtons must manage their checked state manually in order to support
// view switch prevention. This means they can't be checkable or autoExclusive.
Button { Button {
id: _rootButton id: _rootButton
property bool setupComplete: true ///< true: setup complete indicator shows as completed property bool setupComplete: true ///< true: setup complete indicator shows as completed
@ -14,11 +17,13 @@ Button {
property size sourceSize: Qt.size(ScreenTools.defaultFontPixelHeight * 2, ScreenTools.defaultFontPixelHeight * 2) property size sourceSize: Qt.size(ScreenTools.defaultFontPixelHeight * 2, ScreenTools.defaultFontPixelHeight * 2)
text: "Button" ///< Pass in your own button text text: "Button" ///< Pass in your own button text
activeFocusOnPress: true
checkable: true
implicitHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3.5 : ScreenTools.defaultFontPixelHeight * 2.5 implicitHeight: ScreenTools.isTinyScreen ? ScreenTools.defaultFontPixelHeight * 3.5 : ScreenTools.defaultFontPixelHeight * 2.5
implicitWidth: __panel.implicitWidth implicitWidth: __panel.implicitWidth
onCheckedChanged: checkable = false
style: ButtonStyle { style: ButtonStyle {
id: buttonStyle id: buttonStyle

44
src/VehicleSetup/SetupView.qml

@ -41,6 +41,9 @@ Rectangle {
function showSummaryPanel() function showSummaryPanel()
{ {
if (mainWindow.preventViewSwitch) {
return
}
if (_fullParameterVehicleAvailable) { if (_fullParameterVehicleAvailable) {
if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length === 0) { if (QGroundControl.multiVehicleManager.activeVehicle.autopilot.vehicleComponents.length === 0) {
panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent) panelLoader.setSourceComponent(noComponentsVehicleSummaryComponent)
@ -54,30 +57,19 @@ Rectangle {
} }
} }
function showFirmwarePanel() function showPanel(button, qmlSource) {
{ if (mainWindow.preventViewSwitch) {
if (!ScreenTools.isMobile) { return
panelLoader.setSource("FirmwareUpgrade.qml")
}
}
function showJoystickPanel()
{
panelLoader.setSource("JoystickConfig.qml")
}
function showParametersPanel()
{
panelLoader.setSource("SetupParameterEditor.qml")
} }
button.checked = true
function showPX4FlowPanel() panelLoader.setSource(qmlSource)
{
panelLoader.setSource("PX4FlowSensor.qml")
} }
function showVehicleComponentPanel(vehicleComponent) function showVehicleComponentPanel(vehicleComponent)
{ {
if (mainWindow.preventViewSwitch) {
return
}
var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot var autopilotPlugin = QGroundControl.multiVehicleManager.activeVehicle.autopilot
var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent) var prereq = autopilotPlugin.prerequisiteSetup(vehicleComponent)
if (prereq !== "") { if (prereq !== "") {
@ -229,7 +221,7 @@ Rectangle {
exclusiveGroup: setupButtonGroup exclusiveGroup: setupButtonGroup
text: modelData.title text: modelData.title
visible: _corePlugin && _corePlugin.options.combineSettingsAndSetup visible: _corePlugin && _corePlugin.options.combineSettingsAndSetup
onClicked: panelLoader.setSource(modelData.url) onClicked: showPanel(this, modelData.url)
Layout.fillWidth: true Layout.fillWidth: true
} }
} }
@ -255,7 +247,7 @@ Rectangle {
text: qsTr("Firmware") text: qsTr("Firmware")
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showFirmwarePanel() onClicked: showPanel(this, "FirmwareUpgrade.qml")
} }
SubMenuButton { SubMenuButton {
@ -265,8 +257,7 @@ Rectangle {
setupIndicator: false setupIndicator: false
text: qsTr("PX4Flow") text: qsTr("PX4Flow")
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showPX4FlowPanel(this, "PX4FlowSensor.qml")
onClicked: showPX4FlowPanel()
} }
SubMenuButton { SubMenuButton {
@ -277,8 +268,7 @@ Rectangle {
visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length !== 0 visible: _fullParameterVehicleAvailable && joystickManager.joysticks.length !== 0
text: qsTr("Joystick") text: qsTr("Joystick")
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showJoystickPanel(this, "JoystickConfig.qml")
onClicked: showJoystickPanel()
} }
Repeater { Repeater {
@ -293,7 +283,6 @@ Rectangle {
text: modelData.name text: modelData.name
visible: modelData.setupSource.toString() !== "" visible: modelData.setupSource.toString() !== ""
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showVehicleComponentPanel(modelData) onClicked: showVehicleComponentPanel(modelData)
} }
} }
@ -306,8 +295,7 @@ Rectangle {
_corePlugin.showAdvancedUI _corePlugin.showAdvancedUI
text: qsTr("Parameters") text: qsTr("Parameters")
Layout.fillWidth: true Layout.fillWidth: true
onClicked: showPanel(this, "SetupParameterEditor.qml")
onClicked: showParametersPanel()
} }
} }

3
src/ui/AppSettings.qml

@ -74,6 +74,9 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
if (__rightPanel.source !== modelData.url) { if (__rightPanel.source !== modelData.url) {
__rightPanel.source = modelData.url __rightPanel.source = modelData.url
} }

5
src/ui/MainRootWindow.qml

@ -49,6 +49,7 @@ ApplicationWindow {
property bool communicationLost: activeVehicle ? activeVehicle.connectionLost : false property bool communicationLost: activeVehicle ? activeVehicle.connectionLost : false
property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : "" property string formatedMessage: activeVehicle ? activeVehicle.formatedMessage : ""
property real availableHeight: mainWindow.height - mainWindow.header.height - mainWindow.footer.height property real availableHeight: mainWindow.height - mainWindow.header.height - mainWindow.footer.height
property bool preventViewSwitch: false
property var currentPlanMissionItem: planMasterControllerPlan ? planMasterControllerPlan.missionController.currentPlanViewItem : null property var currentPlanMissionItem: planMasterControllerPlan ? planMasterControllerPlan.missionController.currentPlanViewItem : null
property var planMasterControllerPlan: null property var planMasterControllerPlan: null
@ -151,6 +152,8 @@ ApplicationWindow {
mainWindowDialog.dialogComponent = component mainWindowDialog.dialogComponent = component
mainWindowDialog.dialogTitle = title mainWindowDialog.dialogTitle = title
mainWindowDialog.dialogButtons = buttons mainWindowDialog.dialogButtons = buttons
console.log("Prevent view switch")
mainWindow.preventViewSwitch = true
mainWindowDialog.open() mainWindowDialog.open()
if (buttons & StandardButton.Cancel || buttons & StandardButton.Close || buttons & StandardButton.Discard || buttons & StandardButton.Abort || buttons & StandardButton.Ignore) { if (buttons & StandardButton.Cancel || buttons & StandardButton.Close || buttons & StandardButton.Discard || buttons & StandardButton.Abort || buttons & StandardButton.Ignore) {
mainWindowDialog.closePolicy = Popup.NoAutoClose; mainWindowDialog.closePolicy = Popup.NoAutoClose;
@ -184,6 +187,8 @@ ApplicationWindow {
dlgLoader.source = "QGCViewDialogContainer.qml" dlgLoader.source = "QGCViewDialogContainer.qml"
} }
onClosed: { onClosed: {
console.log("View switch ok")
mainWindow.preventViewSwitch = false
dlgLoader.source = "" dlgLoader.source = ""
} }
} }

36
src/ui/toolbar/MainToolBar.qml

@ -98,17 +98,25 @@ Item {
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
spacing: ScreenTools.defaultFontPixelWidth / 2 spacing: ScreenTools.defaultFontPixelWidth / 2
ButtonGroup { // Important Note: Toolbar buttons must manage their checked state manually in order to support
buttons: viewRow.children // view switch prevention. There doesn't seem to be a way to make this work if they are in a
} // ButtonGroup.
//--------------------------------------------- //---------------------------------------------
// Toolbar Row // Toolbar Row
RowLayout { RowLayout {
id: viewRow id: buttonRow
Layout.fillHeight: true Layout.fillHeight: true
spacing: 0 spacing: 0
function clearAllChecks() {
for (var i=0; i<buttonRow.children.length; i++) {
if (buttonRow.children[i].toString().startsWith("QGCToolBarButton")) {
buttonRow.children[i].checked = false
}
}
}
QGCToolBarButton { QGCToolBarButton {
id: settingsButton id: settingsButton
Layout.fillHeight: true Layout.fillHeight: true
@ -116,6 +124,10 @@ Item {
logo: true logo: true
visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup visible: !QGroundControl.corePlugin.options.combineSettingsAndSetup
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
buttonRow.clearAllChecks()
checked = true checked = true
mainWindow.showSettingsView() mainWindow.showSettingsView()
} }
@ -126,6 +138,10 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
icon.source: "/qmlimages/Gears.svg" icon.source: "/qmlimages/Gears.svg"
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
buttonRow.clearAllChecks()
checked = true checked = true
mainWindow.showSetupView() mainWindow.showSetupView()
} }
@ -136,6 +152,10 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
icon.source: "/qmlimages/Plan.svg" icon.source: "/qmlimages/Plan.svg"
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
buttonRow.clearAllChecks()
checked = true checked = true
mainWindow.showPlanView() mainWindow.showPlanView()
} }
@ -146,6 +166,10 @@ Item {
Layout.fillHeight: true Layout.fillHeight: true
icon.source: "/qmlimages/PaperPlane.svg" icon.source: "/qmlimages/PaperPlane.svg"
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
buttonRow.clearAllChecks()
checked = true checked = true
mainWindow.showFlyView() mainWindow.showFlyView()
} }
@ -157,6 +181,10 @@ Item {
icon.source: "/qmlimages/Analyze.svg" icon.source: "/qmlimages/Analyze.svg"
visible: QGroundControl.corePlugin.showAdvancedUI visible: QGroundControl.corePlugin.showAdvancedUI
onClicked: { onClicked: {
if (mainWindow.preventViewSwitch) {
return
}
buttonRow.clearAllChecks()
checked = true checked = true
mainWindow.showAnalyzeView() mainWindow.showAnalyzeView()
} }

Loading…
Cancel
Save