Skip to content

Commit

Permalink
New QGCPopupDialog rework
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Jan 5, 2022
1 parent 716108f commit 670a12b
Show file tree
Hide file tree
Showing 32 changed files with 822 additions and 854 deletions.
3 changes: 3 additions & 0 deletions UnitTest.qrc
Expand Up @@ -16,4 +16,7 @@
<file alias="PolygonBadCoordinatesNode.kml">src/MissionManager/UnitTest/PolygonBadCoordinatesNode.kml</file>
<file alias="MockLinkOptionsDlg.qml">src/comm/MockLinkOptionsDlg.qml</file>
</qresource>
<qresource prefix="/qml">
<file alias="QGroundControl/Controls/MockLinkOptionsDlg.qml">src/comm/MockLinkOptionsDlg.qml</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion qgroundcontrol.qrc
Expand Up @@ -151,10 +151,10 @@
<file alias="QGroundControl/Controls/QGCMouseArea.qml">src/QmlControls/QGCMouseArea.qml</file>
<file alias="QGroundControl/Controls/QGCMovableItem.qml">src/QmlControls/QGCMovableItem.qml</file>
<file alias="QGroundControl/Controls/QGCPopupDialog.qml">src/QmlControls/QGCPopupDialog.qml</file>
<file alias="QGroundControl/Controls/QGCPopupDialogContainer.qml">src/QmlControls/QGCPopupDialogContainer.qml</file>
<file alias="QGroundControl/Controls/QGCPipOverlay.qml">src/QmlControls/QGCPipOverlay.qml</file>
<file alias="QGroundControl/Controls/QGCPipState.qml">src/QmlControls/QGCPipState.qml</file>
<file alias="QGroundControl/Controls/QGCRadioButton.qml">src/QmlControls/QGCRadioButton.qml</file>
<file alias="QGroundControl/Controls/QGCSimpleMessageDialog.qml">src/QmlControls/QGCSimpleMessageDialog.qml</file>
<file alias="QGroundControl/Controls/QGCSlider.qml">src/QmlControls/QGCSlider.qml</file>
<file alias="QGroundControl/Controls/QGCSwitch.qml">src/QmlControls/QGCSwitch.qml</file>
<file alias="QGroundControl/Controls/QGCTabBar.qml">src/QmlControls/QGCTabBar.qml</file>
Expand Down
80 changes: 44 additions & 36 deletions src/AutoPilotPlugins/Common/RadioComponent.qml
Expand Up @@ -31,8 +31,6 @@ SetupPage {
width: availableWidth
height: Math.max(leftColumn.height, rightColumn.height)

readonly property string dialogTitle: qsTr("Radio")

function setupPageCompleted() {
controller.start()
updateChannelCount()
Expand All @@ -57,57 +55,63 @@ SetupPage {

Component {
id: copyTrimsDialogComponent
QGCViewMessage {
message: qsTr("Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero.")
function accept() {
hideDialog()
controller.copyTrims()
}

QGCSimpleMessageDialog {
title: qsTr("Copy Trims")
text: qsTr("Center your sticks and move throttle all the way down, then press Ok to copy trims. After pressing Ok, reset the trims on your radio back to zero.")
destroyOnClose: true
onAccepted: controller.copyTrims()
}
}

Component {
id: zeroTrimsDialogComponent
QGCViewMessage {
message: qsTr("Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration.\n\n%1").arg(
(QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? "" : qsTr("Please ensure all motor power is disconnected AND all props are removed from the vehicle.")))
function accept() {
hideDialog()
controller.nextButtonClicked()
}

QGCSimpleMessageDialog {
title: qsTr("Zero Trims")
text: qsTr("Before calibrating you should zero all your trims and subtrims. Click Ok to start Calibration.\n\n%1").arg(
(QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ? "" : qsTr("Please ensure all motor power is disconnected AND all props are removed from the vehicle.")))
destroyOnClose: true
onAccepted: controller.nextButtonClicked()
}
}

Component {
id: channelCountDialogComponent
QGCViewMessage {
message: controller.channelCount == 0 ? qsTr("Please turn on transmitter.") : qsTr("%1 channels or more are needed to fly.").arg(controller.minChannelCount)

QGCSimpleMessageDialog {
title: qsTr("Radio Not Ready")
text: controller.channelCount == 0 ? qsTr("Please turn on transmitter.") :
(controller.channelCount < controller.minChannelCount ?
qsTr("%1 channels or more are needed to fly.").arg(controller.minChannelCount) :
qsTr("Ready to calibrate."))
destroyOnClose: true
}
}

Component {
id: spektrumBindDialogComponent
QGCViewDialog {

function accept() {
controller.spektrumBindMode(radioGroup.checkedButton.bindMode)
hideDialog()
}
QGCPopupDialog {
title: qsTr("Spektrum Bind")
buttons: StandardButton.Ok | StandardButton.Cancel
destroyOnClose: true

function reject() {
hideDialog()
}
onAccepted: controller.spektrumBindMode(radioGroup.checkedButton.bindMode)

ButtonGroup { id: radioGroup }

Column {
anchors.fill: parent
spacing: 5
ColumnLayout {
spacing: ScreenTools.defaultFontPixelHeight / 2

QGCLabel {
wrapMode: Text.WordWrap
text: qsTr("Click Ok to place your Spektrum receiver in the bind mode.")
}

QGCLabel {
width: parent.width
wrapMode: Text.WordWrap
text: qsTr("Click Ok to place your Spektrum receiver in the bind mode. Select the specific receiver type below:")
text: qsTr("Select the specific receiver type below:")
}

QGCRadioButton {
Expand All @@ -130,7 +134,7 @@ SetupPage {
}
}
}
} // Component - spektrumBindDialogComponent
}

// Live channel monitor control component
Component {
Expand Down Expand Up @@ -346,7 +350,11 @@ SetupPage {

onClicked: {
if (text === qsTr("Calibrate")) {
mainWindow.showComponentDialog(zeroTrimsDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
if (controller.channelCount < controller.minChannelCount) {
channelCountDialogComponent.createObject(mainWindow).open()
} else {
zeroTrimsDialogComponent.createObject(mainWindow).open()
}
} else {
controller.nextButtonClicked()
}
Expand Down Expand Up @@ -380,8 +388,8 @@ SetupPage {
Repeater {
model: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware ?
(QGroundControl.multiVehicleManager.activeVehicle.multiRotor ?
[ "RC_MAP_AUX1", "RC_MAP_AUX2", "RC_MAP_PARAM1", "RC_MAP_PARAM2", "RC_MAP_PARAM3"] :
[ "RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2", "RC_MAP_PARAM1", "RC_MAP_PARAM2", "RC_MAP_PARAM3"]) :
[ "RC_MAP_AUX1", "RC_MAP_AUX2", "RC_MAP_PARAM1", "RC_MAP_PARAM2", "RC_MAP_PARAM3"] :
[ "RC_MAP_FLAPS", "RC_MAP_AUX1", "RC_MAP_AUX2", "RC_MAP_PARAM1", "RC_MAP_PARAM2", "RC_MAP_PARAM3"]) :
0

RowLayout {
Expand All @@ -406,12 +414,12 @@ SetupPage {
QGCButton {
id: bindButton
text: qsTr("Spektrum Bind")
onClicked: mainWindow.showComponentDialog(spektrumBindDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
onClicked: spektrumBindDialogComponent.createObject(mainWindow).open()
}

QGCButton {
text: qsTr("Copy Trims")
onClicked: mainWindow.showComponentDialog(copyTrimsDialogComponent, dialogTitle, mainWindow.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel)
onClicked: copyTrimsDialogComponent.createObject(mainWindow).open()
}
}
} // Column - Left Column
Expand Down
21 changes: 7 additions & 14 deletions src/AutoPilotPlugins/PX4/AirframeComponent.qml
Expand Up @@ -100,21 +100,14 @@ SetupPage {
Component {
id: applyRestartDialogComponent

QGCViewDialog {
id: applyRestartDialog

function accept() {
controller.changeAutostart()
applyRestartDialog.hideDialog()
}

QGCLabel {
anchors.fill: parent
wrapMode: Text.WordWrap
text: qsTr("Clicking 'Apply' will save the changes you have made to your airframe configuration.<br><br>\
QGCSimpleMessageDialog {
buttons: StandardButton.Apply | StandardButton.Cancel
title: qsTr("Apply and Restart")
text: qsTr("Clicking 'Apply' will save the changes you have made to your airframe configuration.<br><br>\
All vehicle parameters other than Radio Calibration will be reset.<br><br>\
Your vehicle will also be restarted in order to complete the process.")
}
destroyOnClose: true
onAccepted: controller.changeAutostart()
}
}

Expand All @@ -140,7 +133,7 @@ Your vehicle will also be restarted in order to complete the process.")
anchors.right: parent.right
text: qsTr("Apply and Restart")

onClicked: mainWindow.showComponentDialog(applyRestartDialogComponent, qsTr("Apply and Restart"), mainWindow.showDialogDefaultWidth, StandardButton.Apply | StandardButton.Cancel)
onClicked: applyRestartDialogComponent.createObject(mainWindow).open()
}
}

Expand Down
44 changes: 25 additions & 19 deletions src/AutoPilotPlugins/PX4/PowerComponent.qml
Expand Up @@ -58,7 +58,7 @@ SetupPage {
onOldFirmware: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("%1 cannot perform ESC Calibration with this version of firmware. You will need to upgrade to a newer firmware.").arg(QGroundControl.appName))
onNewerFirmware: mainWindow.showMessageDialog(qsTr("ESC Calibration"), qsTr("%1 cannot perform ESC Calibration with this version of firmware. You will need to upgrade %1.").arg(QGroundControl.appName))
onDisconnectBattery: mainWindow.showMessageDialog(qsTr("ESC Calibration failed"), qsTr("You must disconnect the battery prior to performing ESC Calibration. Disconnect your battery and try again."))
onConnectBattery: { var dialog = mainWindow.showPopupDialogFromComponent(escCalibrationDlgComponent); dialog.disableAcceptButton() }
onConnectBattery: escCalibrationDlgComponent.createObject(mainWindow).open()
}

ColumnLayout {
Expand Down Expand Up @@ -327,7 +327,7 @@ SetupPage {
QGCButton {
text: qsTr("Calculate")
visible: battVoltageDividerAvailable
onClicked: mainWindow.showPopupDialogFromComponent(calcVoltageDividerDlgComponent, { batteryIndex: _batteryIndex })
onClicked: calcVoltageDividerDlgComponent.createObject(mainWindow, { batteryIndex: _batteryIndex }).open()
}
Item { width: 1; height: 1; Layout.columnSpan: 2; visible: battVoltageDividerAvailable }

Expand All @@ -351,7 +351,7 @@ SetupPage {
QGCButton {
text: qsTr("Calculate")
visible: battAmpsPerVoltAvailable
onClicked: mainWindow.showPopupDialogFromComponent(calcAmpsPerVoltDlgComponent, { batteryIndex: _batteryIndex })
onClicked: calcAmpsPerVoltDlgComponent.createObject(mainWindow, { batteryIndex: _batteryIndex }).open()
}
Item { width: 1; height: 1; Layout.columnSpan: 2; visible: battAmpsPerVoltAvailable }

Expand Down Expand Up @@ -412,16 +412,18 @@ SetupPage {
id: calcVoltageDividerDlgComponent

QGCPopupDialog {
title: qsTr("Calculate Voltage Divider")
buttons: StandardButton.Close
title: qsTr("Calculate Voltage Divider")
buttons: StandardButton.Close
destroyOnClose: true

property alias batteryIndex: batParams.batteryIndex

property var _controller: controller
property FactGroup _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (dialogProperties.batteryIndex - 1))
property FactGroup _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (batteryIndex - 1))

BatteryParams {
id: batParams
controller: _controller
batteryIndex: dialogProperties.batteryIndex
}

ColumnLayout {
Expand Down Expand Up @@ -461,24 +463,26 @@ SetupPage {
}
}
}
} // Column
} // QGCViewDialog
} // Component - calcVoltageDividerDlgComponent
}
}
}

Component {
id: calcAmpsPerVoltDlgComponent

QGCPopupDialog {
title: qsTr("Calculate Amps per Volt")
buttons: StandardButton.Close
title: qsTr("Calculate Amps per Volt")
buttons: StandardButton.Close
destroyOnClose: true

property alias batteryIndex: batParams.batteryIndex

property var _controller: controller
property FactGroup _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (dialogProperties.batteryIndex - 1))
property FactGroup _batteryFactGroup: controller.vehicle.getFactGroup("battery" + (batteryIndex - 1))

BatteryParams {
id: batParams
controller: _controller
batteryIndex: dialogProperties.batteryIndex
}

ColumnLayout {
Expand Down Expand Up @@ -526,16 +530,18 @@ SetupPage {
id: escCalibrationDlgComponent

QGCPopupDialog {
id: popupDialog
title: qsTr("ESC Calibration")
buttons: StandardButton.Ok
id: escCalibrationDlg
title: qsTr("ESC Calibration")
buttons: StandardButton.Ok
acceptButtonEnabled: false
destroyOnClose: true

Connections {
target: controller

onBatteryConnected: textLabel.text = qsTr("Performing calibration. This will take a few seconds..")
onCalibrationFailed: { popupDialog.enableAcceptButton(); textLabel.text = _highlightPrefix + qsTr("ESC Calibration failed. ") + _highlightSuffix + errorMessage }
onCalibrationSuccess: { popupDialog.enableAcceptButton(); textLabel.text = qsTr("Calibration complete. You can disconnect your battery now if you like.") }
onCalibrationFailed: { escCalibrationDlg.acceptButtonEnabled = true; textLabel.text = _highlightPrefix + qsTr("ESC Calibration failed. ") + _highlightSuffix + errorMessage }
onCalibrationSuccess: { escCalibrationDlg.acceptButtonEnabled = true; textLabel.text = qsTr("Calibration complete. You can disconnect your battery now if you like.") }
}

ColumnLayout {
Expand Down

0 comments on commit 670a12b

Please sign in to comment.