From f11e9c6e41dcf8894dc26fe4501e93ea88bda9a1 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 5 Mar 2016 18:57:11 +0100 Subject: [PATCH] LP-29 expose PfdContext to Qml as "pfdContext" instead of "qmlWidget" --- ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp | 2 +- ground/gcs/src/share/qml/EarthView.qml | 4 ++-- ground/gcs/src/share/qml/ModelView.qml | 2 +- ground/gcs/src/share/qml/Pfd.qml | 4 ++-- ground/gcs/src/share/qml/common.js | 4 ++-- ground/gcs/src/share/qml/model/ModelTerrainView.qml | 6 +++--- ground/gcs/src/share/qml/model/ModelView.qml | 4 ++-- ground/gcs/src/share/qml/pfd/AltitudeScale.qml | 12 ++++++------ ground/gcs/src/share/qml/pfd/Info.qml | 6 +++--- ground/gcs/src/share/qml/pfd/Panels.qml | 4 ++-- ground/gcs/src/share/qml/pfd/PfdTerrainView.qml | 4 ++-- ground/gcs/src/share/qml/pfd/SpeedScale.qml | 12 ++++++------ ground/gcs/src/share/qml/pfd/VsiScale.qml | 6 +++--- ground/gcs/src/share/qml/uav.js | 2 +- 14 files changed, 36 insertions(+), 36 deletions(-) diff --git a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp index e1a316c9c..08021b8ee 100644 --- a/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp +++ b/ground/gcs/src/plugins/pfdqml/pfdqmlcontext.cpp @@ -329,5 +329,5 @@ void PfdQmlContext::apply(QQmlContext *context) } // to expose settings values - context->setContextProperty("qmlWidget", this); + context->setContextProperty("pfdContext", this); } diff --git a/ground/gcs/src/share/qml/EarthView.qml b/ground/gcs/src/share/qml/EarthView.qml index 767a4f9f4..97cd5cc88 100644 --- a/ground/gcs/src/share/qml/EarthView.qml +++ b/ground/gcs/src/share/qml/EarthView.qml @@ -35,12 +35,12 @@ Item { id: skyNode sceneData: terrainNode dateTime: Utils.getDateTime() - minimumAmbientLight: qmlWidget.minimumAmbientLight + minimumAmbientLight: pfdContext.minimumAmbientLight } OSGFileNode { id: terrainNode - source: qmlWidget.terrainFile + source: pfdContext.terrainFile async: false } diff --git a/ground/gcs/src/share/qml/ModelView.qml b/ground/gcs/src/share/qml/ModelView.qml index 9f61fbdc5..24b41786d 100644 --- a/ground/gcs/src/share/qml/ModelView.qml +++ b/ground/gcs/src/share/qml/ModelView.qml @@ -23,6 +23,6 @@ Item { Loader { anchors.fill: parent focus: true - source: qmlWidget.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml" + source: pfdContext.terrainEnabled ? "model/ModelTerrainView.qml" : "model/ModelView.qml" } } \ No newline at end of file diff --git a/ground/gcs/src/share/qml/Pfd.qml b/ground/gcs/src/share/qml/Pfd.qml index 542831688..8e007dd01 100644 --- a/ground/gcs/src/share/qml/Pfd.qml +++ b/ground/gcs/src/share/qml/Pfd.qml @@ -61,7 +61,7 @@ Rectangle { id: worldLoader anchors.fill: parent focus: true - source: qmlWidget.terrainEnabled ? "pfd/PfdTerrainView.qml" : "pfd/PfdWorldView.qml" + source: pfdContext.terrainEnabled ? "pfd/PfdTerrainView.qml" : "pfd/PfdWorldView.qml" } Pfd.HorizontCenter { @@ -103,7 +103,7 @@ Rectangle { Pfd.VsiScale { anchors.fill: parent sceneSize: sceneItem.viewportSize - visible: qmlWidget.altitudeUnit != 0 + visible: pfdContext.altitudeUnit != 0 } Pfd.Info { diff --git a/ground/gcs/src/share/qml/common.js b/ground/gcs/src/share/qml/common.js index af2f461ed..8fdacd345 100644 --- a/ground/gcs/src/share/qml/common.js +++ b/ground/gcs/src/share/qml/common.js @@ -24,11 +24,11 @@ // Get date function getDateTime() { - switch(qmlWidget.timeMode) { + switch(pfdContext.timeMode) { case TimeMode.Local: return new Date(); case TimeMode.Predefined: - return qmlWidget.dateTime; + return pfdContext.dateTime; } } diff --git a/ground/gcs/src/share/qml/model/ModelTerrainView.qml b/ground/gcs/src/share/qml/model/ModelTerrainView.qml index 573c6ffdc..108edd0fd 100644 --- a/ground/gcs/src/share/qml/model/ModelTerrainView.qml +++ b/ground/gcs/src/share/qml/model/ModelTerrainView.qml @@ -35,7 +35,7 @@ OSGViewport { id: skyNode sceneData: sceneGroup dateTime: Utils.getDateTime() - minimumAmbientLight: qmlWidget.minimumAmbientLight + minimumAmbientLight: pfdContext.minimumAmbientLight } OSGGroup { @@ -45,7 +45,7 @@ OSGViewport { OSGFileNode { id: terrainNode - source: qmlWidget.terrainFile + source: pfdContext.terrainFile async: false } @@ -68,7 +68,7 @@ OSGViewport { OSGFileNode { id: modelFileNode - source: qmlWidget.modelFile + source: pfdContext.modelFile async: false optimizeMode: OptimizeMode.OptimizeAndCheck } diff --git a/ground/gcs/src/share/qml/model/ModelView.qml b/ground/gcs/src/share/qml/model/ModelView.qml index 1d26cec70..94e9292b2 100644 --- a/ground/gcs/src/share/qml/model/ModelView.qml +++ b/ground/gcs/src/share/qml/model/ModelView.qml @@ -41,7 +41,7 @@ Item { OSGBackgroundNode { id: backgroundNode - imageFile: qmlWidget.backgroundImageFile + imageFile: pfdContext.backgroundImageFile } OSGTransformNode { @@ -52,7 +52,7 @@ Item { OSGFileNode { id: fileNode - source: qmlWidget.modelFile + source: pfdContext.modelFile async: false optimizeMode: OptimizeMode.OptimizeAndCheck } diff --git a/ground/gcs/src/share/qml/pfd/AltitudeScale.qml b/ground/gcs/src/share/qml/pfd/AltitudeScale.qml index cc0bf360e..3fb9adbf7 100644 --- a/ground/gcs/src/share/qml/pfd/AltitudeScale.qml +++ b/ground/gcs/src/share/qml/pfd/AltitudeScale.qml @@ -26,7 +26,7 @@ Item { id: sceneItem property variant sceneSize - property real altitude : -qmlWidget.altitudeFactor * UAV.positionStateDown() + property real altitude : -pfdContext.altitudeFactor * UAV.positionStateDown() SvgElementImage { id: altitude_window @@ -34,7 +34,7 @@ Item { sceneSize: sceneItem.sceneSize clip: true - visible: qmlWidget.altitudeUnit != 0 + visible: pfdContext.altitudeUnit != 0 property variant scaledBounds: svgRenderer.scaledElementBounds("pfd/pfd.svg", "altitude-window") @@ -98,7 +98,7 @@ Item { anchors.verticalCenter: parent.verticalCenter anchors.verticalCenterOffset: -altitude_scale.height / 10 * - (UAV.positionStateDown() - UAV.pathDesiredEndDown()) * qmlWidget.altitudeFactor + (UAV.positionStateDown() - UAV.pathDesiredEndDown()) * pfdContext.altitudeFactor } } @@ -106,7 +106,7 @@ Item { id: altitude_box clip: true - visible: qmlWidget.altitudeUnit != 0 + visible: pfdContext.altitudeUnit != 0 elementName: "altitude-box" sceneSize: sceneItem.sceneSize @@ -136,7 +136,7 @@ Item { elementName: "altitude-unit-box" sceneSize: sceneItem.sceneSize - visible: qmlWidget.altitudeUnit != 0 + visible: pfdContext.altitudeUnit != 0 anchors.top: altitude_window.bottom anchors.right: altitude_window.right @@ -145,7 +145,7 @@ Item { Text { id: altitude_unit_text - text: qmlWidget.altitudeUnit + text: pfdContext.altitudeUnit color: "cyan" font { family: pt_bold.name diff --git a/ground/gcs/src/share/qml/pfd/Info.qml b/ground/gcs/src/share/qml/pfd/Info.qml index c8d634b16..9fae25d24 100644 --- a/ground/gcs/src/share/qml/pfd/Info.qml +++ b/ground/gcs/src/share/qml/pfd/Info.qml @@ -62,7 +62,7 @@ Item { sceneSize: info.sceneSize elementName: "info-bg" width: parent.width - opacity: qmlWidget.terrainEnabled ? 0.3 : 1 + opacity: pfdContext.terrainEnabled ? 0.3 : 1 } // @@ -374,7 +374,7 @@ Item { id: reset_consumed_energy_mouseArea; anchors.fill: parent; cursorShape: Qt.PointingHandCursor; - onClicked: qmlWidget.resetConsumedEnergy(); + onClicked: pfdContext.resetConsumedEnergy(); } // Alarm based on estimatedFlightTime < 120s orange, < 60s red @@ -452,7 +452,7 @@ Item { x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) - opacity: qmlWidget.terrainEnabled ? 0.6 : 1 + opacity: pfdContext.terrainEnabled ? 0.6 : 1 states: State { name: "fading" diff --git a/ground/gcs/src/share/qml/pfd/Panels.qml b/ground/gcs/src/share/qml/pfd/Panels.qml index 7a3b86826..e433bc2e7 100644 --- a/ground/gcs/src/share/qml/pfd/Panels.qml +++ b/ground/gcs/src/share/qml/pfd/Panels.qml @@ -541,7 +541,7 @@ Item { anchors.fill: parent; cursorShape: Qt.PointingHandCursor; visible: display_bat == true ? 1 : 0 - onClicked: qmlWidget.resetConsumedEnergy(); + onClicked: pfdContext.resetConsumedEnergy(); } // Alarm based on estimatedFlightTime < 120s orange, < 60s red @@ -598,7 +598,7 @@ Item { anchors.fill: parent; cursorShape: Qt.PointingHandCursor; visible: display_bat == true ? 1 : 0 - onClicked: qmlWidget.resetConsumedEnergy(); + onClicked: pfdContext.resetConsumedEnergy(); } // Alarm based on estimatedFlightTime < 120s orange, < 60s red diff --git a/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml b/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml index a3c567be3..a9e8ffc15 100644 --- a/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml +++ b/ground/gcs/src/share/qml/pfd/PfdTerrainView.qml @@ -45,12 +45,12 @@ OSGViewport { id: skyNode sceneData: terrainNode dateTime: Utils.getDateTime() - minimumAmbientLight: qmlWidget.minimumAmbientLight + minimumAmbientLight: pfdContext.minimumAmbientLight } OSGFileNode { id: terrainNode - source: qmlWidget.terrainFile + source: pfdContext.terrainFile async: false } diff --git a/ground/gcs/src/share/qml/pfd/SpeedScale.qml b/ground/gcs/src/share/qml/pfd/SpeedScale.qml index 7d4110efb..0b80e4241 100644 --- a/ground/gcs/src/share/qml/pfd/SpeedScale.qml +++ b/ground/gcs/src/share/qml/pfd/SpeedScale.qml @@ -24,7 +24,7 @@ import "../uav.js" as UAV Item { id: sceneItem property variant sceneSize - property real groundSpeed : qmlWidget.speedFactor * UAV.currentVelocity() + property real groundSpeed : pfdContext.speedFactor * UAV.currentVelocity() SvgElementImage { id: speed_window @@ -32,7 +32,7 @@ Item { sceneSize: sceneItem.sceneSize clip: true - visible: qmlWidget.speedUnit != 0 + visible: pfdContext.speedUnit != 0 x: Math.floor(scaledBounds.x * sceneItem.width) y: Math.floor(scaledBounds.y * sceneItem.height) @@ -88,7 +88,7 @@ Item { anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter - anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (UAV.pathDesiredEndingVelocity() * qmlWidget.speedFactor)) + anchors.verticalCenterOffset: speed_scale.height / 10 * (sceneItem.groundSpeed - (UAV.pathDesiredEndingVelocity() * pfdContext.speedFactor)) } } @@ -98,7 +98,7 @@ Item { elementName: "speed-box" sceneSize: sceneItem.sceneSize - visible: qmlWidget.speedUnit != 0 + visible: pfdContext.speedUnit != 0 x: scaledBounds.x * sceneItem.width y: scaledBounds.y * sceneItem.height @@ -123,7 +123,7 @@ Item { elementName: "speed-unit-box" sceneSize: sceneItem.sceneSize - visible: qmlWidget.speedUnit != 0 + visible: pfdContext.speedUnit != 0 anchors.top: speed_window.bottom anchors.right: speed_window.right @@ -132,7 +132,7 @@ Item { Text { id: speed_unit_text - text: qmlWidget.speedUnit + text: pfdContext.speedUnit color: "cyan" font { family: pt_bold.name diff --git a/ground/gcs/src/share/qml/pfd/VsiScale.qml b/ground/gcs/src/share/qml/pfd/VsiScale.qml index d86a3c839..0aef9b2b5 100644 --- a/ground/gcs/src/share/qml/pfd/VsiScale.qml +++ b/ground/gcs/src/share/qml/pfd/VsiScale.qml @@ -56,7 +56,7 @@ Item { SvgElementImage { id: vsi_scale_meter - visible: (qmlWidget.altitudeUnit == "m") + visible: (pfdContext.altitudeUnit == "m") elementName: "vsi-scale-meter" sceneSize: sceneItem.sceneSize @@ -68,7 +68,7 @@ Item { SvgElementImage { id: vsi_scale_ft - visible: (qmlWidget.altitudeUnit == "ft") + visible: (pfdContext.altitudeUnit == "ft") elementName: "vsi-scale-ft" sceneSize: sceneItem.sceneSize @@ -104,7 +104,7 @@ Item { sceneSize: sceneItem.sceneSize Text { - text: (qmlWidget.altitudeUnit == "m") ? "m/s" : "ft/s" + text: (pfdContext.altitudeUnit == "m") ? "m/s" : "ft/s" color: "cyan" font { family: pt_bold.name diff --git a/ground/gcs/src/share/qml/uav.js b/ground/gcs/src/share/qml/uav.js index c9645a077..922027b05 100644 --- a/ground/gcs/src/share/qml/uav.js +++ b/ground/gcs/src/share/qml/uav.js @@ -139,7 +139,7 @@ function homePosition() { } function defaultPosition() { - return Qt.vector3d(qmlWidget.longitude, qmlWidget.latitude, qmlWidget.altitude); + return Qt.vector3d(pfdContext.longitude, pfdContext.latitude, pfdContext.altitude); } /*