From 00e9317b845f72bbb09c2ab5719b4e6bf996e7ba Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Wed, 11 Dec 2019 18:53:40 -0500 Subject: [PATCH] Resources and indicator --- qgcimages.qrc | 1 + qgroundcontrol.qrc | 1 + src/FirmwarePlugin/FirmwarePlugin.cc | 8 +-- src/ui/toolbar/Images/roi.svg | 10 ++++ src/ui/toolbar/ROIIndicator.qml | 89 ++++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 src/ui/toolbar/Images/roi.svg create mode 100644 src/ui/toolbar/ROIIndicator.qml diff --git a/qgcimages.qrc b/qgcimages.qrc index e0e6be148..e60fe913f 100644 --- a/qgcimages.qrc +++ b/qgcimages.qrc @@ -146,6 +146,7 @@ src/AutoPilotPlugins/PX4/Images/RCLossLight.svg src/AutoPilotPlugins/PX4/Images/ReturnToHomeAltitude.svg src/AutoPilotPlugins/PX4/Images/ReturnToHomeAltitudeCopter.svg + src/ui/toolbar/Images/roi.svg src/FlightMap/Images/rollDialWhite.svg src/FlightMap/Images/rollPointerWhite.svg src/ui/toolbar/Images/RTK.svg diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index e82ba2e38..542cba60e 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -15,6 +15,7 @@ src/ui/toolbar/ModeIndicator.qml src/ui/toolbar/MultiVehicleSelector.qml src/ui/toolbar/RCRSSIIndicator.qml + src/ui/toolbar/ROIIndicator.qml src/ui/toolbar/TelemetryRSSIIndicator.qml src/ui/toolbar/VTOLModeIndicator.qml diff --git a/src/FirmwarePlugin/FirmwarePlugin.cc b/src/FirmwarePlugin/FirmwarePlugin.cc index 22d5f3d63..21156618a 100644 --- a/src/FirmwarePlugin/FirmwarePlugin.cc +++ b/src/FirmwarePlugin/FirmwarePlugin.cc @@ -319,7 +319,6 @@ QString FirmwarePlugin::vehicleImageCompass(const Vehicle* vehicle) const const QVariantList &FirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) { - Q_UNUSED(vehicle); //-- Default list of indicators for all vehicles. if(_toolBarIndicatorList.size() == 0) { _toolBarIndicatorList = QVariantList({ @@ -335,14 +334,15 @@ const QVariantList &FirmwarePlugin::toolBarIndicators(const Vehicle* vehicle) QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/MultiVehicleSelector.qml")), QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/LinkIndicator.qml")), }); + if(vehicle->roiModeSupported()) { + _toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/ROIIndicator.qml"))); + } } return _toolBarIndicatorList; } -const QVariantList& FirmwarePlugin::cameraList(const Vehicle* vehicle) +const QVariantList& FirmwarePlugin::cameraList(const Vehicle*) { - Q_UNUSED(vehicle); - if (_cameraList.size() == 0) { CameraMetaData* metaData; diff --git a/src/ui/toolbar/Images/roi.svg b/src/ui/toolbar/Images/roi.svg new file mode 100644 index 000000000..6983926e0 --- /dev/null +++ b/src/ui/toolbar/Images/roi.svg @@ -0,0 +1,10 @@ + + + + + diff --git a/src/ui/toolbar/ROIIndicator.qml b/src/ui/toolbar/ROIIndicator.qml new file mode 100644 index 000000000..c6f52b97e --- /dev/null +++ b/src/ui/toolbar/ROIIndicator.qml @@ -0,0 +1,89 @@ +/**************************************************************************** + * + * (c) 2009-2019 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + * @file + * @author Gus Grubba + */ + +import QtQuick 2.11 +import QtQuick.Controls 1.4 +import QtQuick.Layouts 1.11 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.MultiVehicleManager 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.Palette 1.0 + +//------------------------------------------------------------------------- +//-- ROI Indicator +Item { + id: _root + width: showIndicator ? roiIcon.width : 0 + visible: showIndicator + anchors.top: parent.top + anchors.bottom: parent.bottom + + property bool showIndicator: activeVehicle && activeVehicle.roiModeSupported + + Component { + id: roiInfo + + Rectangle { + width: roiCol.width + ScreenTools.defaultFontPixelWidth * 6 + height: roiCol.height + ScreenTools.defaultFontPixelHeight * 2 + radius: ScreenTools.defaultFontPixelHeight * 0.5 + color: qgcPal.window + + Column { + id: roiCol + spacing: ScreenTools.defaultFontPixelHeight * 0.5 + width: Math.max(roiButton.width, roiLabel.width) + anchors.margins: ScreenTools.defaultFontPixelHeight + anchors.centerIn: parent + + QGCLabel { + id: roiLabel + text: qsTr("ROI Disabled") + font.family: ScreenTools.demiboldFontFamily + visible: !roiButton.visible + anchors.horizontalCenter: parent.horizontalCenter + } + + QGCButton { + id: roiButton + visible: activeVehicle && activeVehicle.isROIEnabled + text: qsTr("Disable ROI") + onClicked: { + if(activeVehicle) + activeVehicle.stopGuidedModeROI() + mainWindow.hidePopUp() + } + } + } + } + } + + QGCColoredImage { + id: roiIcon + width: height + anchors.top: parent.top + anchors.bottom: parent.bottom + sourceSize.height: height + source: "/qmlimages/roi.svg" + color: activeVehicle && activeVehicle.isROIEnabled ? qgcPal.colorGreen : qgcPal.text + fillMode: Image.PreserveAspectFit + opacity: activeVehicle && activeVehicle.isROIEnabled ? 1 : 0.5 + } + + MouseArea { + anchors.fill: parent + onClicked: { + mainWindow.showPopUp(_root, roiInfo) + } + } +} -- 2.22.0