diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 9fe698a3fc06e95b985471a41fd3c0f7956a369a..36e85ae3ce060deb9fa36e2726bb7d40df7c6a6a 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -125,8 +125,8 @@ src/FlightMap/Widgets/QGCAttitudeHUD.qml src/FlightMap/Widgets/QGCAttitudeWidget.qml src/FlightMap/Widgets/QGCCompassWidget.qml - src/FlightMap/Widgets/QGCInstrumentWidget.qml - src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml + src/FlightMap/Widgets/QGCInstrumentWidget.qml + src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml src/MissionEditor/QGCMapPolygonControls.qml src/FlightMap/Widgets/QGCPitchIndicator.qml src/FlightMap/QGCVideoBackground.qml diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index ec47cffb248187a9435c59786a304b2850f955b7..473136265efaba6c82855a1fe71487c286d92425 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -33,25 +33,14 @@ QGCView { QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property bool _mainIsMap: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_mainIsMapKey, true) : true property bool _isPipVisible: QGroundControl.videoManager.hasVideo ? QGroundControl.loadBoolGlobalSetting(_PIPVisibleKey, true) : false - - property real _roll: _activeVehicle ? _activeVehicle.roll.value : _defaultRoll - property real _pitch: _activeVehicle ? _activeVehicle.pitch.value : _defaultPitch - property real _heading: _activeVehicle ? _activeVehicle.heading.value : _defaultHeading - - property Fact _emptyFact: Fact { } - property Fact _groundSpeedFact: _activeVehicle ? _activeVehicle.groundSpeed : _emptyFact - property Fact _airSpeedFact: _activeVehicle ? _activeVehicle.airSpeed : _emptyFact - - property bool activeVehicleJoystickEnabled: _activeVehicle ? _activeVehicle.joystickEnabled : false - - property real _savedZoomLevel: 0 - property real _margins: ScreenTools.defaultFontPixelWidth / 2 - - - property real pipSize: mainWindow.width * 0.2 + property real _savedZoomLevel: 0 + property real _margins: ScreenTools.defaultFontPixelWidth / 2 + property real _pipSize: mainWindow.width * 0.2 readonly property bool isBackgroundDark: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true readonly property real _defaultRoll: 0 @@ -136,8 +125,8 @@ QGCView { anchors.left: _panel.left anchors.bottom: _panel.bottom visible: _mainIsMap || _isPipVisible - width: _mainIsMap ? _panel.width : pipSize - height: _mainIsMap ? _panel.height : pipSize * (9/16) + width: _mainIsMap ? _panel.width : _pipSize + height: _mainIsMap ? _panel.height : _pipSize * (9/16) states: [ State { name: "pipMode" @@ -166,8 +155,8 @@ QGCView { Item { id: _flightVideo z: _mainIsMap ? _panel.z + 2 : _panel.z + 1 - width: !_mainIsMap ? _panel.width : pipSize - height: !_mainIsMap ? _panel.height : pipSize * (9/16) + width: !_mainIsMap ? _panel.width : _pipSize + height: !_mainIsMap ? _panel.height : _pipSize * (9/16) anchors.left: _panel.left anchors.bottom: _panel.bottom visible: QGroundControl.videoManager.hasVideo && (!_mainIsMap || _isPipVisible) @@ -204,8 +193,8 @@ QGCView { QGCPipable { id: _flightVideoPipControl z: _flightVideo.z + 3 - width: pipSize - height: pipSize * (9/16) + width: _pipSize + height: _pipSize * (9/16) anchors.left: _panel.left anchors.bottom: _panel.bottom anchors.margins: ScreenTools.defaultFontPixelHeight diff --git a/src/FlightDisplay/FlightDisplayViewVideo.qml b/src/FlightDisplay/FlightDisplayViewVideo.qml index 2b82520948f95229ad601ed5dd3d44af33c716e5..86d08aff747a1088ef63406745d42ee64695f667 100644 --- a/src/FlightDisplay/FlightDisplayViewVideo.qml +++ b/src/FlightDisplay/FlightDisplayViewVideo.qml @@ -45,8 +45,8 @@ Item { QGCAttitudeHUD { id: attitudeHUD visible: !_mainIsMap - rollAngle: _roll - pitchAngle: _pitch + rollAngle: _activeVehicle ? _activeVehicle.roll.value : 0 + pitchAngle: _activeVehicle ? _activeVehicle.pitch.value : 0 width: ScreenTools.defaultFontPixelHeight * (30) height: ScreenTools.defaultFontPixelHeight * (30) active: QGroundControl.multiVehicleManager.activeVehicleAvailable diff --git a/src/FlightDisplay/FlightDisplayViewWidgets.qml b/src/FlightDisplay/FlightDisplayViewWidgets.qml index 9743c72f3a25f454963d2931f8b923d8cd496a04..4654da7ba47050ad414a8fd9f524f1793fc02f0d 100644 --- a/src/FlightDisplay/FlightDisplayViewWidgets.qml +++ b/src/FlightDisplay/FlightDisplayViewWidgets.qml @@ -25,22 +25,21 @@ import QGroundControl.FlightMap 1.0 Item { id: _root - property alias guidedModeBar: _guidedModeBar - property bool gotoEnabled: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying + property alias guidedModeBar: _guidedModeBar + property bool gotoEnabled: _activeVehicle && _activeVehicle.guidedMode && _activeVehicle.flying property var qgcView property bool isBackgroundDark - property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle - property bool _isSatellite: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true - property bool _lightWidgetBorders: _isSatellite - property bool _useAlternateInstruments: QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property bool _isSatellite: _mainIsMap ? (_flightMap ? _flightMap.isSatelliteMap : true) : true + property bool _lightWidgetBorders: _isSatellite - readonly property real _margins: ScreenTools.defaultFontPixelHeight / 2 + readonly property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 QGCMapPalette { id: mapPal; lightColors: isBackgroundDark } - QGCPalette { id: qgcPal } + QGCPalette { id: qgcPal } - function getGadgetWidth() { + function getPreferredInstrumentWidth() { if(ScreenTools.isMobile) { return ScreenTools.isTinyScreen ? mainWindow.width * 0.2 : mainWindow.width * 0.15 } @@ -48,6 +47,28 @@ Item { return Math.min(w, 200) } + function _setInstrumentWidget() { + var useAlternateInstruments = QGroundControl.virtualTabletJoystick || ScreenTools.isTinyScreen + if(useAlternateInstruments) { + instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidgetAlternate.qml" + instrumentsLoader.state = "topMode" + } else { + instrumentsLoader.source = "qrc:/qml/QGCInstrumentWidget.qml" + instrumentsLoader.state = "centerMode" + } + } + + Connections { + target: QGroundControl + onVirtualTabletJoystickChanged: { + _setInstrumentWidget() + } + } + + Component.onCompleted: { + _setInstrumentWidget() + } + //-- Map warnings Column { anchors.horizontalCenter: parent.horizontalCenter @@ -74,54 +95,33 @@ Item { } //-- Instrument Panel - QGCInstrumentWidget { - id: instrumentGadget - anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right - anchors.verticalCenter: parent.verticalCenter - visible: !_useAlternateInstruments - size: getGadgetWidth() - heading: _heading - rollAngle: _roll - pitchAngle: _pitch - groundSpeedFact: _groundSpeedFact - airSpeedFact: _airSpeedFact - lightBorders: _lightWidgetBorders - z: QGroundControl.zOrderWidgets - qgcView: _root.qgcView - maxHeight: parent.height - (anchors.margins * 2) - } - - QGCInstrumentWidgetAlternate { - id: instrumentGadgetAlternate + Loader { + id: instrumentsLoader anchors.margins: ScreenTools.defaultFontPixelHeight / 2 - anchors.top: parent.top anchors.right: altitudeSlider.visible ? altitudeSlider.left : parent.right - visible: _useAlternateInstruments - width: ScreenTools.isTinyScreen ? getGadgetWidth() * 1.5 : getGadgetWidth() - heading: _heading - rollAngle: _roll - pitchAngle: _pitch - groundSpeedFact: _groundSpeedFact - airSpeedFact: _airSpeedFact - lightBorders: _lightWidgetBorders - qgcView: _root.qgcView - maxHeight: parent.height - (anchors.margins * 2) z: QGroundControl.zOrderWidgets + property var qgcView: _root.qgcView + property real maxHeight:parent.height - (anchors.margins * 2) + states: [ + State { + name: "topMode" + AnchorChanges { + target: instrumentsLoader + anchors.verticalCenter: undefined + anchors.top: _root ? _root.top : undefined + } + }, + State { + name: "centerMode" + AnchorChanges { + target: instrumentsLoader + anchors.top: undefined + anchors.verticalCenter: _root ? _root.verticalCenter : undefined + } + } + ] } - /* - ValuesWidget { - anchors.topMargin: ScreenTools.defaultFontPixelHeight - anchors.top: instrumentGadgetAlternate.bottom - anchors.horizontalCenter: instrumentGadgetAlternate.horizontalCenter - width: getGadgetWidth() - qgcView: _root.qgcView - textColor: _isSatellite ? "white" : "black" - visible: _useAlternateInstruments - maxHeight: virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.y - y : parent.height - anchors.margins - y - }*/ - //-- Guided mode buttons Rectangle { id: _guidedModeBar @@ -131,7 +131,7 @@ Item { width: guidedModeColumn.width + (_margins * 2) height: guidedModeColumn.height + (_margins * 2) radius: ScreenTools.defaultFontPixelHeight * 0.25 - color: _lightWidgetBorders ? Qt.rgba(qgcPal.mapWidgetBorderLight.r, qgcPal.mapWidgetBorderLight.g, qgcPal.mapWidgetBorderLight.b, 0.8) : Qt.rgba(qgcPal.mapWidgetBorderDark.r, qgcPal.mapWidgetBorderDark.g, qgcPal.mapWidgetBorderDark.b, 0.75) + color: _isSatellite ? Qt.rgba(qgcPal.mapWidgetBorderLight.r, qgcPal.mapWidgetBorderLight.g, qgcPal.mapWidgetBorderLight.b, 0.8) : Qt.rgba(qgcPal.mapWidgetBorderDark.r, qgcPal.mapWidgetBorderDark.g, qgcPal.mapWidgetBorderDark.b, 0.75) visible: _activeVehicle z: QGroundControl.zOrderWidgets state: "Shown" @@ -303,7 +303,7 @@ Item { QGCLabel { anchors.horizontalCenter: parent.horizontalCenter - color: _lightWidgetBorders ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight + color: _isSatellite ? qgcPal.mapWidgetBorderDark : qgcPal.mapWidgetBorderLight text: "Click in map to move vehicle" visible: gotoEnabled } diff --git a/src/FlightDisplay/MultiVehicleList.qml b/src/FlightDisplay/MultiVehicleList.qml index 9278056d6753451436fb36fdc7367132708fafc3..a266bf0b6dd13f9a79f990f63ff70395bec336d0 100644 --- a/src/FlightDisplay/MultiVehicleList.qml +++ b/src/FlightDisplay/MultiVehicleList.qml @@ -52,15 +52,12 @@ QGCListView { QGCCompassWidget { size: _widgetHeight - heading: _vehicle.heading.rawValue vehicle: _vehicle } QGCAttitudeWidget { size: _widgetHeight - active: true - rollAngle: _vehicle.roll.rawValue - pitchAngle: _vehicle.pitch.rawValue + vehicle: _vehicle } } diff --git a/src/FlightMap/Widgets/QGCAttitudeWidget.qml b/src/FlightMap/Widgets/QGCAttitudeWidget.qml index 9f252926c279848ac948e47d92c266403dedb968..b3358db3d0d486949fefc25933b34140213480d6 100644 --- a/src/FlightMap/Widgets/QGCAttitudeWidget.qml +++ b/src/FlightMap/Widgets/QGCAttitudeWidget.qml @@ -17,22 +17,18 @@ import QtQuick 2.4 import QtGraphicalEffects 1.0 +import QGroundControl 1.0 import QGroundControl.Controls 1.0 Item { id: root - property bool active: false ///< true: actively connected to data provider, false: show inactive control - property real rollAngle : _defaultRollAngle - property real pitchAngle: _defaultPitchAngle property bool showPitch: true + property var vehicle: null property real size - readonly property real _defaultRollAngle: 0 - readonly property real _defaultPitchAngle: 0 - - property real _rollAngle: active ? rollAngle : _defaultRollAngle - property real _pitchAngle: active ? pitchAngle : _defaultPitchAngle + property real _rollAngle: vehicle ? vehicle.roll.rawValue : 0 + property real _pitchAngle: vehicle ? vehicle.pitch.rawValue : 0 width: size height: size diff --git a/src/FlightMap/Widgets/QGCCompassWidget.qml b/src/FlightMap/Widgets/QGCCompassWidget.qml index b941fbf919f8fbd9663aba8f0822738e39942ae1..a8e107180e32b41d45ccf242cffdb06a4c25a1ef 100644 --- a/src/FlightMap/Widgets/QGCCompassWidget.qml +++ b/src/FlightMap/Widgets/QGCCompassWidget.qml @@ -25,12 +25,12 @@ Item { id: root property real size: _defaultSize - property real heading: 0 property var vehicle: null property real _defaultSize: ScreenTools.defaultFontPixelHeight * (10) property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize property int _fontSize: ScreenTools.defaultFontPointSize * _sizeRatio + property real _heading: vehicle ? vehicle.heading.rawValue : 0 width: size height: size @@ -58,7 +58,7 @@ Item { transform: Rotation { origin.x: pointer.width / 2 origin.y: pointer.height / 2 - angle: heading + angle: _heading } } @@ -79,7 +79,7 @@ Item { color: Qt.rgba(0,0,0,0.65) QGCLabel { - text: vehicle ? heading.toFixed(0) : qsTr("OFF") + text: vehicle ? _heading.toFixed(0) : qsTr("OFF") font.family: vehicle ? ScreenTools.demiboldFontFamily : ScreenTools.normalFontFamily font.pointSize: _fontSize < 8 ? 8 : _fontSize; color: "white" diff --git a/src/FlightMap/Widgets/QGCInstrumentWidget.qml b/src/FlightMap/Widgets/QGCInstrumentWidget.qml index 879f740c4295eb240ff6e996802618cec944ba4e..a5b81c55a2ca64ef57bf7ff6bf6ab805f3ceab53 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidget.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidget.qml @@ -26,27 +26,15 @@ import QGroundControl.Palette 1.0 Item { id: instrumentPanel height: instrumentColumn.y + instrumentColumn.height + _topBottomMargin - width: size - - property alias heading: compass.heading - property alias rollAngle: attitudeWidget.rollAngle - property alias pitchAngle: attitudeWidget.pitchAngle - property real size: _defaultSize - property bool lightBorders: true - property bool active: false - property var qgcView - property real maxHeight - - property Fact _emptyFact: Fact { } - property Fact groundSpeedFact: _emptyFact - property Fact airSpeedFact: _emptyFact - - property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) + width: getPreferredInstrumentWidth() + property var _qgcView: qgcView + property real _maxHeight: maxHeight + property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) property color _backgroundColor: qgcPal.window property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 - property real _topBottomMargin: (size * 0.05) / 2 - property real _availableValueHeight: maxHeight - (attitudeWidget.height + _spacer1.height + _spacer2.height + (_spacing * 4)) - (_showCompass ? compass.height : 0) + property real _topBottomMargin: (width * 0.05) / 2 + property real _availableValueHeight: _maxHeight - (attitudeWidget.height + _spacer1.height + _spacer2.height + (_spacing * 4)) - (_showCompass ? compass.height : 0) property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle readonly property bool _showCompass: true // !ScreenTools.isShortScreen @@ -57,10 +45,10 @@ Item { anchors.left: parent.left anchors.right: parent.right height: (_showCompass ? instrumentColumn.height : attitudeWidget.height) + (_topBottomMargin * 2) - radius: size / 2 + radius: width / 2 color: _backgroundColor border.width: 1 - border.color: lightBorders ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark + border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark } MouseArea { @@ -83,7 +71,7 @@ Item { QGCAttitudeWidget { id: attitudeWidget size: parent.width * 0.95 - active: instrumentPanel.active + vehicle: _activeVehicle anchors.horizontalCenter: parent.horizontalCenter } @@ -131,7 +119,7 @@ Item { anchors.margins: 1 anchors.left: parent.left anchors.right: parent.right - qgcView: instrumentPanel.qgcView + qgcView: instrumentPanel._qgcView textColor: qgcPal.text backgroundColor: _backgroundColor maxHeight: _availableValueHeight diff --git a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml index 2ce355663276064feb8f7139dc6fec8d6b11fca2..03d5e34f323724675d3a8d3484d7349718e28936 100644 --- a/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml +++ b/src/FlightMap/Widgets/QGCInstrumentWidgetAlternate.qml @@ -20,38 +20,24 @@ import QGroundControl.Palette 1.0 /// Instrument panel shown when virtual thumbsticks are visible Rectangle { id: root + width: ScreenTools.isTinyScreen ? getPreferredInstrumentWidth() * 1.5 : getPreferredInstrumentWidth() height: _outerRadius * 2 radius: _outerRadius color: qgcPal.window border.width: 1 - border.color: lightBorders ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark - - property alias heading: compass.heading - property alias rollAngle: attitude.rollAngle - property alias pitchAngle: attitude.pitchAngle - property real size: _defaultSize - property bool active: false - property bool lightBorders: true - property var qgcView - property real maxHeight - - property Fact _emptyFact: Fact { } - property Fact groundSpeedFact: _emptyFact - property Fact airSpeedFact: _emptyFact - property Fact altitudeFact: _emptyFact - - property real _innerRadius: (width - (_topBottomMargin * 3)) / 4 - property real _outerRadius: _innerRadius + _topBottomMargin - - property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) - - property real _sizeRatio: ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize - property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio - property real _normalFontSize:ScreenTools.defaultFontPointSize * 1.5 * _sizeRatio - property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio - property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 - property real _topBottomMargin: (size * 0.05) / 2 + border.color: _isSatellite ? qgcPal.mapWidgetBorderLight : qgcPal.mapWidgetBorderDark + + property real _innerRadius: (width - (_topBottomMargin * 3)) / 4 + property real _outerRadius: _innerRadius + _topBottomMargin + property real _defaultSize: ScreenTools.defaultFontPixelHeight * (9) + property real _sizeRatio: ScreenTools.isTinyScreen ? (width / _defaultSize) * 0.5 : width / _defaultSize + property real _bigFontSize: ScreenTools.defaultFontPointSize * 2.5 * _sizeRatio + property real _normalFontSize: ScreenTools.defaultFontPointSize * 1.5 * _sizeRatio + property real _labelFontSize: ScreenTools.defaultFontPointSize * 0.75 * _sizeRatio + property real _spacing: ScreenTools.defaultFontPixelHeight * 0.33 + property real _topBottomMargin: (width * 0.05) / 2 property real _availableValueHeight: maxHeight - (root.height + _valuesItem.anchors.topMargin) + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle QGCPalette { id: qgcPal } @@ -60,7 +46,7 @@ Rectangle { anchors.leftMargin: _topBottomMargin anchors.left: parent.left size: _innerRadius * 2 - active: root.active + vehicle: _activeVehicle anchors.verticalCenter: parent.verticalCenter } @@ -69,7 +55,7 @@ Rectangle { anchors.leftMargin: _spacing anchors.left: attitude.right size: _innerRadius * 2 - vehicle: QGroundControl.multiVehicleManager.activeVehicle + vehicle: _activeVehicle anchors.verticalCenter: parent.verticalCenter } diff --git a/src/FlightMap/qmldir b/src/FlightMap/qmldir index c6d02e2cf02b458c0500ec20cb0920839b820513..84cdd15c37a80593e0e4d740a7644492051f6948 100644 --- a/src/FlightMap/qmldir +++ b/src/FlightMap/qmldir @@ -14,8 +14,6 @@ QGCArtificialHorizon 1.0 QGCArtificialHorizon.qml QGCAttitudeHUD 1.0 QGCAttitudeHUD.qml QGCAttitudeWidget 1.0 QGCAttitudeWidget.qml QGCCompassWidget 1.0 QGCCompassWidget.qml -QGCInstrumentWidget 1.0 QGCInstrumentWidget.qml -QGCInstrumentWidgetAlternate 1.0 QGCInstrumentWidgetAlternate.qml QGCPitchIndicator 1.0 QGCPitchIndicator.qml QGCSlider 1.0 QGCSlider.qml ValuesWidget 1.0 ValuesWidget.qml