From f7071dfdc97c5849e0f5589ea1f1d57719e2d879 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sun, 3 Jan 2016 09:42:26 -0800 Subject: [PATCH] Standard sizing for QGCView::showDialog --- .../APM/APMAirframeComponent.qml | 2 +- .../APM/APMSensorsComponent.qml | 8 ++--- .../Common/RadioComponent.qml | 32 +++++++++---------- .../PX4/AirframeComponent.qml | 4 +-- .../PX4/FlightModesComponent.qml | 4 +-- src/AutoPilotPlugins/PX4/SensorsComponent.qml | 14 ++++---- src/FactSystem/FactControls/FactTextField.qml | 2 +- src/QmlControls/MissionItemEditor.qml | 4 +-- src/QmlControls/ParameterEditor.qml | 4 +-- src/QmlControls/QGCView.qml | 10 ++++-- src/VehicleSetup/FirmwareUpgrade.qml | 2 +- 11 files changed, 45 insertions(+), 41 deletions(-) diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.qml b/src/AutoPilotPlugins/APM/APMAirframeComponent.qml index 3f15a84c9..30529cc56 100644 --- a/src/AutoPilotPlugins/APM/APMAirframeComponent.qml +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.qml @@ -127,7 +127,7 @@ QGCView { id: applyButton anchors.right: parent.right text: "Load common parameters" - onClicked: showDialog(applyRestartDialogComponent, qsTr("Load common parameters"), 50, StandardButton.Close) + onClicked: showDialog(applyRestartDialogComponent, "Load common parameters", qgcView.showDialogDefaultWidth, StandardButton.Close) } } diff --git a/src/AutoPilotPlugins/APM/APMSensorsComponent.qml b/src/AutoPilotPlugins/APM/APMSensorsComponent.qml index 4efc35791..37e33f39a 100644 --- a/src/AutoPilotPlugins/APM/APMSensorsComponent.qml +++ b/src/AutoPilotPlugins/APM/APMSensorsComponent.qml @@ -34,7 +34,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 QGCView { - id: rootQGCView + id: qgcView viewPanel: panel // Help text which is shown both in the status text area prior to pressing a cal button and in the @@ -157,7 +157,7 @@ QGCView { _postCalibrationDialogParams.push("COMPASS_OFS3_Z") } } - showDialog(postCalibrationDialogComponent, "Calibration complete", 50, StandardButton.Ok) + showDialog(postCalibrationDialogComponent, "Calibration complete", qgcView.showDialogDefaultWidth, StandardButton.Ok) } } @@ -362,7 +362,7 @@ QGCView { } else { preCalibrationDialogType = "compass" preCalibrationDialogHelp = compassHelp - showDialog(preCalibrationDialogComponent, "Calibrate Compass", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Compass", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } } @@ -376,7 +376,7 @@ QGCView { onClicked: { preCalibrationDialogType = "accel" preCalibrationDialogHelp = accelHelp - showDialog(preCalibrationDialogComponent, "Calibrate Accelerometer", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Accelerometer", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } QGCButton { diff --git a/src/AutoPilotPlugins/Common/RadioComponent.qml b/src/AutoPilotPlugins/Common/RadioComponent.qml index fe5a030af..68eb9e5d1 100644 --- a/src/AutoPilotPlugins/Common/RadioComponent.qml +++ b/src/AutoPilotPlugins/Common/RadioComponent.qml @@ -34,7 +34,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 QGCView { - id: rootQGCView + id: qgcView viewPanel: panel QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } @@ -51,7 +51,7 @@ QGCView { FIXME: Turned off for now, since it prevents binding. Need to restructure to allow binding and still check channel count if (controller.channelCount < controller.minChannelCount) { - showDialog(channelCountDialogComponent, dialogTitle, 50, 0) + showDialog(channelCountDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, 0) } else { hideDialog() } @@ -68,7 +68,7 @@ QGCView { Component.onCompleted: { controllerCompleted = true - if (rootQGCView.completedSignalled) { + if (qgcView.completedSignalled) { controllerAndViewReady = true controller.start() updateChannelCount() @@ -283,11 +283,11 @@ QGCView { id: rollLoader anchors.left: rollLabel.right anchors.right: parent.right - height: rootQGCView.defaultTextHeight + height: qgcView.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: rootQGCView.defaultTextWidth + property real defaultTextWidth: qgcView.defaultTextWidth property bool mapped: controller.rollChannelMapped property bool reversed: controller.rollChannelReversed } @@ -313,11 +313,11 @@ QGCView { id: pitchLoader anchors.left: pitchLabel.right anchors.right: parent.right - height: rootQGCView.defaultTextHeight + height: qgcView.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: rootQGCView.defaultTextWidth + property real defaultTextWidth: qgcView.defaultTextWidth property bool mapped: controller.pitchChannelMapped property bool reversed: controller.pitchChannelReversed } @@ -343,11 +343,11 @@ QGCView { id: yawLoader anchors.left: yawLabel.right anchors.right: parent.right - height: rootQGCView.defaultTextHeight + height: qgcView.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: rootQGCView.defaultTextWidth + property real defaultTextWidth: qgcView.defaultTextWidth property bool mapped: controller.yawChannelMapped property bool reversed: controller.yawChannelReversed } @@ -373,11 +373,11 @@ QGCView { id: throttleLoader anchors.left: throttleLabel.right anchors.right: parent.right - height: rootQGCView.defaultTextHeight + height: qgcView.defaultTextHeight width: 100 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: rootQGCView.defaultTextWidth + property real defaultTextWidth: qgcView.defaultTextWidth property bool mapped: controller.throttleChannelMapped property bool reversed: controller.throttleChannelReversed } @@ -418,7 +418,7 @@ QGCView { onClicked: { if (text == "Calibrate") { - showDialog(zeroTrimsDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + showDialog(zeroTrimsDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } else { controller.nextButtonClicked() } @@ -460,7 +460,7 @@ QGCView { showBorder: true text: "Spektrum Bind" - onClicked: showDialog(spektrumBindDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + onClicked: showDialog(spektrumBindDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } } @@ -468,7 +468,7 @@ QGCView { showBorder: true text: "Copy Trims" visible: QGroundControl.multiVehicleManager.activeVehicle.px4Firmware - onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, 50, StandardButton.Ok | StandardButton.Cancel) + onClicked: showDialog(copyTrimsDialogComponent, dialogTitle, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } } // Column - Left Column @@ -552,11 +552,11 @@ QGCView { Loader { id: theLoader anchors.verticalCenter: channelLabel.verticalCenter - height: rootQGCView.defaultTextHeight + height: qgcView.defaultTextHeight width: 200 sourceComponent: channelMonitorDisplayComponent - property real defaultTextWidth: rootQGCView.defaultTextWidth + property real defaultTextWidth: qgcView.defaultTextWidth property bool mapped: true readonly property bool reversed: false } diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index 0bff1ddd8..69c63f699 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -67,7 +67,7 @@ QGCView { Component.onCompleted: { if (controller.showCustomConfigPanel) { - showDialog(customConfigDialogComponent, "Custom Airframe Config", 50, StandardButton.Reset) + showDialog(customConfigDialogComponent, "Custom Airframe Config", qgcView.showDialogDefaultWidth, StandardButton.Reset) } } } @@ -138,7 +138,7 @@ QGCView { anchors.right: parent.right text: "Apply and Restart" - onClicked: showDialog(applyRestartDialogComponent, "Apply and Restart", 50, StandardButton.Apply | StandardButton.Cancel) + onClicked: showDialog(applyRestartDialogComponent, "Apply and Restart", qgcView.showDialogDefaultWidth, StandardButton.Apply | StandardButton.Cancel) } } diff --git a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml index a4b643cbe..d63a3edcf 100644 --- a/src/AutoPilotPlugins/PX4/FlightModesComponent.qml +++ b/src/AutoPilotPlugins/PX4/FlightModesComponent.qml @@ -35,7 +35,7 @@ import QGroundControl.Controllers 1.0 import QGroundControl.ScreenTools 1.0 QGCView { - id: rootQGCView + id: qgcView viewPanel: panel readonly property int monitorThresholdCharWidth: 8 // Character width of Monitor and Threshold labels @@ -138,7 +138,7 @@ QGCView { onTriggered: { recalcModePositions() if (rcInMode.value == 1) { - showDialog(joystickEnabledDialogComponent, title, 50, 0) + showDialog(joystickEnabledDialogComponent, title, qgcView.showDialogDefaultWidth, 0) } } } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index 7fc5ac494..c6f74b770 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -34,7 +34,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 QGCView { - id: rootQGCView + id: qgcView viewPanel: panel // Help text which is shown both in the status text area prior to pressing a cal button and in the @@ -130,7 +130,7 @@ QGCView { onSetCompassRotations: { if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { - showDialog(compassRotationDialogComponent, "Set Compass Rotation(s)", 50, StandardButton.Ok) + showDialog(compassRotationDialogComponent, "Set Compass Rotation(s)", qgcView.showDialogDefaultWidth, StandardButton.Ok) } } @@ -295,7 +295,7 @@ QGCView { onClicked: { preCalibrationDialogType = "compass" preCalibrationDialogHelp = compassHelp - showDialog(preCalibrationDialogComponent, "Calibrate Compass", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Compass", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } @@ -308,7 +308,7 @@ QGCView { onClicked: { preCalibrationDialogType = "gyro" preCalibrationDialogHelp = gyroHelp - showDialog(preCalibrationDialogComponent, "Calibrate Gyro", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Gyro", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } @@ -321,7 +321,7 @@ QGCView { onClicked: { preCalibrationDialogType = "accel" preCalibrationDialogHelp = accelHelp - showDialog(preCalibrationDialogComponent, "Calibrate Accelerometer", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Accelerometer", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } @@ -335,7 +335,7 @@ QGCView { onClicked: { preCalibrationDialogType = "level" preCalibrationDialogHelp = levelHelp - showDialog(preCalibrationDialogComponent, "Level Horizon", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Level Horizon", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } @@ -349,7 +349,7 @@ QGCView { onClicked: { preCalibrationDialogType = "airspeed" preCalibrationDialogHelp = airspeedHelp - showDialog(preCalibrationDialogComponent, "Calibrate Airspeed", 50, StandardButton.Cancel | StandardButton.Ok) + showDialog(preCalibrationDialogComponent, "Calibrate Airspeed", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Ok) } } diff --git a/src/FactSystem/FactControls/FactTextField.qml b/src/FactSystem/FactControls/FactTextField.qml index aa7050a0e..e22416945 100644 --- a/src/FactSystem/FactControls/FactTextField.qml +++ b/src/FactSystem/FactControls/FactTextField.qml @@ -29,7 +29,7 @@ QGCTextField { fact.value = text } else { _validateString = text - qgcView.showDialog(editorDialogComponent, "Invalid Parameter Value", 50, StandardButton.Save) + qgcView.showDialog(editorDialogComponent, "Invalid Parameter Value", qgcView.showDialogDefaultWidth, StandardButton.Save) } } else { fact.value = text diff --git a/src/QmlControls/MissionItemEditor.qml b/src/QmlControls/MissionItemEditor.qml index 5fc35af69..d4eb9c4bd 100644 --- a/src/QmlControls/MissionItemEditor.qml +++ b/src/QmlControls/MissionItemEditor.qml @@ -95,7 +95,7 @@ Rectangle { MenuItem { text: "Delete all" - onTriggered: qgcView.showDialog(deleteAllPromptDialog, "Delete all", 40, StandardButton.Yes | StandardButton.No) + onTriggered: qgcView.showDialog(deleteAllPromptDialog, "Delete all", qgcView.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No) } MenuSeparator { } @@ -139,7 +139,7 @@ Rectangle { } } - onClicked: qgcView.showDialog(commandDialog, "Select Mission Command", 40, StandardButton.Cancel) + onClicked: qgcView.showDialog(commandDialog, "Select Mission Command", qgcView.showDialogDefaultWidth, StandardButton.Cancel) } QGCLabel { diff --git a/src/QmlControls/ParameterEditor.qml b/src/QmlControls/ParameterEditor.qml index 0b0bb79da..f5def04c6 100644 --- a/src/QmlControls/ParameterEditor.qml +++ b/src/QmlControls/ParameterEditor.qml @@ -119,7 +119,7 @@ QGCView { } MenuItem { text: "Search..." - onTriggered: showDialog(searchDialogComponent, "Parameter Search", 50, StandardButton.Reset | StandardButton.Apply) + onTriggered: showDialog(searchDialogComponent, "Parameter Search", panel.showDialogDefaultWidth, StandardButton.Reset | StandardButton.Apply) } MenuSeparator { visible: !ScreenTools.isMobile } MenuItem { @@ -314,7 +314,7 @@ QGCView { acceptedButtons: Qt.LeftButton onClicked: { __editorDialogFact = factRow.modelFact - showDialog(editorDialogComponent, "Parameter Editor", 50, StandardButton.Cancel | StandardButton.Save) + showDialog(editorDialogComponent, "Parameter Editor", qgcView.showDialogDefaultWidth, StandardButton.Cancel | StandardButton.Save) } } } diff --git a/src/QmlControls/QGCView.qml b/src/QmlControls/QGCView.qml index 199456e99..432a629fb 100644 --- a/src/QmlControls/QGCView.qml +++ b/src/QmlControls/QGCView.qml @@ -128,8 +128,12 @@ FactPanel { /// Shows a QGCViewDialog component /// @param compoent QGCViewDialog component /// @param title Title for dialog - /// @param charWidth Width of dialog in characters (-1 for full parent width) + /// @param charWidth Width of dialog in characters /// @param buttons Buttons to show in dialog using StandardButton enum + + readonly property int showDialogFullWidth: -1 ///< Use for full width dialog + readonly property int showDialogDefaultWidth: 40 ///< Use for default dialog width + function showDialog(component, title, charWidth, buttons) { if (__checkForEarlyDialog(title)) { return @@ -158,7 +162,7 @@ FactPanel { __stopAllAnimations() - __dialogCharWidth = 50 + __dialogCharWidth = showDialogDefaultWidth __dialogTitle = title __messageDialogText = message @@ -285,7 +289,7 @@ FactPanel { // This is the main dialog panel which is anchored to the right edge Rectangle { id: __dialogPanel - width: __dialogCharWidth == -1 ? parent.width : defaultTextWidth * __dialogCharWidth + width: __dialogCharWidth == showDialogFullWidth ? parent.width : defaultTextWidth * __dialogCharWidth anchors.topMargin: topDialogMargin anchors.top: parent.top anchors.bottom: parent.bottom diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 11dc82a93..78f8bdff3 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -109,7 +109,7 @@ QGCView { // We end up here when we detect a board plugged in after we've started upgrade statusTextArea.append(highlightPrefix + "Found device" + highlightSuffix + ": " + controller.boardType) if (controller.boardType == "Pixhawk" || controller.boardType == "AeroCore" || controller.boardType == "PX4 Flow" || controller.boardType == "PX4 FMU V1") { - showDialog(pixhawkFirmwareSelectDialog, title, 50, StandardButton.Ok | StandardButton.Cancel) + showDialog(pixhawkFirmwareSelectDialog, title, qgcView.showDialogDefaultWidth, StandardButton.Ok | StandardButton.Cancel) } } } -- 2.22.0