From ac08dd5a25700d29bd690a2d4bc6d8e915f8bc01 Mon Sep 17 00:00:00 2001 From: DoinLakeFlyer Date: Wed, 6 May 2020 18:28:34 -0700 Subject: [PATCH] Re-architect toolbar for better customization capabilities. Also use less real estate. --- qgroundcontrol.qrc | 1 + .../APM/ArduSubFirmwarePlugin.cc | 19 +- .../APM/ArduSubFirmwarePlugin.h | 6 +- src/FirmwarePlugin/FirmwarePlugin.cc | 19 +- src/FirmwarePlugin/FirmwarePlugin.h | 20 +- src/FlightDisplay/FlyViewCustomLayer.qml | 4 +- src/FlightDisplay/FlyViewMap.qml | 4 +- src/FlightDisplay/FlyViewWidgetLayer.qml | 6 +- src/PlanView/PlanToolBar.qml | 1 - src/PlanView/PlanToolBarIndicators.qml | 62 +-- src/QmlControls/QGCToolBarButton.qml | 4 +- .../QGroundControl/Controls/qmldir | 1 + src/Vehicle/Vehicle.cc | 18 +- src/Vehicle/Vehicle.h | 9 +- src/api/QGCCorePlugin.cc | 14 +- src/api/QGCCorePlugin.h | 21 +- src/api/QGCOptions.cc | 15 - src/api/QGCOptions.h | 9 - src/ui/MainRootWindow.qml | 28 +- src/ui/toolbar/MainToolBar.qml | 325 +++++++------- src/ui/toolbar/MainToolBarIndicators.qml | 43 +- src/ui/toolbar/ToolBarBase.qml | 415 ++++++++++++++++++ 22 files changed, 751 insertions(+), 293 deletions(-) create mode 100644 src/ui/toolbar/ToolBarBase.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 1d2f9aaa3..bd38bc549 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -177,6 +177,7 @@ src/PlanView/SurveyMapVisual.qml src/PlanView/TerrainStatus.qml src/PlanView/TakeoffItemMapVisual.qml + src/ui/toolbar/ToolBarBase.qml src/QmlControls/ToolStrip.qml src/PlanView/TransectStyleComplexItemStats.qml src/QmlControls/VehicleRotationCal.qml diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc index d77274119..574f19751 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.cc @@ -217,20 +217,31 @@ bool ArduSubFirmwarePlugin::supportsMotorInterference(void) return false; } -const QVariantList& ArduSubFirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) +const QVariantList& ArduSubFirmwarePlugin::toolIndicators(const Vehicle* vehicle) { Q_UNUSED(vehicle); //-- Sub specific list of indicators (Enter your modified list here) - if(_toolBarIndicators.size() == 0) { - _toolBarIndicators = QVariantList({ + if(_toolIndicators.size() == 0) { + _toolIndicators = QVariantList({ QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/JoystickIndicator.qml")), + }); + } + return _toolIndicators; +} + +const QVariantList& ArduSubFirmwarePlugin::modeIndicators(const Vehicle* vehicle) +{ + Q_UNUSED(vehicle); + //-- Sub specific list of indicators (Enter your modified list here) + if(_modeIndicators.size() == 0) { + _modeIndicators = QVariantList({ QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ArmedIndicator.qml")), }); } - return _toolBarIndicators; + return _modeIndicators; } void ArduSubFirmwarePlugin::_handleNamedValueFloat(mavlink_message_t* message) diff --git a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h index ca744313a..a957a5305 100644 --- a/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h +++ b/src/FirmwarePlugin/APM/ArduSubFirmwarePlugin.h @@ -136,14 +136,16 @@ public: QString brandImageOutdoor(const Vehicle* vehicle) const final { Q_UNUSED(vehicle); return QStringLiteral("/qmlimages/APM/BrandImageSub"); } const FirmwarePlugin::remapParamNameMajorVersionMap_t& paramNameRemapMajorVersionMap(void) const final { return _remapParamName; } int remapParamNameHigestMinorVersionNumber(int majorVersionNumber) const final; - const QVariantList& toolBarIndicators(const Vehicle* vehicle) final; + const QVariantList& toolIndicators(const Vehicle* vehicle) final; + const QVariantList& modeIndicators(const Vehicle* vehicle) final; bool adjustIncomingMavlinkMessage(Vehicle* vehicle, mavlink_message_t* message) final; virtual QMap* factGroups(void) final; void adjustMetaData(MAV_TYPE vehicleType, FactMetaData* metaData) override final; private: - QVariantList _toolBarIndicators; + QVariantList _toolIndicators; + QVariantList _modeIndicators; static bool _remapParamNameIntialized; QMap _factRenameMap; static FirmwarePlugin::remapParamNameMajorVersionMap_t _remapParamName; diff --git a/src/FirmwarePlugin/FirmwarePlugin.cc b/src/FirmwarePlugin/FirmwarePlugin.cc index e7c3cb86f..7b862974e 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.cc +++ b/src/FirmwarePlugin/FirmwarePlugin.cc @@ -304,17 +304,26 @@ QString FirmwarePlugin::vehicleImageCompass(const Vehicle*) const return QStringLiteral("/qmlimages/compassInstrumentArrow.svg"); } -const QVariantList &FirmwarePlugin::toolBarIndicators(const Vehicle*) +const QVariantList& FirmwarePlugin::toolIndicators(const Vehicle*) { //-- Default list of indicators for all vehicles. - if(_toolBarIndicatorList.size() == 0) { - _toolBarIndicatorList = QVariantList({ + if(_toolIndicatorList.size() == 0) { + _toolIndicatorList = QVariantList({ QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MessageIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/TelemetryRSSIIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RCRSSIIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/BatteryIndicator.qml")), - QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSRTKIndicator.qml")), + }); + } + return _toolIndicatorList; +} + +const QVariantList& FirmwarePlugin::modeIndicators(const Vehicle*) +{ + //-- Default list of indicators for all vehicles. + if(_modeIndicatorList.size() == 0) { + _modeIndicatorList = QVariantList({ QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ROIIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ArmedIndicator.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ModeIndicator.qml")), @@ -323,7 +332,7 @@ const QVariantList &FirmwarePlugin::toolBarIndicators(const Vehicle*) QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/LinkIndicator.qml")), }); } - return _toolBarIndicatorList; + return _modeIndicatorList; } const QVariantList& FirmwarePlugin::cameraList(const Vehicle*) diff --git a/src/FirmwarePlugin/FirmwarePlugin.h b/src/FirmwarePlugin/FirmwarePlugin.h index 8f615d19b..2484b9e37 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.h +++ b/src/FirmwarePlugin/FirmwarePlugin.h @@ -267,10 +267,15 @@ public: /// Return the resource file which contains the vehicle icon used in the compass virtual QString vehicleImageCompass(const Vehicle* vehicle) const; - /// Allows the core plugin to override the toolbar indicators - /// signals toolbarIndicatorsChanged - /// @return A list of QUrl with the indicators (see MainToolBarIndicators.qml) - virtual const QVariantList& toolBarIndicators(const Vehicle* vehicle); + /// Returns the list of toolbar tool indicators associated with a vehicle + /// signals toolIndicatorsChanged + /// @return A list of QUrl with the indicators + virtual const QVariantList& toolIndicators(const Vehicle* vehicle); + + /// Returns the list of toolbar mode indicators associated with a vehicle + /// signals modeIndicatorsChanged + /// @return A list of QUrl with the indicators + virtual const QVariantList& modeIndicators(const Vehicle* vehicle); /// Returns a list of CameraMetaData objects for available cameras on the vehicle. /// TODO: This should go into QGCCameraManager @@ -330,7 +335,8 @@ public: static const QString px4FollowMeFlightMode; signals: - void toolbarIndicatorsChanged(void); + void toolIndicatorsChanged(void); + void modeIndicatorsChanged(void); protected: // Arms the vehicle with validation and retries @@ -351,7 +357,9 @@ protected: virtual QString _versionRegex() { return QString(); } private: - QVariantList _toolBarIndicatorList; + QVariantList _toolIndicatorList; + QVariantList _modeIndicatorList; + static QVariantList _cameraList; ///< Standard QGC camera list }; diff --git a/src/FlightDisplay/FlyViewCustomLayer.qml b/src/FlightDisplay/FlyViewCustomLayer.qml index a123f475b..a8ead7d3f 100644 --- a/src/FlightDisplay/FlyViewCustomLayer.qml +++ b/src/FlightDisplay/FlyViewCustomLayer.qml @@ -34,8 +34,8 @@ import QGroundControl.Vehicle 1.0 Item { id: _root - property var parentToolInsets // These insets tell you what screen real estate is available for positioning the controls in your overlay - property var toolInsets: _toolInsets // These are the insets for your custom overlay additions + property var parentToolInsets // These insets tell you what screen real estate is available for positioning the controls in your overlay + property var totalToolInsets: _toolInsets // These are the insets for your custom overlay additions property var mapControl QGCToolInsets { diff --git a/src/FlightDisplay/FlyViewMap.qml b/src/FlightDisplay/FlyViewMap.qml index 5e0fb2abc..27d2c4901 100644 --- a/src/FlightDisplay/FlyViewMap.qml +++ b/src/FlightDisplay/FlyViewMap.qml @@ -41,8 +41,8 @@ FlightMap { property var guidedActionsController property var rightPanelWidth property var planMasterController - property bool pipMode: false // true: map is shown in a small pip mode - property var toolInsets // Insets for the center viewport area + property bool pipMode: false // true: map is shown in a small pip mode + property var toolInsets // Insets for the center viewport area property var _planMasterController: planMasterController property var _geoFenceController: planMasterController.geoFenceController diff --git a/src/FlightDisplay/FlyViewWidgetLayer.qml b/src/FlightDisplay/FlyViewWidgetLayer.qml index 99f4a4d21..7f5aa6e6c 100644 --- a/src/FlightDisplay/FlyViewWidgetLayer.qml +++ b/src/FlightDisplay/FlyViewWidgetLayer.qml @@ -33,9 +33,9 @@ import QGroundControl.Vehicle 1.0 Item { id: _root - property var parentToolInsets - property var totalToolInsets: _totalToolInsets - property var mapControl + property var parentToolInsets + property var totalToolInsets: _totalToolInsets + property var mapControl property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle property var _planMasterController: mainWindow.planMasterControllerPlanView diff --git a/src/PlanView/PlanToolBar.qml b/src/PlanView/PlanToolBar.qml index c74df9e3c..3fdcc7841 100644 --- a/src/PlanView/PlanToolBar.qml +++ b/src/PlanView/PlanToolBar.qml @@ -32,7 +32,6 @@ Rectangle { id: settingsButton Layout.fillHeight: true icon.source: "/qmlimages/PaperPlane.svg" - logo: true checked: false onClicked: { checked = false diff --git a/src/PlanView/PlanToolBarIndicators.qml b/src/PlanView/PlanToolBarIndicators.qml index 22b63c6a2..a1ee03001 100644 --- a/src/PlanView/PlanToolBarIndicators.qml +++ b/src/PlanView/PlanToolBarIndicators.qml @@ -11,7 +11,7 @@ import QGroundControl.Palette 1.0 // Toolbar for Plan View Item { - anchors.fill: parent + width: missionStats.width + _margins property var _planMasterController: mainWindow.planMasterControllerPlanView property var _currentMissionItem: mainWindow.currentPlanMissionItem ///< Mission item to display status for @@ -109,11 +109,9 @@ Item { anchors.top: parent.top anchors.bottom: parent.bottom anchors.leftMargin: _margins - anchors.rightMargin: _margins anchors.left: parent.left - anchors.right: uploadButton.visible ? uploadButton.left : parent.right columnSpacing: 0 - columns: 3 + columns: 4 GridLayout { columns: 8 @@ -226,37 +224,25 @@ Item { } Item { width: 1; height: 1 } -/* - FIXME: Swap point display is currently hidden since the code which calcs it doesn't work correctly - QGCLabel { text: qsTr("Swap waypoint:"); font.pointSize: _dataFontSize; } - QGCLabel { - text: _batteryChangePointText - font.pointSize: _dataFontSize - Layout.minimumWidth: _mediumValueWidth - } -*/ } - } - QGCButton { - id: uploadButton - anchors.rightMargin: _margins - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - text: _controllerDirty ? qsTr("Upload Required") : qsTr("Upload") - enabled: !_controllerSyncInProgress - visible: !_controllerOffline && !_controllerSyncInProgress && !uploadCompleteText.visible - primary: _controllerDirty - onClicked: _planMasterController.upload() - - PropertyAnimation on opacity { - easing.type: Easing.OutQuart - from: 0.5 - to: 1 - loops: Animation.Infinite - running: _controllerDirty && !_controllerSyncInProgress - alwaysRunToEnd: true - duration: 2000 + QGCButton { + id: uploadButton + text: _controllerDirty ? qsTr("Upload Required") : qsTr("Upload") + enabled: !_controllerSyncInProgress + visible: !_controllerOffline && !_controllerSyncInProgress && !uploadCompleteText.visible + primary: _controllerDirty + onClicked: _planMasterController.upload() + + PropertyAnimation on opacity { + easing.type: Easing.OutQuart + from: 0.5 + to: 1 + loops: Animation.Infinite + running: _controllerDirty && !_controllerSyncInProgress + alwaysRunToEnd: true + duration: 2000 + } } } @@ -277,16 +263,6 @@ Item { } } - /* - Rectangle { - anchors.bottom: parent.bottom - height: toolBar.height * 0.05 - width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0 - color: qgcPal.colorGreen - visible: !largeProgressBar.visible - } - */ - // Large mission download progress bar Rectangle { id: largeProgressBar diff --git a/src/QmlControls/QGCToolBarButton.qml b/src/QmlControls/QGCToolBarButton.qml index af394d5bb..16380a9ad 100644 --- a/src/QmlControls/QGCToolBarButton.qml +++ b/src/QmlControls/QGCToolBarButton.qml @@ -32,7 +32,7 @@ Button { background: Rectangle { anchors.fill: parent - color: logo ? qgcPal.brandingPurple : (button.checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0)) + color: button.checked ? qgcPal.buttonHighlight : Qt.rgba(0,0,0,0) } contentItem: Row { @@ -44,7 +44,7 @@ Button { width: height sourceSize.height: parent.height fillMode: Image.PreserveAspectFit - color: logo ? "white" : (button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText) + color: logo ? "transparent" : (button.checked ? qgcPal.buttonHighlightText : qgcPal.buttonText) source: button.icon.source anchors.verticalCenter: parent.verticalCenter } diff --git a/src/QmlControls/QGroundControl/Controls/qmldir b/src/QmlControls/QGroundControl/Controls/qmldir index 4406652e3..d1d19cc3e 100644 --- a/src/QmlControls/QGroundControl/Controls/qmldir +++ b/src/QmlControls/QGroundControl/Controls/qmldir @@ -99,6 +99,7 @@ SurveyMapVisuals 1.0 SurveyMapVisuals.qml TerrainStatus 1.0 TerrainStatus.qml TransectStyleComplexItemStats 1.0 TransectStyleComplexItemStats.qml TransectStyleMapVisuals 1.0 TransectStyleMapVisuals.qml +ToolBarBase 1.0 ToolBarBase.qml ToolStrip 1.0 ToolStrip.qml VehicleRotationCal 1.0 VehicleRotationCal.qml VehicleSummaryRow 1.0 VehicleSummaryRow.qml diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 446dd984d..baf2a3952 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -414,8 +414,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, , _flightDistanceFact (0, _flightDistanceFactName, FactMetaData::valueTypeDouble) , _flightTimeFact (0, _flightTimeFactName, FactMetaData::valueTypeElapsedTimeInSeconds) , _distanceToHomeFact (0, _distanceToHomeFactName, FactMetaData::valueTypeDouble) - , _headingToNextWPFact (0, _headingToNextWPFactName, FactMetaData::valueTypeDouble) , _missionItemIndexFact (0, _missionItemIndexFactName, FactMetaData::valueTypeUint16) + , _headingToNextWPFact (0, _headingToNextWPFactName, FactMetaData::valueTypeDouble) , _headingToHomeFact (0, _headingToHomeFactName, FactMetaData::valueTypeDouble) , _distanceToGCSFact (0, _distanceToGCSFactName, FactMetaData::valueTypeDouble) , _hobbsFact (0, _hobbsFactName, FactMetaData::valueTypeString) @@ -446,7 +446,8 @@ void Vehicle::_commonInit() { _firmwarePlugin = _firmwarePluginManager->firmwarePluginForAutopilot(_firmwareType, _vehicleType); - connect(_firmwarePlugin, &FirmwarePlugin::toolbarIndicatorsChanged, this, &Vehicle::toolBarIndicatorsChanged); + connect(_firmwarePlugin, &FirmwarePlugin::toolIndicatorsChanged, this, &Vehicle::toolIndicatorsChanged); + connect(_firmwarePlugin, &FirmwarePlugin::modeIndicatorsChanged, this, &Vehicle::modeIndicatorsChanged); connect(this, &Vehicle::coordinateChanged, this, &Vehicle::_updateDistanceHeadingToHome); connect(this, &Vehicle::coordinateChanged, this, &Vehicle::_updateDistanceToGCS); @@ -3902,10 +3903,19 @@ QString Vehicle::vehicleImageCompass() const return QString(); } -const QVariantList& Vehicle::toolBarIndicators() +const QVariantList& Vehicle::toolIndicators() +{ + if(_firmwarePlugin) { + return _firmwarePlugin->toolIndicators(this); + } + static QVariantList emptyList; + return emptyList; +} + +const QVariantList& Vehicle::modeIndicators() { if(_firmwarePlugin) { - return _firmwarePlugin->toolBarIndicators(this); + return _firmwarePlugin->modeIndicators(this); } static QVariantList emptyList; return emptyList; diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 886c9f8e0..b86335c35 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -615,7 +615,8 @@ public: Q_PROPERTY(unsigned int telemetryTXBuffer READ telemetryTXBuffer NOTIFY telemetryTXBufferChanged) Q_PROPERTY(int telemetryLNoise READ telemetryLNoise NOTIFY telemetryLNoiseChanged) Q_PROPERTY(int telemetryRNoise READ telemetryRNoise NOTIFY telemetryRNoiseChanged) - Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) + Q_PROPERTY(QVariantList toolIndicators READ toolIndicators NOTIFY toolIndicatorsChanged) + Q_PROPERTY(QVariantList modeIndicators READ modeIndicators NOTIFY modeIndicatorsChanged) Q_PROPERTY(bool initialPlanRequestComplete READ initialPlanRequestComplete NOTIFY initialPlanRequestCompleteChanged) Q_PROPERTY(QVariantList staticCameraList READ staticCameraList CONSTANT) Q_PROPERTY(QGCCameraManager* dynamicCameras READ dynamicCameras NOTIFY dynamicCamerasChanged) @@ -1086,7 +1087,8 @@ public: QString vehicleImageOutline () const; QString vehicleImageCompass () const; - const QVariantList& toolBarIndicators (); + const QVariantList& toolIndicators (); + const QVariantList& modeIndicators (); const QVariantList& staticCameraList () const; bool capabilitiesKnown () const { return _capabilityBitsKnown; } @@ -1160,7 +1162,8 @@ signals: void capabilitiesKnownChanged (bool capabilitiesKnown); void initialPlanRequestCompleteChanged(bool initialPlanRequestComplete); void capabilityBitsChanged (uint64_t capabilityBits); - void toolBarIndicatorsChanged (); + void toolIndicatorsChanged (); + void modeIndicatorsChanged (); void highLatencyLinkChanged (bool highLatencyLink); void priorityLinkNameChanged (const QString& priorityLinkName); void linksChanged (); diff --git a/src/api/QGCCorePlugin.cc b/src/api/QGCCorePlugin.cc index ebc95de52..8597bffa8 100644 --- a/src/api/QGCCorePlugin.cc +++ b/src/api/QGCCorePlugin.cc @@ -516,8 +516,18 @@ QString QGCCorePlugin::stableVersionCheckFileUrl() const #endif } -QStringList -QGCCorePlugin::startupPages() +QStringList QGCCorePlugin::startupPages() { return { "/qml/QGroundControl/Specific/UnitsWizardPage.qml" }; } + +const QVariantList &QGCCorePlugin::toolBarIndicators(void) +{ + //-- Default list of indicators for all vehicles. + if(_toolBarIndicatorList.size() == 0) { + _toolBarIndicatorList = QVariantList({ + QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPSRTKIndicator.qml")), + }); + } + return _toolBarIndicatorList; +} diff --git a/src/api/QGCCorePlugin.h b/src/api/QGCCorePlugin.h index a2b6f1835..5c4f3bfbd 100644 --- a/src/api/QGCCorePlugin.h +++ b/src/api/QGCCorePlugin.h @@ -58,7 +58,7 @@ public: Q_PROPERTY(QString brandImageOutdoor READ brandImageOutdoor CONSTANT) Q_PROPERTY(QmlObjectListModel* customMapItems READ customMapItems CONSTANT) Q_PROPERTY(QStringList startupPages READ startupPages NOTIFY startupPagesChanged) - + Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) Q_INVOKABLE bool guidedActionsControllerLogging() const; @@ -172,6 +172,11 @@ public: /// @return QML files paths that will be loaded using the StartupWizard control virtual QStringList startupPages(); + /// Returns the list of toolbar indicators which are not related to a vehicle + /// signals toolbarIndicatorsChanged + /// @return A list of QUrl with the indicators + virtual const QVariantList& toolBarIndicators(void); + bool showTouchAreas() const { return _showTouchAreas; } bool showAdvancedUI() const { return _showAdvancedUI; } void setShowTouchAreas(bool show); @@ -181,12 +186,13 @@ public: void setToolbox (QGCToolbox* toolbox); signals: - void settingsPagesChanged (); - void analyzePagesChanged (); - void instrumentPagesChanged (); - void showTouchAreasChanged (bool showTouchAreas); - void showAdvancedUIChanged (bool showAdvancedUI); - void startupPagesChanged (); + void settingsPagesChanged (); + void analyzePagesChanged (); + void instrumentPagesChanged (); + void showTouchAreasChanged (bool showTouchAreas); + void showAdvancedUIChanged (bool showAdvancedUI); + void startupPagesChanged (); + void toolBarIndicatorsChanged (); protected slots: void _activeVehicleChanged (Vehicle* activeVehicle); @@ -203,6 +209,7 @@ protected: Vehicle* _activeVehicle = nullptr; QGCCameraManager* _dynamicCameras = nullptr; QGCCameraControl* _currentCamera = nullptr; + QVariantList _toolBarIndicatorList; private: QGCCorePlugin_p* _p; diff --git a/src/api/QGCOptions.cc b/src/api/QGCOptions.cc index 56ed43fc3..d8555d1e8 100644 --- a/src/api/QGCOptions.cc +++ b/src/api/QGCOptions.cc @@ -21,16 +21,6 @@ QGCOptions::QGCOptions(QObject* parent) QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); } -QUrl QGCOptions::mainToolbarUrl() const -{ - return QUrl(QStringLiteral("qrc:/toolbar/MainToolBar.qml")); -} - -QUrl QGCOptions::planToolbarUrl() const -{ - return QUrl(QStringLiteral("qrc:/qml/PlanToolBar.qml")); -} - QColor QGCOptions::toolbarBackgroundLight() const { return QColor(255,255,255,204); @@ -41,11 +31,6 @@ QColor QGCOptions::toolbarBackgroundDark() const return QColor(0,0,0,192); } -QUrl QGCOptions::planToolbarIndicatorsUrl() const -{ - return QUrl(QStringLiteral("PlanToolBar.qml")); -} - QGCFlyViewOptions* QGCOptions::flyViewOptions(void) { if (!_defaultFlyViewOptions) { diff --git a/src/api/QGCOptions.h b/src/api/QGCOptions.h index f559123de..60e0ebf1c 100644 --- a/src/api/QGCOptions.h +++ b/src/api/QGCOptions.h @@ -55,11 +55,8 @@ public: Q_PROPERTY(double toolbarHeightMultiplier READ toolbarHeightMultiplier CONSTANT) Q_PROPERTY(bool enablePlanViewSelector READ enablePlanViewSelector CONSTANT) Q_PROPERTY(QUrl preFlightChecklistUrl READ preFlightChecklistUrl CONSTANT) - Q_PROPERTY(QUrl mainToolbarUrl READ mainToolbarUrl CONSTANT) - Q_PROPERTY(QUrl planToolbarUrl READ planToolbarUrl CONSTANT) Q_PROPERTY(QColor toolbarBackgroundLight READ toolbarBackgroundLight CONSTANT) Q_PROPERTY(QColor toolbarBackgroundDark READ toolbarBackgroundDark CONSTANT) - Q_PROPERTY(QUrl planToolbarIndicatorsUrl READ planToolbarIndicatorsUrl CONSTANT) Q_PROPERTY(bool showSensorCalibrationCompass READ showSensorCalibrationCompass NOTIFY showSensorCalibrationCompassChanged) Q_PROPERTY(bool showSensorCalibrationGyro READ showSensorCalibrationGyro NOTIFY showSensorCalibrationGyroChanged) Q_PROPERTY(bool showSensorCalibrationAccel READ showSensorCalibrationAccel NOTIFY showSensorCalibrationAccelChanged) @@ -107,16 +104,10 @@ public: /// Provides an optional, custom preflight checklist virtual QUrl preFlightChecklistUrl () const { return QUrl::fromUserInput("qrc:/qml/PreFlightCheckList.qml"); } - /// Allows replacing the Main toolbar - virtual QUrl mainToolbarUrl () const; - /// Allows replacing the Plan View toolbar - virtual QUrl planToolbarUrl () const; /// Allows replacing the toolbar Light Theme color virtual QColor toolbarBackgroundLight () const; /// Allows replacing the toolbar Dark Theme color virtual QColor toolbarBackgroundDark () const; - /// Allows replacing the Plan View toolbar container - virtual QUrl planToolbarIndicatorsUrl () const; /// By returning false you can hide the following sensor calibration pages virtual bool showSensorCalibrationCompass () const { return true; } virtual bool showSensorCalibrationGyro () const { return true; } diff --git a/src/ui/MainRootWindow.qml b/src/ui/MainRootWindow.qml index 40cd099f6..ed9ab02c4 100644 --- a/src/ui/MainRootWindow.qml +++ b/src/ui/MainRootWindow.qml @@ -49,10 +49,7 @@ ApplicationWindow { property var _rgPreventViewSwitch: [ false ] - readonly property real _topBottomMargins: ScreenTools.defaultFontPixelHeight * 0.5 - readonly property string _mainToolbar: QGroundControl.corePlugin.options.mainToolbarUrl - readonly property string _planToolbar: QGroundControl.corePlugin.options.planToolbarUrl //------------------------------------------------------------------------- //-- Global Scope Variables @@ -107,44 +104,47 @@ ApplicationWindow { return _rgPreventViewSwitch[_rgPreventViewSwitch.length - 1] } - function viewSwitch(isPlanView) { + function viewSwitch(isPlanView, showModeIndicators) { settingsWindow.visible = false setupWindow.visible = false analyzeWindow.visible = false flightView.visible = false planViewLoader.visible = false - if(isPlanView) { - toolbar.source = _planToolbar + var indicatorSource + if (isPlanView) { + indicatorSource = "qrc:/qml/PlanToolBarIndicators.qml" } else { - toolbar.source = _mainToolbar + indicatorSource = "qrc:/toolbar/MainToolBarIndicators.qml" } + toolbar.item.indicatorSource = indicatorSource + toolbar.item.showModeIndicators = showModeIndicators } function showFlyView() { if (!flightView.visible) { mainWindow.showPreFlightChecklistIfNeeded() } - viewSwitch(false) + viewSwitch(false, true) flightView.visible = true } function showPlanView() { - viewSwitch(true) + viewSwitch(true, false) planViewLoader.visible = true } function showAnalyzeView() { - viewSwitch(false) + viewSwitch(false, false) analyzeWindow.visible = true } function showSetupView() { - viewSwitch(false) + viewSwitch(false, false) setupWindow.visible = true } function showSettingsView() { - viewSwitch(false) + viewSwitch(false, false) settingsWindow.visible = true } @@ -324,13 +324,13 @@ ApplicationWindow { header: ToolBar { height: ScreenTools.toolbarHeight visible: !QGroundControl.videoManager.fullScreen - background: Rectangle { + background: Rectangle { color: qgcPal.globalTheme === QGCPalette.Light ? QGroundControl.corePlugin.options.toolbarBackgroundLight : QGroundControl.corePlugin.options.toolbarBackgroundDark } Loader { id: toolbar anchors.fill: parent - source: _mainToolbar + source: "qrc:/toolbar/MainToolBar.qml" //-- Toggle Full Screen / Windowed MouseArea { anchors.fill: parent diff --git a/src/ui/toolbar/MainToolBar.qml b/src/ui/toolbar/MainToolBar.qml index fb6dd695f..63466c780 100644 --- a/src/ui/toolbar/MainToolBar.qml +++ b/src/ui/toolbar/MainToolBar.qml @@ -20,13 +20,40 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.Controllers 1.0 Item { - id: toolBar + id: _root - Component.onCompleted: { - //-- TODO: Get this from the actual state - flyButton.checked = true + property alias indicatorSource: indicatorLoader.source + property alias showModeIndicators: indicatorLoader.showModeIndicators + + // FIXME: Reaching up for communicationLost? + + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + + Component.onCompleted: _viewButtonClicked(flyButton) + + function _viewButtonClicked(button) { + if (mainWindow.preventViewSwitch()) { + return false + } + viewButtonSelectRow.visible = false + buttonSelectHideTimer.stop() + currentButton.icon.source = button.icon.source + currentButton.logo = button.logo + return true + } + + //-- Setup can be invoked from c++ side + Connections { + target: setupWindow + onVisibleChanged: { + if (setupWindow.visible) { + _viewButtonClicked(setupButton) + } + } } + QGCPalette { id: qgcPal } + /// Bottom single pixel divider Rectangle { anchors.left: parent.left @@ -37,105 +64,87 @@ Item { visible: qgcPal.globalTheme === QGCPalette.Light } - - //-- Setup can be invoked from c++ side - Connections { - target: setupWindow - onVisibleChanged: { - if (setupWindow.visible) { - buttonRow.clearAllChecks() - setupButton.checked = true + RowLayout { + id: viewButtonRow + anchors.bottomMargin: 1 + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth / 2 + + QGCToolBarButton { + id: currentButton + Layout.fillHeight: true + + onClicked: { + viewButtonSelectRow.visible = !viewButtonSelectRow.visible + if (viewButtonSelectRow.visible) { + buttonSelectHideTimer.start() + } else { + buttonSelectHideTimer.stop() + } } } - } - - QGCFlickable { - anchors.fill: parent - contentWidth: toolbarRow.width - flickableDirection: Flickable.HorizontalFlick + //--------------------------------------------- + // Toolbar Row RowLayout { - id: toolbarRow - anchors.bottomMargin: 1 - anchors.top: parent.top - anchors.bottom: parent.bottom - spacing: ScreenTools.defaultFontPixelWidth / 2 - - // Important Note: Toolbar buttons must manage their checked state manually in order to support - // view switch prevention. There doesn't seem to be a way to make this work if they are in a - // ButtonGroup. - - //--------------------------------------------- - // Toolbar Row - RowLayout { - id: buttonRow - Layout.fillHeight: true - spacing: 0 - - function clearAllChecks() { - for (var i=0; i (toolbarRow.x + toolbarRow.width + ScreenTools.defaultFontPixelWidth) + visible: _activeVehicle && !communicationLost && x > (toolsFlickable.x + toolsFlickable.contentWidth + ScreenTools.defaultFontPixelWidth) fillMode: Image.PreserveAspectFit source: _outdoorPalette ? _brandImageOutdoor : _brandImageIndoor mipmap: true @@ -236,27 +246,27 @@ Item { property bool _userBrandingOutdoor: _userBrandImageOutdoor.length != 0 property string _brandImageIndoor: _userBrandingIndoor ? _userBrandImageIndoor : (_userBrandingOutdoor ? - _userBrandImageOutdoor : (_corePluginBranding ? - QGroundControl.corePlugin.brandImageIndoor : (activeVehicle ? - activeVehicle.brandImageIndoor : "" - ) - ) - ) + _userBrandImageOutdoor : (_corePluginBranding ? + QGroundControl.corePlugin.brandImageIndoor : (activeVehicle ? + activeVehicle.brandImageIndoor : "" + ) + ) + ) property string _brandImageOutdoor: _userBrandingOutdoor ? _userBrandImageOutdoor : (_userBrandingIndoor ? - _userBrandImageIndoor : (_corePluginBranding ? - QGroundControl.corePlugin.brandImageOutdoor : (activeVehicle ? - activeVehicle.brandImageOutdoor : "" - ) - ) - ) + _userBrandImageIndoor : (_corePluginBranding ? + QGroundControl.corePlugin.brandImageOutdoor : (activeVehicle ? + activeVehicle.brandImageOutdoor : "" + ) + ) + ) } // Small parameter download progress bar Rectangle { anchors.bottom: parent.bottom - height: toolBar.height * 0.05 - width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0 + height: _root.height * 0.05 + width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 color: qgcPal.colorGreen visible: !largeProgressBar.visible } @@ -271,7 +281,7 @@ Item { color: qgcPal.window visible: _showLargeProgress - property bool _initialDownloadComplete: activeVehicle ? activeVehicle.parameterManager.parametersReady : true + property bool _initialDownloadComplete: _activeVehicle ? _activeVehicle.parameterManager.parametersReady : true property bool _userHide: false property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light @@ -283,7 +293,7 @@ Item { Rectangle { anchors.top: parent.top anchors.bottom: parent.bottom - width: activeVehicle ? activeVehicle.parameterManager.loadProgress * parent.width : 0 + width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 color: qgcPal.colorGreen } @@ -308,7 +318,6 @@ Item { } } - //------------------------------------------------------------------------- //-- Waiting for a vehicle QGCLabel { @@ -319,26 +328,27 @@ Item { font.pointSize: ScreenTools.mediumFontPointSize font.family: ScreenTools.demiboldFontFamily color: qgcPal.colorRed - visible: !activeVehicle + visible: !_activeVehicle } //------------------------------------------------------------------------- //-- Connection Status Row { + id: connectionStatus anchors.rightMargin: ScreenTools.defaultFontPixelWidth anchors.top: parent.top anchors.bottom: parent.bottom anchors.right: parent.right layoutDirection: Qt.RightToLeft spacing: ScreenTools.defaultFontPixelWidth - visible: activeVehicle && communicationLost + visible: _activeVehicle && communicationLost QGCButton { id: disconnectButton anchors.verticalCenter: parent.verticalCenter text: qsTr("Disconnect") primary: true - onClicked: activeVehicle.disconnectInactiveVehicle() + onClicked: _activeVehicle.disconnectInactiveVehicle() } QGCLabel { @@ -350,5 +360,4 @@ Item { color: qgcPal.colorRed } } - } diff --git a/src/ui/toolbar/MainToolBarIndicators.qml b/src/ui/toolbar/MainToolBarIndicators.qml index 6d8f3fce5..cb9b71250 100644 --- a/src/ui/toolbar/MainToolBarIndicators.qml +++ b/src/ui/toolbar/MainToolBarIndicators.qml @@ -7,15 +7,10 @@ * ****************************************************************************/ -import QtQuick 2.11 -import QtQuick.Controls 2.4 -import QtQuick.Layouts 1.11 +import QtQuick 2.12 -import QGroundControl 1.0 -import QGroundControl.Controls 1.0 -import QGroundControl.MultiVehicleManager 1.0 -import QGroundControl.ScreenTools 1.0 -import QGroundControl.Palette 1.0 +import QGroundControl 1.0 +import QGroundControl.ScreenTools 1.0 //------------------------------------------------------------------------- //-- Toolbar Indicators @@ -23,15 +18,41 @@ Row { id: indicatorRow anchors.top: parent.top anchors.bottom: parent.bottom + anchors.margins: _toolIndicatorMargins spacing: ScreenTools.defaultFontPixelWidth * 1.5 + // This property should come in from the Loader + //property bool showModeIndicators: true + + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property real _toolIndicatorMargins: ScreenTools.defaultFontPixelHeight * 0.66 + + Repeater { + id: appRepeater + model: QGroundControl.corePlugin.toolBarIndicators + Loader { + anchors.top: parent.top + anchors.bottom: parent.bottom + source: modelData + visible: item.showIndicator + } + } + + Repeater { + model: _activeVehicle ? _activeVehicle.toolIndicators : [] + Loader { + anchors.top: parent.top + anchors.bottom: parent.bottom + source: modelData + visible: item.showIndicator + } + } + Repeater { - model: activeVehicle ? activeVehicle.toolBarIndicators : [] + model: _activeVehicle && showModeIndicators ? _activeVehicle.modeIndicators : [] Loader { - id: indicatorLoader anchors.top: parent.top anchors.bottom: parent.bottom - anchors.margins: ScreenTools.defaultFontPixelHeight * 0.66 source: modelData visible: item.showIndicator } diff --git a/src/ui/toolbar/ToolBarBase.qml b/src/ui/toolbar/ToolBarBase.qml new file mode 100644 index 000000000..4294a1c30 --- /dev/null +++ b/src/ui/toolbar/ToolBarBase.qml @@ -0,0 +1,415 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.11 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.11 +import QtQuick.Dialogs 1.3 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 + +Item { + id: _root + + // FIXME: Reaching up for communicationLost? + + property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle + property real _toolIndicatorMargins: ScreenTools.defaultFontPixelHeight * 0.66 + + Component.onCompleted: _viewButtonClicked(flyButton) + + function _viewButtonClicked(button) { + if (mainWindow.preventViewSwitch()) { + return false + } + viewButtonSelectRow.visible = false + buttonSelectHideTimer.stop() + currentButton.icon.source = button.icon.source + currentButton.logo = button.logo + return true + } + + //-- Setup can be invoked from c++ side + Connections { + target: setupWindow + onVisibleChanged: { + if (setupWindow.visible) { + _viewButtonClicked(setupButton) + } + } + } + + QGCPalette { id: qgcPal } + + /// Bottom single pixel divider + Rectangle { + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 1 + color: "black" + visible: qgcPal.globalTheme === QGCPalette.Light + } + + + //-- Setup can be invoked from c++ side + Connections { + target: setupWindow + onVisibleChanged: { + if (setupWindow.visible) { + buttonRow.clearAllChecks() + setupButton.checked = true + } + } + } + + RowLayout { + id: viewButtonRow + anchors.bottomMargin: 1 + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth / 2 + + QGCToolBarButton { + id: currentButton + Layout.fillHeight: true + + onClicked: { + viewButtonSelectRow.visible = !viewButtonSelectRow.visible + if (viewButtonSelectRow.visible) { + buttonSelectHideTimer.start() + } else { + buttonSelectHideTimer.stop() + } + } + } + + //--------------------------------------------- + // Toolbar Row + RowLayout { + id: viewButtonSelectRow + Layout.fillHeight: true + spacing: 0 + visible: false + + Timer { + id: buttonSelectHideTimer + interval: 5000 + repeat: false + onTriggered: viewButtonSelectRow.visible = false + } + + QGCToolBarButton { + id: settingsButton + Layout.fillHeight: true + icon.source: "/res/QGCLogoFull" + logo: true + visible: currentButton.icon.source !== icon.source && !QGroundControl.corePlugin.options.combineSettingsAndSetup + onClicked: { + if (_viewButtonClicked(this)) { + mainWindow.showSettingsView() + } + } + } + + QGCToolBarButton { + id: setupButton + Layout.fillHeight: true + icon.source: "/qmlimages/Gears.svg" + visible: currentButton.icon.source !== icon.source + onClicked: { + if (_viewButtonClicked(this)) { + mainWindow.showSetupView() + } + } + } + + QGCToolBarButton { + id: planButton + Layout.fillHeight: true + icon.source: "/qmlimages/Plan.svg" + visible: currentButton.icon.source !== icon.source + onClicked: { + if (_viewButtonClicked(this)) { + mainWindow.showPlanView() + } + } + } + + QGCToolBarButton { + id: flyButton + Layout.fillHeight: true + icon.source: "/qmlimages/PaperPlane.svg" + visible: currentButton.icon.source !== icon.source + onClicked: { + if (_viewButtonClicked(this)) { + mainWindow.showFlyView() + // Easter Egg mechanism + _clickCount++ + eggTimer.restart() + if (_clickCount == 5) { + if(!QGroundControl.corePlugin.showAdvancedUI) { + advancedModeConfirmation.open() + } else { + QGroundControl.corePlugin.showAdvancedUI = false + } + } else if (_clickCount == 7) { + QGroundControl.corePlugin.showTouchAreas = !QGroundControl.corePlugin.showTouchAreas + } + } + } + + property int _clickCount: 0 + + Timer { + id: eggTimer + interval: 1000 + repeat: false + onTriggered: parent._clickCount = 0 + } + + MessageDialog { + id: advancedModeConfirmation + title: qsTr("Advanced Mode") + text: QGroundControl.corePlugin.showAdvancedUIMessage + standardButtons: StandardButton.Yes | StandardButton.No + onYes: { + QGroundControl.corePlugin.showAdvancedUI = true + advancedModeConfirmation.close() + } + } + } + + QGCToolBarButton { + id: analyzeButton + Layout.fillHeight: true + icon.source: "/qmlimages/Analyze.svg" + visible: currentButton.icon.source !== icon.source && QGroundControl.corePlugin.showAdvancedUI + onClicked: { + if (_viewButtonClicked(this)) { + mainWindow.showAnalyzeView() + } + } + } + } + } + + // View / Tool separator + Row { + id: separator + anchors.bottomMargin: 1 + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth * 1.5 + + Item { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: ScreenTools.defaultFontPixelWidth / 2 + } + + Rectangle { + anchors.margins: ScreenTools.defaultFontPixelHeight / 2 + anchors.top: parent.top + anchors.bottom: parent.bottom + width: 1 + color: qgcPal.text + } + + Item { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: ScreenTools.defaultFontPixelWidth / 2 + } + } + + QGCFlickable { + id: toolsFlickable + anchors.left: separator.right + anchors.right: connectionStatus.visible ? connectionStatus.left : parent.right + anchors.bottomMargin: 1 + anchors.top: parent.top + anchors.bottom: parent.bottom + contentWidth: toolRow.width + flickableDirection: Flickable.HorizontalFlick + + Row { + id: toolRow + anchors.bottomMargin: 1 + anchors.top: parent.top + anchors.bottom: parent.bottom + spacing: ScreenTools.defaultFontPixelWidth * 1.5 + + Repeater { + id: appRepeater + model: QGroundControl.corePlugin.toolBarIndicators + + Loader { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: _toolIndicatorMargins + source: modelData + visible: item.showIndicator + } + } + + Repeater { + model: _activeVehicle ? _activeVehicle.toolBarIndicators : [] + + Loader { + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: _toolIndicatorMargins + source: modelData + visible: item.showIndicator + } + } + } + } + + //------------------------------------------------------------------------- + //-- Branding Logo + Image { + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.margins: ScreenTools.defaultFontPixelHeight * 0.66 + visible: _activeVehicle && !communicationLost && x > (toolsFlickable.x + toolsFlickable.contentWidth + ScreenTools.defaultFontPixelWidth) + fillMode: Image.PreserveAspectFit + source: _outdoorPalette ? _brandImageOutdoor : _brandImageIndoor + mipmap: true + + property bool _outdoorPalette: qgcPal.globalTheme === QGCPalette.Light + property bool _corePluginBranding: QGroundControl.corePlugin.brandImageIndoor.length != 0 + property string _userBrandImageIndoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageIndoor.value + property string _userBrandImageOutdoor: QGroundControl.settingsManager.brandImageSettings.userBrandImageOutdoor.value + property bool _userBrandingIndoor: _userBrandImageIndoor.length != 0 + property bool _userBrandingOutdoor: _userBrandImageOutdoor.length != 0 + property string _brandImageIndoor: _userBrandingIndoor ? + _userBrandImageIndoor : (_userBrandingOutdoor ? + _userBrandImageOutdoor : (_corePluginBranding ? + QGroundControl.corePlugin.brandImageIndoor : (activeVehicle ? + activeVehicle.brandImageIndoor : "" + ) + ) + ) + property string _brandImageOutdoor: _userBrandingOutdoor ? + _userBrandImageOutdoor : (_userBrandingIndoor ? + _userBrandImageIndoor : (_corePluginBranding ? + QGroundControl.corePlugin.brandImageOutdoor : (activeVehicle ? + activeVehicle.brandImageOutdoor : "" + ) + ) + ) + } + + // Small parameter download progress bar + Rectangle { + anchors.bottom: parent.bottom + height: _root.height * 0.05 + width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 + color: qgcPal.colorGreen + visible: !largeProgressBar.visible + } + + // Large parameter download progress bar + Rectangle { + id: largeProgressBar + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + height: parent.height + color: qgcPal.window + visible: _showLargeProgress + + property bool _initialDownloadComplete: _activeVehicle ? _activeVehicle.parameterManager.parametersReady : true + property bool _userHide: false + property bool _showLargeProgress: !_initialDownloadComplete && !_userHide && qgcPal.globalTheme === QGCPalette.Light + + Connections { + target: QGroundControl.multiVehicleManager + onActiveVehicleChanged: largeProgressBar._userHide = false + } + + Rectangle { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: _activeVehicle ? _activeVehicle.parameterManager.loadProgress * parent.width : 0 + color: qgcPal.colorGreen + } + + QGCLabel { + anchors.centerIn: parent + text: qsTr("Downloading Parameters") + font.pointSize: ScreenTools.largeFontPointSize + } + + QGCLabel { + anchors.margins: _margin + anchors.right: parent.right + anchors.bottom: parent.bottom + text: qsTr("Click anywhere to hide") + + property real _margin: ScreenTools.defaultFontPixelWidth / 2 + } + + MouseArea { + anchors.fill: parent + onClicked: largeProgressBar._userHide = true + } + } + + //------------------------------------------------------------------------- + //-- Waiting for a vehicle + QGCLabel { + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Waiting For Vehicle Connection") + font.pointSize: ScreenTools.mediumFontPointSize + font.family: ScreenTools.demiboldFontFamily + color: qgcPal.colorRed + visible: !_activeVehicle + } + + //------------------------------------------------------------------------- + //-- Connection Status + Row { + id: connectionStatus + anchors.rightMargin: ScreenTools.defaultFontPixelWidth + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: parent.right + layoutDirection: Qt.RightToLeft + spacing: ScreenTools.defaultFontPixelWidth + visible: _activeVehicle && communicationLost + + QGCButton { + id: disconnectButton + anchors.verticalCenter: parent.verticalCenter + text: qsTr("Disconnect") + primary: true + onClicked: _activeVehicle.disconnectInactiveVehicle() + } + + QGCLabel { + id: connectionLost + anchors.verticalCenter: parent.verticalCenter + text: qsTr("COMMUNICATION LOST") + font.pointSize: ScreenTools.largeFontPointSize + font.family: ScreenTools.demiboldFontFamily + color: qgcPal.colorRed + } + } +} -- 2.22.0