From 2815f53d25d64a5986dbcd9c91a6e7fb1f550fb3 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 29 Nov 2024 04:49:08 -0500 Subject: [PATCH] Convert QGCCorePlugin to Singleton --- custom-example/CMakeLists.txt | 1 - custom-example/qgcimages.qrc | 6 + custom-example/qgcresources.qrc | 2 +- custom-example/qgroundcontrol.qrc | 6 +- .../AutoPilotPlugin/CustomAutoPilotPlugin.cc | 5 +- custom-example/src/CustomPlugin.cc | 30 +- custom-example/src/CustomPlugin.h | 18 +- src/API/CMakeLists.txt | 5 +- src/API/QGCCorePlugin.cc | 348 ++++++++---------- src/API/QGCCorePlugin.h | 130 +++---- src/AnalyzeView/MAVLinkConsoleController.cc | 2 - src/CMakeLists.txt | 7 +- src/Camera/QGCCameraManager.cc | 1 - src/Camera/VehicleCameraControl.cc | 2 +- src/Comms/AirLink/AirLinkLink.cc | 1 - src/Comms/AirLink/AirLinkManager.cc | 2 - src/Comms/AirLink/CMakeLists.txt | 1 - src/FactSystem/Fact.cc | 2 +- src/FactSystem/FactMetaData.cc | 2 +- src/FactSystem/SettingsFact.cc | 4 +- src/GPS/GPSRtk.cc | 11 +- src/GPS/GPSRtk.h | 2 + src/MissionManager/ComplexMissionItem.cc | 3 +- src/MissionManager/MissionController.cc | 2 +- src/MissionManager/PlanMasterController.cc | 12 +- src/PositionManager/PositionManager.cpp | 2 +- src/QGCApplication.cc | 14 +- src/QGCApplication.h | 5 - src/QGCToolbox.cc | 53 --- src/QGCToolbox.h | 50 --- .../EditPositionDialogController.cc | 2 - src/QmlControls/FactValueGrid.cc | 4 +- src/QmlControls/HorizontalFactValueGrid.cc | 1 - src/QmlControls/InstrumentValueData.cc | 2 - src/QmlControls/QGCPalette.cc | 1 - src/QmlControls/QGCPalette.h | 6 +- src/QmlControls/QGroundControlQmlGlobal.cc | 36 +- src/QmlControls/QGroundControlQmlGlobal.h | 22 +- src/QmlControls/RCToParamDialogController.cc | 2 - src/Settings/APMMavlinkStreamRateSettings.cc | 1 - src/Settings/APMMavlinkStreamRateSettings.h | 2 +- src/Settings/AppSettings.cc | 1 - src/Settings/GimbalControllerSettings.cc | 3 +- src/Settings/SettingsGroup.cc | 3 +- src/Utilities/CMakeLists.txt | 1 - src/Vehicle/FTPManager.cc | 1 - src/Vehicle/InitialConnectStateMachine.cc | 2 +- src/Vehicle/MultiVehicleManager.cc | 2 +- src/Vehicle/TerrainProtocolHandler.cc | 2 - src/Vehicle/Vehicle.cc | 6 +- src/Vehicle/Vehicle.h | 4 - src/VehicleSetup/FirmwareUpgradeController.cc | 2 +- src/VideoManager/VideoManager.cc | 9 +- .../VideoReceiver/GStreamer/CMakeLists.txt | 1 - test/AnalyzeView/CMakeLists.txt | 1 - test/AnalyzeView/MavlinkLogTest.cc | 1 - test/AutoPilotPlugins/CMakeLists.txt | 1 - test/AutoPilotPlugins/RadioConfigTest.cc | 1 - test/CMakeLists.txt | 1 - test/FactSystem/CMakeLists.txt | 1 - test/FactSystem/FactSystemTestBase.cc | 1 - test/FactSystem/ParameterManagerTest.cc | 1 - test/MissionManager/CMakeLists.txt | 1 - test/MissionManager/CameraSectionTest.cc | 1 - .../MissionCommandTreeEditorTest.cc | 3 +- .../MissionControllerManagerTest.cc | 1 - test/Vehicle/CMakeLists.txt | 1 - test/Vehicle/FTPManagerTest.cc | 1 - test/Vehicle/InitialConnectTest.cc | 1 - test/Vehicle/MAVLinkLogManagerTest.cc | 2 - test/Vehicle/RequestMessageTest.cc | 1 - test/Vehicle/SendMavCommandWithHandlerTest.cc | 1 - .../SendMavCommandWithSignallingTest.cc | 1 - test/Vehicle/VehicleLinkManagerTest.cc | 2 - test/qgcunittest/CMakeLists.txt | 1 - 75 files changed, 339 insertions(+), 531 deletions(-) delete mode 100644 src/QGCToolbox.cc delete mode 100644 src/QGCToolbox.h diff --git a/custom-example/CMakeLists.txt b/custom-example/CMakeLists.txt index 59e6703b756..1d48a96af7c 100644 --- a/custom-example/CMakeLists.txt +++ b/custom-example/CMakeLists.txt @@ -56,7 +56,6 @@ target_link_libraries(CustomPlugin PUBLIC Qt6::Core MAVLink - QGC Settings ) diff --git a/custom-example/qgcimages.qrc b/custom-example/qgcimages.qrc index aeb7855b68f..a4fa9522480 100644 --- a/custom-example/qgcimages.qrc +++ b/custom-example/qgcimages.qrc @@ -61,6 +61,12 @@ ../src/FlightMap/Images/attitudePointer.svg ../src/FlightMap/Images/AwarenessAircraft.svg ../src/UI/toolbar/Images/Battery.svg + ../src/UI/toolbar/Images/BatteryGreen.svg + ../src/UI/toolbar/Images/BatteryYellowGreen.svg + ../src/UI/toolbar/Images/BatteryYellow.svg + ../src/UI/toolbar/Images/BatteryOrange.svg + ../src/UI/toolbar/Images/BatteryCritical.svg + ../src/UI/toolbar/Images/BatteryEMERGENCY.svg ../resources/camera.svg ../src/Camera/images/camera_photo.svg ../src/Camera/images/camera_video.svg diff --git a/custom-example/qgcresources.qrc b/custom-example/qgcresources.qrc index 474fb189766..ad76d00022c 100644 --- a/custom-example/qgcresources.qrc +++ b/custom-example/qgcresources.qrc @@ -45,7 +45,7 @@ ../resources/SplashScreen.png ../resources/Stop.svg ../resources/takeoff.svg - resources/terrain.svg + ../resources/terrain.svg ../resources/TrashDelete.svg ../resources/waves.svg ../resources/wind-guru.svg diff --git a/custom-example/qgroundcontrol.qrc b/custom-example/qgroundcontrol.qrc index be3baa56d4c..9ea6cdf11cb 100644 --- a/custom-example/qgroundcontrol.qrc +++ b/custom-example/qgroundcontrol.qrc @@ -1,8 +1,8 @@ ../src/UI/toolbar/ArmedIndicator.qml - ../src/UI/toolbar/GPSIndicator.qml - ../src/UI/toolbar/GPSRTKIndicator.qml + ../src/UI/toolbar/RTKGPSIndicator.qml + ../src/UI/toolbar/VehicleGPSIndicator.qml ../src/UI/toolbar/JoystickIndicator.qml ../src/UI/toolbar/LinkIndicator.qml ../src/UI/toolbar/MessageIndicator.qml @@ -103,6 +103,7 @@ ../src/QmlControls/FlightModeDropdown.qml ../src/QmlControls/FlightModeMenu.qml ../src/PlanView/FWLandingPatternMapVisual.qml + ../src/UI/toolbar/GPSIndicator.qml ../src/UI/toolbar/GPSIndicatorPage.qml ../src/PlanView/GeoFenceEditor.qml ../src/PlanView/GeoFenceMapVisuals.qml @@ -418,6 +419,7 @@ ../src/MissionManager/VTOLLandingPattern.FactMetaData.json ../src/Settings/Viewer3D.SettingsGroup.json ../src/Settings/GimbalController.SettingsGroup.json + ../src/Camera/CameraMetaData.json ../src/Comms/MockLink/APMArduSubMockLink.params diff --git a/custom-example/src/AutoPilotPlugin/CustomAutoPilotPlugin.cc b/custom-example/src/AutoPilotPlugin/CustomAutoPilotPlugin.cc index fb4f508475a..9281b9ab789 100644 --- a/custom-example/src/AutoPilotPlugin/CustomAutoPilotPlugin.cc +++ b/custom-example/src/AutoPilotPlugin/CustomAutoPilotPlugin.cc @@ -12,7 +12,6 @@ #include "CustomAutoPilotPlugin.h" #include "ParameterManager.h" -#include "QGCApplication.h" #include "QGCCorePlugin.h" #include "Vehicle.h" @@ -20,7 +19,7 @@ CustomAutoPilotPlugin::CustomAutoPilotPlugin(Vehicle* vehicle, QObject* parent) : PX4AutoPilotPlugin(vehicle, parent) { // Whenever we go on/out of advanced mode the available list of settings pages will change - connect(qgcApp()->toolbox()->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomAutoPilotPlugin::_advancedChanged); + connect(QGCCorePlugin::instance(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomAutoPilotPlugin::_advancedChanged); } // This signals that when Advanced Mode changes the list of Vehicle Settings page also changed @@ -35,7 +34,7 @@ const QVariantList& CustomAutoPilotPlugin::vehicleComponents() { if (_components.count() == 0 && !_incorrectParameterVersion) { if (_vehicle) { - bool showAdvanced = qgcApp()->toolbox()->corePlugin()->showAdvancedUI(); + bool showAdvanced = QGCCorePlugin::instance()->showAdvancedUI(); if (_vehicle->parameterManager()->parametersReady()) { if (showAdvanced) { _airframeComponent = new AirframeComponent(_vehicle, this); diff --git a/custom-example/src/CustomPlugin.cc b/custom-example/src/CustomPlugin.cc index ff1838fdf35..220c6db06a2 100644 --- a/custom-example/src/CustomPlugin.cc +++ b/custom-example/src/CustomPlugin.cc @@ -10,15 +10,19 @@ */ #include "CustomPlugin.h" -#include "QGCApplication.h" #include "QmlComponentInfo.h" #include "QGCPalette.h" +#include "QGCMAVLink.h" #include "AppSettings.h" #include "BrandImageSettings.h" + +#include #include QGC_LOGGING_CATEGORY(CustomLog, "gcs.custom.customplugin") +Q_APPLICATION_STATIC(CustomPlugin, _customPluginInstance); + CustomFlyViewOptions::CustomFlyViewOptions(CustomOptions* options, QObject* parent) : QGCFlyViewOptions(options, parent) { @@ -37,9 +41,11 @@ bool CustomFlyViewOptions::showInstrumentPanel(void) const return false; } -CustomOptions::CustomOptions(CustomPlugin*, QObject* parent) +CustomOptions::CustomOptions(CustomPlugin *plugin, QObject *parent) : QGCOptions(parent) + , _plugin(plugin) { + Q_CHECK_PTR(_plugin); } QGCFlyViewOptions* CustomOptions::flyViewOptions(void) @@ -53,7 +59,7 @@ QGCFlyViewOptions* CustomOptions::flyViewOptions(void) // Firmware upgrade page is only shown in Advanced Mode. bool CustomOptions::showFirmwareUpgrade() const { - return qgcApp()->toolbox()->corePlugin()->showAdvancedUI(); + return _plugin->showAdvancedUI(); } // Normal QGC needs to work with an ESP8266 WiFi thing which is remarkably crappy. This in turns causes PX4 Pro calibration to fail @@ -64,23 +70,21 @@ bool CustomOptions::wifiReliableForCalibration(void) const return true; } -CustomPlugin::CustomPlugin(QGCApplication *app, QGCToolbox* toolbox) - : QGCCorePlugin(app, toolbox) +CustomPlugin::CustomPlugin(QObject *parent) + : QGCCorePlugin(parent) + , _options(new CustomOptions(this, this)) { - _options = new CustomOptions(this, this); _showAdvancedUI = false; + connect(this, &QGCCorePlugin::showAdvancedUIChanged, this, &CustomPlugin::_advancedChanged); } CustomPlugin::~CustomPlugin() { } -void CustomPlugin::setToolbox(QGCToolbox* toolbox) +QGCCorePlugin *CustomPlugin::instance() { - QGCCorePlugin::setToolbox(toolbox); - - // Allows us to be notified when the user goes in/out out advanced mode - connect(qgcApp()->toolbox()->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &CustomPlugin::_advancedChanged); + return _customPluginInstance(); } void CustomPlugin::_advancedChanged(bool changed) @@ -116,7 +120,7 @@ QString CustomPlugin::brandImageOutdoor(void) const return QStringLiteral("/custom/img/dronecode-black.svg"); } -bool CustomPlugin::overrideSettingsGroupVisibility(QString name) +bool CustomPlugin::overrideSettingsGroupVisibility(const QString &name) { // We have set up our own specific brand imaging. Hide the brand image settings such that the end user // can't change it. @@ -147,7 +151,7 @@ bool CustomPlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaD } // This modifies QGC colors palette to match possible custom corporate branding -void CustomPlugin::paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo) +void CustomPlugin::paletteOverride(const QString &colorName, QGCPalette::PaletteColorInfo_t& colorInfo) { if (colorName == QStringLiteral("window")) { colorInfo[QGCPalette::Dark][QGCPalette::ColorGroupEnabled] = QColor("#212529"); diff --git a/custom-example/src/CustomPlugin.h b/custom-example/src/CustomPlugin.h index e0ef9c4448d..bab143ae47d 100644 --- a/custom-example/src/CustomPlugin.h +++ b/custom-example/src/CustomPlugin.h @@ -15,7 +15,7 @@ #include "QGCCorePlugin.h" #include "QGCOptions.h" -#include +#include "QGCLoggingCategory.h" class CustomOptions; class CustomPlugin; @@ -37,7 +37,7 @@ class CustomFlyViewOptions : public QGCFlyViewOptions class CustomOptions : public QGCOptions { public: - CustomOptions(CustomPlugin*, QObject* parent = nullptr); + CustomOptions(CustomPlugin *plugin, QObject* parent = nullptr); // Overrides from QGCOptions bool wifiReliableForCalibration (void) const final; @@ -45,28 +45,28 @@ class CustomOptions : public QGCOptions QGCFlyViewOptions* flyViewOptions(void) final; private: - CustomFlyViewOptions* _flyViewOptions = nullptr; + QGCCorePlugin *_plugin = nullptr; + CustomFlyViewOptions *_flyViewOptions = nullptr; }; class CustomPlugin : public QGCCorePlugin { Q_OBJECT public: - CustomPlugin(QGCApplication* app, QGCToolbox *toolbox); + CustomPlugin(QObject *parent = nullptr); ~CustomPlugin(); + static QGCCorePlugin *instance(); + // Overrides from QGCCorePlugin QGCOptions* options (void) final; QString brandImageIndoor (void) const final; QString brandImageOutdoor (void) const final; - bool overrideSettingsGroupVisibility (QString name) final; + bool overrideSettingsGroupVisibility (const QString &name) final; bool adjustSettingMetaData (const QString& settingsGroup, FactMetaData& metaData) final; - void paletteOverride (QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo) final; + void paletteOverride (const QString &colorName, QGCPalette::PaletteColorInfo_t& colorInfo) final; QQmlApplicationEngine* createQmlApplicationEngine (QObject* parent) final; - // Overrides from QGCTool - void setToolbox (QGCToolbox* toolbox); - private slots: void _advancedChanged(bool advanced); diff --git a/src/API/CMakeLists.txt b/src/API/CMakeLists.txt index 460ad3819cc..dd7f734fa88 100644 --- a/src/API/CMakeLists.txt +++ b/src/API/CMakeLists.txt @@ -26,8 +26,11 @@ target_link_libraries(API Qt6::Core Qt6::Gui MAVLink - QGC QmlControls ) target_include_directories(API PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) + +if(QGC_CUSTOM_BUILD) + target_link_libraries(API PRIVATE CustomPlugin) +endif() diff --git a/src/API/QGCCorePlugin.cc b/src/API/QGCCorePlugin.cc index e57159e0ce5..4f284be4674 100644 --- a/src/API/QGCCorePlugin.cc +++ b/src/API/QGCCorePlugin.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "QGCCorePlugin.h" -#include "QGCApplication.h" #include "QGCOptions.h" #include "QmlComponentInfo.h" #include "FactMetaData.h" @@ -27,137 +26,143 @@ #include "HorizontalFactValueGrid.h" #include "InstrumentValueData.h" #include "QGCLoggingCategory.h" +#ifdef QGC_CUSTOM_BUILD +#include CUSTOMHEADER +#endif -#include +#include #include #include +#include -/// @file -/// @brief Core Plugin Interface for QGroundControl - Default Implementation -/// @author Gus Grubba +QGC_LOGGING_CATEGORY(QGCCorePluginLog, "qgc.api.qgccoreplugin"); -class QGCCorePlugin_p -{ -public: - QGCCorePlugin_p() - { - } +#ifndef QGC_CUSTOM_BUILD +Q_APPLICATION_STATIC(QGCCorePlugin, _qgcCorePluginInstance); +#endif +struct QGCCorePlugin_p +{ ~QGCCorePlugin_p() { - if(pGeneral) + if (pGeneral) { delete pGeneral; - if(pCommLinks) + } + if (pCommLinks) { delete pCommLinks; - if(pOfflineMaps) + } + if (pOfflineMaps) { delete pOfflineMaps; - if(pMAVLink) + } + if (pMAVLink) { delete pMAVLink; - if(pConsole) + } + if (pConsole) { delete pConsole; -#if defined(QT_DEBUG) - if(pMockLink) + } +#ifdef QT_DEBUG + if (pMockLink) { delete pMockLink; - if(pDebug) + } + if (pDebug) { delete pDebug; - if(pQmlTest) + } + if (pQmlTest) { delete pQmlTest; + } #endif - if(pRemoteID) + if (pRemoteID) { delete pRemoteID; - if(defaultOptions) + } + if (defaultOptions) { delete defaultOptions; + } } - QmlComponentInfo* pGeneral = nullptr; - QmlComponentInfo* pCommLinks = nullptr; - QmlComponentInfo* pOfflineMaps = nullptr; - QmlComponentInfo* pMAVLink = nullptr; - QmlComponentInfo* pConsole = nullptr; - QmlComponentInfo* pHelp = nullptr; -#if defined(QT_DEBUG) - QmlComponentInfo* pMockLink = nullptr; - QmlComponentInfo* pDebug = nullptr; - QmlComponentInfo* pQmlTest = nullptr; + QmlComponentInfo *pGeneral = nullptr; + QmlComponentInfo *pCommLinks = nullptr; + QmlComponentInfo *pOfflineMaps = nullptr; + QmlComponentInfo *pMAVLink = nullptr; + QmlComponentInfo *pConsole = nullptr; + QmlComponentInfo *pHelp = nullptr; +#ifdef QT_DEBUG + QmlComponentInfo *pMockLink = nullptr; + QmlComponentInfo *pDebug = nullptr; + QmlComponentInfo *pQmlTest = nullptr; #endif - QmlComponentInfo* pRemoteID = nullptr; + QmlComponentInfo *pRemoteID = nullptr; - QGCOptions* defaultOptions = nullptr; - QVariantList settingsList; - QVariantList analyzeList; + QGCOptions *defaultOptions = nullptr; + QVariantList settingsList; + QVariantList analyzeList; QmlObjectListModel _emptyCustomMapItems; }; +QGCCorePlugin::QGCCorePlugin(QObject *parent) + : QObject(parent) + , _p(new QGCCorePlugin_p()) +{ + // qCDebug(QGCCorePluginLog) << Q_FUNC_INFO << this; +} + QGCCorePlugin::~QGCCorePlugin() { - if(_p) { + // qCDebug(QGCCorePluginLog) << Q_FUNC_INFO << this; + + if (_p) { delete _p; } } -QGCCorePlugin::QGCCorePlugin(QGCApplication *app, QGCToolbox* toolbox) - : QGCTool(app, toolbox) - , _showTouchAreas(false) - , _showAdvancedUI(true) +QGCCorePlugin *QGCCorePlugin::instance() { - QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); - _p = new QGCCorePlugin_p; +#ifndef QGC_CUSTOM_BUILD + return _qgcCorePluginInstance(); +#else + return CUSTOMCLASS::instance(); +#endif } -void QGCCorePlugin::setToolbox(QGCToolbox *toolbox) +void QGCCorePlugin::registerQmlTypes() { - QGCTool::setToolbox(toolbox); - - qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QGCCorePlugin", "Reference only"); - qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QGCOptions", "Reference only"); - qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QGCFlyViewOptions", "Reference only"); + (void) qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QGCCorePlugin", QStringLiteral("Reference only")); + (void) qmlRegisterUncreatableType ("QGroundControl", 1, 0, "QGCOptions", QStringLiteral("Reference only")); + (void) qmlRegisterUncreatableType("QGroundControl", 1, 0, "QGCFlyViewOptions", QStringLiteral("Reference only")); } -QVariantList& QGCCorePlugin::analyzePages() +QVariantList &QGCCorePlugin::analyzePages() { - if (!_p->analyzeList.count()) { - _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("Log Download"), QUrl::fromUserInput("qrc:/qml/LogDownloadPage.qml"), QUrl::fromUserInput("qrc:/qmlimages/LogDownloadIcon")))); -#if !defined(__mobile__) - _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("GeoTag Images"), QUrl::fromUserInput("qrc:/qml/GeoTagPage.qml"), QUrl::fromUserInput("qrc:/qmlimages/GeoTagIcon")))); + if (_p->analyzeList.isEmpty()) { + _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("Log Download"), QUrl::fromUserInput(QStringLiteral("qrc:/qml/LogDownloadPage.qml")), QUrl::fromUserInput(QStringLiteral("qrc:/qmlimages/LogDownloadIcon"))))); +#if !defined(Q_OS_ANDROID) && !defined(Q_OS_IOS) + _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("GeoTag Images"), QUrl::fromUserInput(QStringLiteral("qrc:/qml/GeoTagPage.qml")), QUrl::fromUserInput(QStringLiteral("qrc:/qmlimages/GeoTagIcon"))))); #endif - _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("MAVLink Console"), QUrl::fromUserInput("qrc:/qml/MAVLinkConsolePage.qml"), QUrl::fromUserInput("qrc:/qmlimages/MAVLinkConsoleIcon")))); -#if !defined(QGC_DISABLE_MAVLINK_INSPECTOR) - _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("MAVLink Inspector"),QUrl::fromUserInput("qrc:/qml/MAVLinkInspectorPage.qml"), QUrl::fromUserInput("qrc:/qmlimages/MAVLinkInspector")))); + _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("MAVLink Console"), QUrl::fromUserInput(QStringLiteral("qrc:/qml/MAVLinkConsolePage.qml")), QUrl::fromUserInput(QStringLiteral("qrc:/qmlimages/MAVLinkConsoleIcon"))))); +#ifndef QGC_DISABLE_MAVLINK_INSPECTOR + _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("MAVLink Inspector"), QUrl::fromUserInput(QStringLiteral("qrc:/qml/MAVLinkInspectorPage.qml")), QUrl::fromUserInput(QStringLiteral("qrc:/qmlimages/MAVLinkInspector"))))); #endif - _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("Vibration"), QUrl::fromUserInput("qrc:/qml/VibrationPage.qml"), QUrl::fromUserInput("qrc:/qmlimages/VibrationPageIcon")))); + _p->analyzeList.append(QVariant::fromValue(new QmlComponentInfo(tr("Vibration"), QUrl::fromUserInput(QStringLiteral("qrc:/qml/VibrationPage.qml")), QUrl::fromUserInput(QStringLiteral("qrc:/qmlimages/VibrationPageIcon"))))); } - return _p->analyzeList; -} -int QGCCorePlugin::defaultSettings() -{ - return 0; + return _p->analyzeList; } -QGCOptions* QGCCorePlugin::options() +QGCOptions *QGCCorePlugin::options() { if (!_p->defaultOptions) { _p->defaultOptions = new QGCOptions(this); } - return _p->defaultOptions; -} -bool QGCCorePlugin::overrideSettingsGroupVisibility(QString name) -{ - Q_UNUSED(name); - - // Always show all - return true; + return _p->defaultOptions; } -bool QGCCorePlugin::adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData) +bool QGCCorePlugin::adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData) { if (settingsGroup == AppSettings::settingsGroup) { - //-- Default Palette if (metaData.name() == AppSettings::indoorPaletteName) { QVariant outdoorPalette; -#if defined (__mobile__) +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) outdoorPalette = 0; #else outdoorPalette = 1; @@ -165,45 +170,20 @@ bool QGCCorePlugin::adjustSettingMetaData(const QString& settingsGroup, FactMeta metaData.setRawDefaultValue(outdoorPalette); return true; } - -#if defined (__mobile__) - if (metaData.name() == AppSettings::telemetrySaveName) { - // Mobile devices have limited storage so don't turn on telemtry saving by default +#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) + else if (metaData.name() == AppSettings::telemetrySaveName) { metaData.setRawDefaultValue(false); return true; } #endif - #ifndef Q_OS_ANDROID - if (metaData.name() == AppSettings::androidSaveToSDCardName) { - // This only shows on android builds + else if (metaData.name() == AppSettings::androidSaveToSDCardName) { return false; } #endif } - return true; // Show setting in ui -} - -void QGCCorePlugin::setShowTouchAreas(bool show) -{ - if (show != _showTouchAreas) { - _showTouchAreas = show; - emit showTouchAreasChanged(show); - } -} - -void QGCCorePlugin::setShowAdvancedUI(bool show) -{ - if (show != _showAdvancedUI) { - _showAdvancedUI = show; - emit showAdvancedUIChanged(show); - } -} - -void QGCCorePlugin::paletteOverride(QString /*colorName*/, QGCPalette::PaletteColorInfo_t& /*colorInfo*/) -{ - + return true; } QString QGCCorePlugin::showAdvancedUIMessage() const @@ -214,96 +194,89 @@ QString QGCCorePlugin::showAdvancedUIMessage() const "Are you sure you want to enable Advanced Mode?"); } -void QGCCorePlugin::factValueGridCreateDefaultSettings(const QString& defaultSettingsGroup) +void QGCCorePlugin::factValueGridCreateDefaultSettings(const QString &defaultSettingsGroup) { HorizontalFactValueGrid factValueGrid(defaultSettingsGroup); - bool includeFWValues = factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassFixedWing || factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassVTOL || factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassAirship; + const bool includeFWValues = ((factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassFixedWing) || (factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassVTOL) || (factValueGrid.vehicleClass() == QGCMAVLink::VehicleClassAirship)); factValueGrid.setFontSize(FactValueGrid::LargeFontSize); - factValueGrid.appendColumn(); - factValueGrid.appendColumn(); - factValueGrid.appendColumn(); + (void) factValueGrid.appendColumn(); + (void) factValueGrid.appendColumn(); + (void) factValueGrid.appendColumn(); if (includeFWValues) { - factValueGrid.appendColumn(); + (void) factValueGrid.appendColumn(); } factValueGrid.appendRow(); - int rowIndex = 0; - QmlObjectListModel* column = factValueGrid.columns()->value(0); + int rowIndex = 0; + QmlObjectListModel *column = factValueGrid.columns()->value(0); - InstrumentValueData* value = column->value(rowIndex++); - value->setFact("Vehicle", "AltitudeRelative"); - value->setIcon("arrow-thick-up.svg"); + InstrumentValueData *value = column->value(rowIndex++); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("AltitudeRelative")); + value->setIcon(QStringLiteral("arrow-thick-up.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); value = column->value(rowIndex++); - value->setFact("Vehicle", "DistanceToHome"); - value->setIcon("bookmark copy 3.svg"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("DistanceToHome")); + value->setIcon(QStringLiteral("bookmark copy 3.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); - rowIndex = 0; - column = factValueGrid.columns()->value(1); + rowIndex = 0; + column = factValueGrid.columns()->value(1); value = column->value(rowIndex++); - value->setFact("Vehicle", "ClimbRate"); - value->setIcon("arrow-simple-up.svg"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("ClimbRate")); + value->setIcon(QStringLiteral("arrow-simple-up.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); value = column->value(rowIndex++); - value->setFact("Vehicle", "GroundSpeed"); - value->setIcon("arrow-simple-right.svg"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("GroundSpeed")); + value->setIcon(QStringLiteral("arrow-simple-right.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); - if (includeFWValues) { - rowIndex = 0; - column = factValueGrid.columns()->value(2); + rowIndex = 0; + column = factValueGrid.columns()->value(2); value = column->value(rowIndex++); - value->setFact("Vehicle", "AirSpeed"); - value->setText("AirSpd"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("AirSpeed")); + value->setText(QStringLiteral("AirSpd")); value->setShowUnits(true); value = column->value(rowIndex++); - value->setFact("Vehicle", "ThrottlePct"); - value->setText("Thr"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("ThrottlePct")); + value->setText(QStringLiteral("Thr")); value->setShowUnits(true); } - rowIndex = 0; - column = factValueGrid.columns()->value(includeFWValues ? 3 : 2); + rowIndex = 0; + column = factValueGrid.columns()->value(includeFWValues ? 3 : 2); value = column->value(rowIndex++); - value->setFact("Vehicle", "FlightTime"); - value->setIcon("timer.svg"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("FlightTime")); + value->setIcon(QStringLiteral("timer.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(false); value = column->value(rowIndex++); - value->setFact("Vehicle", "FlightDistance"); - value->setIcon("travel-walk.svg"); + value->setFact(QStringLiteral("Vehicle"), QStringLiteral("FlightDistance")); + value->setIcon(QStringLiteral("travel-walk.svg")); value->setText(value->fact()->shortDescription()); value->setShowUnits(true); } -QQmlApplicationEngine* QGCCorePlugin::createQmlApplicationEngine(QObject* parent) +QQmlApplicationEngine *QGCCorePlugin::createQmlApplicationEngine(QObject *parent) { - QQmlApplicationEngine* qmlEngine = new QQmlApplicationEngine(parent); - /* EventDatabase eventDatabase; - EventMonitor eventMonitor; - qmlEngine->setInitialProperties({ - { "eventDatabase", QVariant::fromValue(&eventDatabase) }, - { "eventMonitor", QVariant::fromValue(&eventMonitor) } - }); */ - qmlEngine->addImportPath("qrc:/qml"); - qmlEngine->rootContext()->setContextProperty("joystickManager", JoystickManager::instance()); - qmlEngine->rootContext()->setContextProperty("debugMessageModel", AppMessages::getModel()); + QQmlApplicationEngine *const qmlEngine = new QQmlApplicationEngine(parent); + qmlEngine->addImportPath(QStringLiteral("qrc:/qml")); + qmlEngine->rootContext()->setContextProperty(QStringLiteral("joystickManager"), JoystickManager::instance()); + qmlEngine->rootContext()->setContextProperty(QStringLiteral("debugMessageModel"), AppMessages::getModel()); return qmlEngine; } @@ -312,21 +285,12 @@ void QGCCorePlugin::createRootWindow(QQmlApplicationEngine* qmlEngine) qmlEngine->load(QUrl(QStringLiteral("qrc:/qml/MainRootWindow.qml"))); } -bool QGCCorePlugin::mavlinkMessage(Vehicle* vehicle, LinkInterface* link, mavlink_message_t message) -{ - Q_UNUSED(vehicle); - Q_UNUSED(link); - Q_UNUSED(message); - - return true; -} - -QmlObjectListModel* QGCCorePlugin::customMapItems() +QmlObjectListModel *QGCCorePlugin::customMapItems() const { return &_p->_emptyCustomMapItems; } -VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject* parent) +VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject *parent) { #ifdef QGC_GST_STREAMING return GStreamer::createVideoReceiver(parent); @@ -337,23 +301,27 @@ VideoReceiver* QGCCorePlugin::createVideoReceiver(QObject* parent) #endif } -void* QGCCorePlugin::createVideoSink(QObject* parent, QQuickItem* widget) +void *QGCCorePlugin::createVideoSink(QObject *parent, QQuickItem *widget) { #ifdef QGC_GST_STREAMING return GStreamer::createVideoSink(parent, widget); #elif defined(QGC_QT_STREAMING) return QtMultimediaReceiver::createVideoSink(parent, widget); #else + Q_UNUSED(parent); + Q_UNUSED(widget); return nullptr; #endif } -void QGCCorePlugin::releaseVideoSink(void* sink) +void QGCCorePlugin::releaseVideoSink(void *sink) { #ifdef QGC_GST_STREAMING GStreamer::releaseVideoSink(sink); #elif defined(QGC_QT_STREAMING) QtMultimediaReceiver::releaseVideoSink(sink); +#else + Q_UNUSED(sink); #endif } @@ -365,36 +333,26 @@ bool QGCCorePlugin::guidedActionsControllerLogging() const QString QGCCorePlugin::stableVersionCheckFileUrl() const { #ifdef QGC_CUSTOM_BUILD - // Custom builds must override to turn on and provide their own location return QString(); #else - return QString("https://s3-us-west-2.amazonaws.com/qgroundcontrol/latest/QGC.version.txt"); + return QStringLiteral("https://s3-us-west-2.amazonaws.com/qgroundcontrol/latest/QGC.version.txt"); #endif } -const QVariantList& QGCCorePlugin::toolBarIndicators(void) +const QVariantList &QGCCorePlugin::toolBarIndicators() { - //-- Default list of indicators for all vehicles. - if(_toolBarIndicatorList.size() == 0) { - _toolBarIndicatorList = QVariantList({ - QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/RTKGPSIndicator.qml")), - }); + if (_toolBarIndicatorList.isEmpty()) { + _toolBarIndicatorList = QVariantList( + { + QVariant::fromValue(QUrl::fromUserInput(QStringLiteral("qrc:/toolbar/RTKGPSIndicator.qml"))), + } + ); } - return _toolBarIndicatorList; -} - -QList QGCCorePlugin::firstRunPromptStdIds(void) -{ - QList rgStdIds = { unitsFirstRunPromptId, offlineVehicleFirstRunPromptId }; - return rgStdIds; -} -QList QGCCorePlugin::firstRunPromptCustomIds(void) -{ - return QList(); + return _toolBarIndicatorList; } -QVariantList QGCCorePlugin::firstRunPromptsToShow(void) +QVariantList QGCCorePlugin::firstRunPromptsToShow() { QList rgIdsToShow; @@ -402,9 +360,8 @@ QVariantList QGCCorePlugin::firstRunPromptsToShow(void) rgIdsToShow.append(firstRunPromptCustomIds()); QList rgAlreadyShownIds = AppSettings::firstRunPromptsIdsVariantToList(SettingsManager::instance()->appSettings()->firstRunPromptIdsShown()->rawValue()); - for (int idToRemove: rgAlreadyShownIds) { - rgIdsToShow.removeOne(idToRemove); + (void) rgIdsToShow.removeOne(idToRemove); } QVariantList rgVarIdsToShow; @@ -418,12 +375,27 @@ QVariantList QGCCorePlugin::firstRunPromptsToShow(void) QString QGCCorePlugin::firstRunPromptResource(int id) { switch (id) { - case unitsFirstRunPromptId: - return "/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml"; - case offlineVehicleFirstRunPromptId: - return "/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml"; - break; + case kUnitsFirstRunPromptId: + return QStringLiteral("/FirstRunPromptDialogs/UnitsFirstRunPrompt.qml"); + case kOfflineVehicleFirstRunPromptId: + return QStringLiteral("/FirstRunPromptDialogs/OfflineVehicleFirstRunPrompt.qml"); + default: + return QString(); } +} - return QString(); +void QGCCorePlugin::_setShowTouchAreas(bool show) +{ + if (show != _showTouchAreas) { + _showTouchAreas = show; + emit showTouchAreasChanged(show); + } +} + +void QGCCorePlugin::_setShowAdvancedUI(bool show) +{ + if (show != _showAdvancedUI) { + _showAdvancedUI = show; + emit showAdvancedUIChanged(show); + } } diff --git a/src/API/QGCCorePlugin.h b/src/API/QGCCorePlugin.h index 9255cbd4672..3cbf5d0bdfa 100644 --- a/src/API/QGCCorePlugin.h +++ b/src/API/QGCCorePlugin.h @@ -9,19 +9,18 @@ #pragma once -#include "QGCToolbox.h" #include "QGCPalette.h" -#include "QGCMAVLink.h" +#include "MAVLinkLib.h" +#include +#include #include #include -#include /// @file /// @brief Core Plugin Interface for QGroundControl /// @author Gus Grubba -class QGCApplication; class QGCOptions; class QGCSettings; class QGCCorePlugin_p; @@ -38,53 +37,56 @@ class QGCCameraManager; class MavlinkCameraControl; class QQuickItem; +Q_DECLARE_LOGGING_CATEGORY(QGCCorePluginLog) -class QGCCorePlugin : public QGCTool +class QGCCorePlugin : public QObject { Q_OBJECT Q_MOC_INCLUDE("QGCOptions.h") Q_MOC_INCLUDE("QmlObjectListModel.h") + Q_PROPERTY(bool showAdvancedUI READ showAdvancedUI WRITE _setShowAdvancedUI NOTIFY showAdvancedUIChanged) + Q_PROPERTY(bool showTouchAreas READ showTouchAreas WRITE _setShowTouchAreas NOTIFY showTouchAreasChanged) + Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) + Q_PROPERTY(int offlineVehicleFirstRunPromptId MEMBER kOfflineVehicleFirstRunPromptId CONSTANT) + Q_PROPERTY(int unitsFirstRunPromptId MEMBER kUnitsFirstRunPromptId CONSTANT) + Q_PROPERTY(QGCOptions *options READ options CONSTANT) + Q_PROPERTY(QmlObjectListModel *customMapItems READ customMapItems CONSTANT) + Q_PROPERTY(QString brandImageIndoor READ brandImageIndoor CONSTANT) + Q_PROPERTY(QString brandImageOutdoor READ brandImageOutdoor CONSTANT) + Q_PROPERTY(QString showAdvancedUIMessage READ showAdvancedUIMessage CONSTANT) + Q_PROPERTY(QVariantList analyzePages READ analyzePages NOTIFY analyzePagesChanged) + Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) public: - QGCCorePlugin(QGCApplication* app, QGCToolbox* toolbox); + explicit QGCCorePlugin(QObject *parent = nullptr); ~QGCCorePlugin(); - Q_PROPERTY(QVariantList analyzePages READ analyzePages NOTIFY analyzePagesChanged) - Q_PROPERTY(int defaultSettings READ defaultSettings CONSTANT) - Q_PROPERTY(QGCOptions* options READ options CONSTANT) - Q_PROPERTY(bool showTouchAreas READ showTouchAreas WRITE setShowTouchAreas NOTIFY showTouchAreasChanged) - Q_PROPERTY(bool showAdvancedUI READ showAdvancedUI WRITE setShowAdvancedUI NOTIFY showAdvancedUIChanged) - Q_PROPERTY(QString showAdvancedUIMessage READ showAdvancedUIMessage CONSTANT) - Q_PROPERTY(QString brandImageIndoor READ brandImageIndoor CONSTANT) - Q_PROPERTY(QString brandImageOutdoor READ brandImageOutdoor CONSTANT) - Q_PROPERTY(QmlObjectListModel* customMapItems READ customMapItems CONSTANT) - Q_PROPERTY(QVariantList toolBarIndicators READ toolBarIndicators NOTIFY toolBarIndicatorsChanged) - Q_PROPERTY(int unitsFirstRunPromptId MEMBER unitsFirstRunPromptId CONSTANT) - Q_PROPERTY(int offlineVehicleFirstRunPromptId MEMBER offlineVehicleFirstRunPromptId CONSTANT) + static QGCCorePlugin *instance(); + static void registerQmlTypes(); Q_INVOKABLE bool guidedActionsControllerLogging() const; /// The list of pages/buttons under the Analyze Menu /// @return A list of QmlPageInfo - virtual QVariantList& analyzePages(); + virtual QVariantList &analyzePages(); /// The default settings panel to show /// @return The settings index - virtual int defaultSettings(); + virtual int defaultSettings() { return 0; } /// Global options /// @return An instance of QGCOptions - virtual QGCOptions* options(); + virtual QGCOptions *options(); /// Allows the core plugin to override the visibility for a settings group /// @param name - SettingsGroup name /// @return true: Show settings ui, false: Hide settings ui - virtual bool overrideSettingsGroupVisibility(QString name); + virtual bool overrideSettingsGroupVisibility(const QString &name) { Q_UNUSED(name); return true; } /// Allows the core plugin to override the setting meta data before the setting fact is created. /// @param settingsGroup - QSettings group which contains this item /// @param metaData - MetaData for setting fact /// @return true: Setting should be visible in ui, false: Setting should not be shown in ui - virtual bool adjustSettingMetaData(const QString& settingsGroup, FactMetaData& metaData); + virtual bool adjustSettingMetaData(const QString &settingsGroup, FactMetaData &metaData); /// Return the resource file which contains the brand image for for Indoor theme. virtual QString brandImageIndoor() const { return QString(); } @@ -96,48 +98,48 @@ class QGCCorePlugin : public QGCTool virtual QString showAdvancedUIMessage() const; /// @return An instance of an alternate position source (or NULL if not available) - virtual QGeoPositionInfoSource* createPositionSource(QObject* /*parent*/) { return nullptr; } + virtual QGeoPositionInfoSource *createPositionSource(QObject *parent) { Q_UNUSED(parent); return nullptr; } /// Allows a plugin to override the specified color name from the palette - virtual void paletteOverride(QString colorName, QGCPalette::PaletteColorInfo_t& colorInfo); + virtual void paletteOverride(const QString &colorName, QGCPalette::PaletteColorInfo_t &colorInfo) { Q_UNUSED(colorName); Q_UNUSED(colorInfo); }; - virtual void factValueGridCreateDefaultSettings(const QString& defaultSettingsGroup); + virtual void factValueGridCreateDefaultSettings(const QString &defaultSettingsGroup); /// Allows the plugin to override or get access to the QmlApplicationEngine to do things like add import /// path or stuff things into the context prior to window creation. - virtual QQmlApplicationEngine* createQmlApplicationEngine(QObject* parent); + virtual QQmlApplicationEngine *createQmlApplicationEngine(QObject *parent); /// Allows the plugin to override the creation of the root (native) window. - virtual void createRootWindow(QQmlApplicationEngine* qmlEngine); + virtual void createRootWindow(QQmlApplicationEngine *qmlEngine); /// Allows the plugin to override the creation of VideoReceiver. - virtual VideoReceiver* createVideoReceiver(QObject* parent); + virtual VideoReceiver *createVideoReceiver(QObject *parent); /// Allows the plugin to override the creation of VideoSink. - virtual void* createVideoSink(QObject* parent, QQuickItem* widget); + virtual void *createVideoSink(QObject *parent, QQuickItem *widget); /// Allows the plugin to override the release of VideoSink. - virtual void releaseVideoSink(void* sink); + virtual void releaseVideoSink(void *sink); /// Allows the plugin to see all mavlink traffic to a vehicle /// @return true: Allow vehicle to continue processing, false: Vehicle should not process message - virtual bool mavlinkMessage(Vehicle* vehicle, LinkInterface* link, mavlink_message_t message); + virtual bool mavlinkMessage(Vehicle *vehicle, LinkInterface *link, const mavlink_message_t &message) { Q_UNUSED(vehicle); Q_UNUSED(link); Q_UNUSED(message); return true; } /// Allows custom builds to add custom items to the FlightMap. Objects put into QmlObjectListModel should derive from QmlComponentInfo and set the url property. - virtual QmlObjectListModel* customMapItems(); + virtual QmlObjectListModel *customMapItems() const; /// Allows custom builds to add custom items to the plan file before the document is created. - virtual void preSaveToJson (PlanMasterController* /*pController*/, QJsonObject& /*json*/) {} + virtual void preSaveToJson(PlanMasterController *pController, QJsonObject &json) { Q_UNUSED(pController); Q_UNUSED(json); } /// Allows custom builds to add custom items to the plan file after the document is created. - virtual void postSaveToJson (PlanMasterController* /*pController*/, QJsonObject& /*json*/) {} + virtual void postSaveToJson(PlanMasterController *pController, QJsonObject &json) { Q_UNUSED(pController); Q_UNUSED(json); } /// Allows custom builds to add custom items to the mission section of the plan file before the item is created. - virtual void preSaveToMissionJson (PlanMasterController* /*pController*/, QJsonObject& /*missionJson*/) {} + virtual void preSaveToMissionJson(PlanMasterController *pController, QJsonObject &missionJson) { Q_UNUSED(pController); Q_UNUSED(missionJson); } /// Allows custom builds to add custom items to the mission section of the plan file after the item is created. - virtual void postSaveToMissionJson (PlanMasterController* /*pController*/, QJsonObject& /*missionJson*/) {} + virtual void postSaveToMissionJson(PlanMasterController *pController, QJsonObject& missionJson) { Q_UNUSED(pController); Q_UNUSED(missionJson); } /// Allows custom builds to load custom items from the plan file before the document is parsed. - virtual void preLoadFromJson (PlanMasterController* /*pController*/, QJsonObject& /*json*/) {} + virtual void preLoadFromJson(PlanMasterController *pController, QJsonObject &json) { Q_UNUSED(pController); Q_UNUSED(json); } /// Allows custom builds to load custom items from the plan file after the document is parsed. - virtual void postLoadFromJson (PlanMasterController* /*pController*/, QJsonObject& /*json*/) {} + virtual void postLoadFromJson(PlanMasterController *pController, QJsonObject &json) { Q_UNUSED(pController); Q_UNUSED(json); } /// Returns the url to download the stable version check file. Return QString() to indicate no version check should be performed. /// Default QGC mainline implemenentation returns QGC Stable file location. Default QGC custom build code returns QString(). @@ -149,22 +151,22 @@ class QGCCorePlugin : public QGCTool /// Returns the user visible url to show user where to download new stable builds from. /// Custom builds must override to provide their own location. - virtual QString stableDownloadLocation() const { return QString("qgroundcontrol.com"); } + virtual QString stableDownloadLocation() const { return QStringLiteral("qgroundcontrol.com"); } /// Returns the complex mission items to display in the Plan UI /// @param complexMissionItemNames Default set of complex items /// @return Complex items to be made available to user - virtual QStringList complexMissionItemNames(Vehicle* /*vehicle*/, const QStringList& complexMissionItemNames) { return complexMissionItemNames; } + virtual QStringList complexMissionItemNames(Vehicle *vehicle, const QStringList &complexMissionItemNames) { Q_UNUSED(vehicle); return complexMissionItemNames; } /// Returns the standard list of first run prompt ids for possible display. Actual display is based on the /// current AppSettings::firstRunPromptIds value. The order of this list also determines the order the prompts /// will be displayed in. - virtual QList firstRunPromptStdIds(void); + virtual QList firstRunPromptStdIds() { return QList({ kUnitsFirstRunPromptId, kOfflineVehicleFirstRunPromptId }); } /// Returns the custom build list of first run prompt ids for possible display. Actual display is based on the /// current AppSettings::firstRunPromptIds value. The order of this list also determines the order the prompts /// will be displayed in. - virtual QList firstRunPromptCustomIds(void); + virtual QList firstRunPromptCustomIds() { return QList(); } /// Returns the resource which contains the specified first run prompt for display Q_INVOKABLE virtual QString firstRunPromptResource(int id); @@ -172,43 +174,41 @@ class QGCCorePlugin : public QGCTool /// 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); + virtual const QVariantList &toolBarIndicators(); /// Returns a true if xml definition file of a providen camera name exists, and loads it to file argument, to allow definition files to be loaded from resources - virtual bool getOfflineCameraDefinitionFile(QString cameraname, QFile& file) { Q_UNUSED(cameraname); Q_UNUSED(file); return false; } + virtual bool getOfflineCameraDefinitionFile(const QString &cameraName, QFile &file) { Q_UNUSED(cameraName); Q_UNUSED(file); return false; } /// Returns the list of first run prompt ids which need to be displayed according to current settings - Q_INVOKABLE QVariantList firstRunPromptsToShow(void); + Q_INVOKABLE QVariantList firstRunPromptsToShow(); bool showTouchAreas() const { return _showTouchAreas; } bool showAdvancedUI() const { return _showAdvancedUI; } - void setShowTouchAreas(bool show); - void setShowAdvancedUI(bool show); - - // Override from QGCTool - void setToolbox (QGCToolbox* toolbox); // Standard first run prompt ids - static const int unitsFirstRunPromptId = 1; - static const int offlineVehicleFirstRunPromptId = 2; + static constexpr int kUnitsFirstRunPromptId = 1; + static constexpr int kOfflineVehicleFirstRunPromptId = 2; // Custom builds can start there first run prompt ids from here - static const int firstRunPromptIdsFirstCustomId = 10000; + static constexpr int kFirstRunPromptIdsFirstCustomId = 10000; signals: - void analyzePagesChanged (); - void showTouchAreasChanged (bool showTouchAreas); - void showAdvancedUIChanged (bool showAdvancedUI); - void toolBarIndicatorsChanged (); + void analyzePagesChanged(); + void showTouchAreasChanged(bool showTouchAreas); + void showAdvancedUIChanged(bool showAdvancedUI); + void toolBarIndicatorsChanged(); protected: - bool _showTouchAreas; - bool _showAdvancedUI; - Vehicle* _activeVehicle = nullptr; - QGCCameraManager* _cameraManager = nullptr; - MavlinkCameraControl* _currentCamera = nullptr; - QVariantList _toolBarIndicatorList; + bool _showTouchAreas = false; + bool _showAdvancedUI = true; + Vehicle *_activeVehicle = nullptr; + QGCCameraManager *_cameraManager = nullptr; + MavlinkCameraControl *_currentCamera = nullptr; + QVariantList _toolBarIndicatorList; private: - QGCCorePlugin_p* _p; + QGCCorePlugin_p *_p = nullptr; + + void _setShowTouchAreas(bool show); + void _setShowAdvancedUI(bool show); }; diff --git a/src/AnalyzeView/MAVLinkConsoleController.cc b/src/AnalyzeView/MAVLinkConsoleController.cc index fc1695d078c..aabaf245597 100644 --- a/src/AnalyzeView/MAVLinkConsoleController.cc +++ b/src/AnalyzeView/MAVLinkConsoleController.cc @@ -10,10 +10,8 @@ #include "MAVLinkConsoleController.h" #include "MAVLinkProtocol.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "QGCPalette.h" -#include "QGCToolbox.h" #include "Vehicle.h" #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7b6c42bf765..9d00df81946 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,8 +14,6 @@ qt_add_library(QGC STATIC QGCApplication.cc QGCApplication.h QGCConfig.h - QGCToolbox.cc - QGCToolbox.h ) add_subdirectory(ADSB) @@ -75,6 +73,7 @@ target_link_libraries(QGC # FlightDisplay FollowMe Gimbal + GPS GStreamerReceiver Joystick MAVLink @@ -96,10 +95,6 @@ target_link_libraries(QGC Qt6::Widgets ) -if(QGC_CUSTOM_BUILD) - target_link_libraries(QGC PRIVATE CustomPlugin) -endif() - target_include_directories(QGC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) if(ANDROID) diff --git a/src/Camera/QGCCameraManager.cc b/src/Camera/QGCCameraManager.cc index 3a79d22bbcc..b5166fe58d0 100644 --- a/src/Camera/QGCCameraManager.cc +++ b/src/Camera/QGCCameraManager.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "QGCCameraManager.h" -#include "QGCApplication.h" #include "JoystickManager.h" #include "SimulatedCameraControl.h" #include "MultiVehicleManager.h" diff --git a/src/Camera/VehicleCameraControl.cc b/src/Camera/VehicleCameraControl.cc index fc725fd77c8..55b43bb1a30 100644 --- a/src/Camera/VehicleCameraControl.cc +++ b/src/Camera/VehicleCameraControl.cc @@ -2158,7 +2158,7 @@ VehicleCameraControl::_dataReady(QByteArray data) } else { qCDebug(CameraControlLog) << "No camera definition received, trying to search on our own..."; QFile definitionFile; - if(qgcApp()->toolbox()->corePlugin()->getOfflineCameraDefinitionFile(_modelName, definitionFile)) { + if(QGCCorePlugin::instance()->getOfflineCameraDefinitionFile(_modelName, definitionFile)) { qCDebug(CameraControlLog) << "Found offline definition file for: " << _modelName << ", loading: " << definitionFile.fileName(); if (definitionFile.open(QIODevice::ReadOnly)) { QByteArray newData = definitionFile.readAll(); diff --git a/src/Comms/AirLink/AirLinkLink.cc b/src/Comms/AirLink/AirLinkLink.cc index 1e7e45b8929..b55899bc05c 100644 --- a/src/Comms/AirLink/AirLinkLink.cc +++ b/src/Comms/AirLink/AirLinkLink.cc @@ -10,7 +10,6 @@ #include "AirLinkLink.h" #include "AppSettings.h" #include "MAVLinkProtocol.h" -#include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "SettingsManager.h" diff --git a/src/Comms/AirLink/AirLinkManager.cc b/src/Comms/AirLink/AirLinkManager.cc index 499a7e1b2a9..b2f6bc1b8c6 100644 --- a/src/Comms/AirLink/AirLinkManager.cc +++ b/src/Comms/AirLink/AirLinkManager.cc @@ -8,8 +8,6 @@ ****************************************************************************/ #include "AirLinkManager.h" -#include "QGCApplication.h" -#include "QGCToolbox.h" #include "SettingsManager.h" #include "QGCLoggingCategory.h" diff --git a/src/Comms/AirLink/CMakeLists.txt b/src/Comms/AirLink/CMakeLists.txt index ffb678b568a..4c80fa13c5b 100644 --- a/src/Comms/AirLink/CMakeLists.txt +++ b/src/Comms/AirLink/CMakeLists.txt @@ -16,7 +16,6 @@ if(NOT QGC_AIRLINK_DISABLED) target_link_libraries(AirLink PRIVATE Qt6::Network - QGC Settings Utilities PUBLIC diff --git a/src/FactSystem/Fact.cc b/src/FactSystem/Fact.cc index d3ffbbba1bb..b789486bc81 100644 --- a/src/FactSystem/Fact.cc +++ b/src/FactSystem/Fact.cc @@ -61,7 +61,7 @@ Fact::Fact(const QString& settingsGroup, FactMetaData* metaData, QObject* parent , _valueSliderModel (nullptr) , _ignoreQGCRebootRequired (false) { - qgcApp()->toolbox()->corePlugin()->adjustSettingMetaData(settingsGroup, *metaData); + QGCCorePlugin::instance()->adjustSettingMetaData(settingsGroup, *metaData); setMetaData(metaData, true /* setDefaultFromMetaData */); _init(); diff --git a/src/FactSystem/FactMetaData.cc b/src/FactSystem/FactMetaData.cc index f80f2d50dae..139de03a892 100644 --- a/src/FactSystem/FactMetaData.cc +++ b/src/FactSystem/FactMetaData.cc @@ -11,7 +11,7 @@ #include "SettingsManager.h" #include "UnitsSettings.h" #include "JsonHelper.h" -#include +#include "MAVLinkLib.h" #include diff --git a/src/FactSystem/SettingsFact.cc b/src/FactSystem/SettingsFact.cc index b27d44197c2..11bdb106a59 100644 --- a/src/FactSystem/SettingsFact.cc +++ b/src/FactSystem/SettingsFact.cc @@ -9,8 +9,8 @@ #include "SettingsFact.h" -#include "QGCCorePlugin.h" #include "QGCApplication.h" +#include "QGCCorePlugin.h" #include #include @@ -33,7 +33,7 @@ SettingsFact::SettingsFact(QString settingsGroup, FactMetaData* metaData, QObjec } // Allow core plugin a chance to override the default value - _visible = qgcApp()->toolbox()->corePlugin()->adjustSettingMetaData(settingsGroup, *metaData); + _visible = QGCCorePlugin::instance()->adjustSettingMetaData(settingsGroup, *metaData); setMetaData(metaData); if (metaData->defaultValueAvailable()) { diff --git a/src/GPS/GPSRtk.cc b/src/GPS/GPSRtk.cc index 78ef642155a..fef93875e09 100644 --- a/src/GPS/GPSRtk.cc +++ b/src/GPS/GPSRtk.cc @@ -22,10 +22,6 @@ GPSRtk::GPSRtk(QObject *parent) , _gpsRtkFactGroup(new GPSRTKFactGroup(this)) { // qCDebug(GPSRtkLog) << Q_FUNC_INFO << this; - - qRegisterMetaType("satellite_info_s"); - qRegisterMetaType("sensor_gnss_relative_s"); - qRegisterMetaType("sensor_gps_s"); } GPSRtk::~GPSRtk() @@ -35,6 +31,13 @@ GPSRtk::~GPSRtk() // qCDebug(GPSRtkLog) << Q_FUNC_INFO << this; } +void GPSRtk::registerQmlTypes() +{ + (void) qRegisterMetaType("satellite_info_s"); + (void) qRegisterMetaType("sensor_gnss_relative_s"); + (void) qRegisterMetaType("sensor_gps_s"); +} + void GPSRtk::_onGPSConnect() { _gpsRtkFactGroup->connected()->setRawValue(true); diff --git a/src/GPS/GPSRtk.h b/src/GPS/GPSRtk.h index 68d9fae14d2..4e69c84ad2d 100644 --- a/src/GPS/GPSRtk.h +++ b/src/GPS/GPSRtk.h @@ -32,6 +32,8 @@ class GPSRtk : public QObject GPSRtk(QObject *parent = nullptr); ~GPSRtk(); + static void registerQmlTypes(); + void connectGPS(const QString &device, QStringView gps_type); void disconnectGPS(); bool connected() const; diff --git a/src/MissionManager/ComplexMissionItem.cc b/src/MissionManager/ComplexMissionItem.cc index 82cb3f90c23..aa6011135e0 100644 --- a/src/MissionManager/ComplexMissionItem.cc +++ b/src/MissionManager/ComplexMissionItem.cc @@ -9,7 +9,6 @@ #include "ComplexMissionItem.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "QGCCorePlugin.h" #include "QGCOptions.h" #include "PlanMasterController.h" @@ -62,7 +61,7 @@ void ComplexMissionItem::savePreset(const QString& name) void ComplexMissionItem::deletePreset(const QString& name) { - if (qgcApp()->toolbox()->corePlugin()->options()->surveyBuiltInPresetNames().contains(name)) { + if (QGCCorePlugin::instance()->options()->surveyBuiltInPresetNames().contains(name)) { qgcApp()->showAppMessage(tr("'%1' is a built-in preset which cannot be deleted.").arg(name)); return; } diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 8c113dd3bd1..81ab73dc412 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -2251,7 +2251,7 @@ QStringList MissionController::complexMissionItemNames(void) const // Note: The landing pattern items are not added here since they have there own button which adds them - return qgcApp()->toolbox()->corePlugin()->complexMissionItemNames(_controllerVehicle, complexItems); + return QGCCorePlugin::instance()->complexMissionItemNames(_controllerVehicle, complexItems); } void MissionController::resumeMission(int resumeIndex) diff --git a/src/MissionManager/PlanMasterController.cc b/src/MissionManager/PlanMasterController.cc index 00fdc48228a..f55b417c066 100644 --- a/src/MissionManager/PlanMasterController.cc +++ b/src/MissionManager/PlanMasterController.cc @@ -369,7 +369,7 @@ void PlanMasterController::loadFromFile(const QString& filename) QJsonObject json = jsonDoc.object(); //-- Allow plugins to pre process the load - qgcApp()->toolbox()->corePlugin()->preLoadFromJson(this, json); + QGCCorePlugin::instance()->preLoadFromJson(this, json); int version; if (!JsonHelper::validateExternalQGCJsonFile(json, kPlanFileType, kPlanFileVersion, kPlanFileVersion, version, errorString)) { @@ -393,7 +393,7 @@ void PlanMasterController::loadFromFile(const QString& filename) qgcApp()->showAppMessage(errorMessage.arg(errorString)); } else { //-- Allow plugins to post process the load - qgcApp()->toolbox()->corePlugin()->postLoadFromJson(this, json); + QGCCorePlugin::instance()->postLoadFromJson(this, json); success = true; } } @@ -413,22 +413,22 @@ void PlanMasterController::loadFromFile(const QString& filename) QJsonDocument PlanMasterController::saveToJson() { QJsonObject planJson; - qgcApp()->toolbox()->corePlugin()->preSaveToJson(this, planJson); + QGCCorePlugin::instance()->preSaveToJson(this, planJson); QJsonObject missionJson; QJsonObject fenceJson; QJsonObject rallyJson; JsonHelper::saveQGCJsonFileHeader(planJson, kPlanFileType, kPlanFileVersion); //-- Allow plugin to preemptly add its own keys to mission - qgcApp()->toolbox()->corePlugin()->preSaveToMissionJson(this, missionJson); + QGCCorePlugin::instance()->preSaveToMissionJson(this, missionJson); _missionController.save(missionJson); //-- Allow plugin to add its own keys to mission - qgcApp()->toolbox()->corePlugin()->postSaveToMissionJson(this, missionJson); + QGCCorePlugin::instance()->postSaveToMissionJson(this, missionJson); _geoFenceController.save(fenceJson); _rallyPointController.save(rallyJson); planJson[kJsonMissionObjectKey] = missionJson; planJson[kJsonGeoFenceObjectKey] = fenceJson; planJson[kJsonRallyPointsObjectKey] = rallyJson; - qgcApp()->toolbox()->corePlugin()->postSaveToJson(this, planJson); + QGCCorePlugin::instance()->postSaveToJson(this, planJson); return QJsonDocument(planJson); } diff --git a/src/PositionManager/PositionManager.cpp b/src/PositionManager/PositionManager.cpp index ed80dbb4e44..00525a2fc8a 100644 --- a/src/PositionManager/PositionManager.cpp +++ b/src/PositionManager/PositionManager.cpp @@ -58,7 +58,7 @@ void QGCPositionManager::init() void QGCPositionManager::_setupPositionSources() { - _defaultSource = qgcApp()->toolbox()->corePlugin()->createPositionSource(this); + _defaultSource = QGCCorePlugin::instance()->createPositionSource(this); if (_defaultSource) { _usingPluginSource = true; } else { diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 2369bcf97fd..862de4b0010 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -37,6 +37,7 @@ #include "FollowMe.h" #include "GeoTagController.h" #include "GimbalController.h" +#include "GPSRtk.h" #include "JoystickConfigController.h" #include "JoystickManager.h" #include "JsonHelper.h" @@ -203,9 +204,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) // We need to set language as early as possible prior to loading on JSON files. setLanguage(); - _toolbox = new QGCToolbox(this); - _toolbox->setChildToolboxes(); - #ifndef DAILY_BUILD _checkForNewVersion(); #endif @@ -278,6 +276,8 @@ void QGCApplication::init() QGCPositionManager::registerQmlTypes(); SettingsManager::registerQmlTypes(); VideoManager::registerQmlTypes(); + QGCCorePlugin::registerQmlTypes(); + GPSRtk::registerQmlTypes(); #ifdef QGC_VIEWER3D Viewer3DManager::registerQmlTypes(); #endif @@ -335,9 +335,9 @@ void QGCApplication::_initForNormalAppBoot() VideoManager::instance(); // GStreamer must be initialized before QmlEngine QQuickStyle::setStyle("Basic"); - _qmlAppEngine = _toolbox->corePlugin()->createQmlApplicationEngine(this); + _qmlAppEngine = QGCCorePlugin::instance()->createQmlApplicationEngine(this); QObject::connect(_qmlAppEngine, &QQmlApplicationEngine::objectCreationFailed, this, QCoreApplication::quit, Qt::QueuedConnection); - _toolbox->corePlugin()->createRootWindow(_qmlAppEngine); + QGCCorePlugin::instance()->createRootWindow(_qmlAppEngine); AudioOutput::instance()->init(SettingsManager::instance()->appSettings()->audioMuted()); FollowMe::instance()->init(); @@ -557,7 +557,7 @@ void QGCApplication::_checkForNewVersion() { if (!_runningUnitTests) { if (_parseVersionText(applicationVersion(), _majorVersion, _minorVersion, _buildVersion)) { - const QString versionCheckFile = _toolbox->corePlugin()->stableVersionCheckFileUrl(); + const QString versionCheckFile = QGCCorePlugin::instance()->stableVersionCheckFileUrl(); if (!versionCheckFile.isEmpty()) { QGCFileDownload* download = new QGCFileDownload(this); connect(download, &QGCFileDownload::downloadComplete, this, &QGCApplication::_qgcCurrentStableVersionDownloadComplete); @@ -582,7 +582,7 @@ void QGCApplication::_qgcCurrentStableVersionDownloadComplete(QString /*remoteFi if (_majorVersion < majorVersion || (_majorVersion == majorVersion && _minorVersion < minorVersion) || (_majorVersion == majorVersion && _minorVersion == minorVersion && _buildVersion < buildVersion)) { - showAppMessage(tr("There is a newer version of %1 available. You can download it from %2.").arg(applicationName()).arg(_toolbox->corePlugin()->stableDownloadLocation()), tr("New Version Available")); + showAppMessage(tr("There is a newer version of %1 available. You can download it from %2.").arg(applicationName()).arg(QGCCorePlugin::instance()->stableDownloadLocation()), tr("New Version Available")); } } } diff --git a/src/QGCApplication.h b/src/QGCApplication.h index 9ce9a110d2f..5b37f403a06 100644 --- a/src/QGCApplication.h +++ b/src/QGCApplication.h @@ -25,7 +25,6 @@ // Work around circular header includes class QQmlApplicationEngine; -class QGCToolbox; class QQuickWindow; class QGCImageProvider; class QGCApplication; @@ -82,9 +81,6 @@ class QGCApplication : public QApplication /// @return true: Fake ui into showing mobile interface bool fakeMobile(void) const { return _fakeMobile; } - // Still working on getting rid of this and using dependency injection instead for everything - QGCToolbox* toolbox(void) { return _toolbox; } - void setLanguage(); QQuickWindow* mainRootWindow(); uint64_t msecsSinceBoot(void) { return _msecsElapsedTime.elapsed(); } @@ -170,7 +166,6 @@ private slots: int _majorVersion = 0; int _minorVersion = 0; int _buildVersion = 0; - QGCToolbox* _toolbox = nullptr; QQuickWindow* _mainRootWindow = nullptr; QTranslator _qgcTranslatorSourceCode; ///< translations for source code C++/Qml QTranslator _qgcTranslatorQtLibs; ///< tranlsations for Qt libraries diff --git a/src/QGCToolbox.cc b/src/QGCToolbox.cc deleted file mode 100644 index ce3dd100500..00000000000 --- a/src/QGCToolbox.cc +++ /dev/null @@ -1,53 +0,0 @@ - /**************************************************************************** - * - * (c) 2009-2024 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#include "QGCToolbox.h" -#include "QGCCorePlugin.h" -#include "QGCApplication.h" - -#if defined(QGC_CUSTOM_BUILD) -#include CUSTOMHEADER -#endif - -QGCToolbox::QGCToolbox(QGCApplication* app) - : QObject(app) -{ - //-- Scan and load plugins - _scanAndLoadPlugins(app); -} - -void QGCToolbox::setChildToolboxes(void) -{ - _corePlugin->setToolbox(this); -} - -void QGCToolbox::_scanAndLoadPlugins(QGCApplication* app) -{ -#if defined (QGC_CUSTOM_BUILD) - //-- Create custom plugin (Static) - _corePlugin = (QGCCorePlugin*) new CUSTOMCLASS(app, this); - if(_corePlugin) { - return; - } -#endif - //-- No plugins found, use default instance - _corePlugin = new QGCCorePlugin(app, this); -} - -QGCTool::QGCTool(QGCApplication* app, QGCToolbox* toolbox) - : QObject(toolbox) - , _app(app) - , _toolbox(nullptr) -{ -} - -void QGCTool::setToolbox(QGCToolbox* toolbox) -{ - _toolbox = toolbox; -} diff --git a/src/QGCToolbox.h b/src/QGCToolbox.h deleted file mode 100644 index 0f87104c19f..00000000000 --- a/src/QGCToolbox.h +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** - * - * (c) 2009-2024 QGROUNDCONTROL PROJECT - * - * QGroundControl is licensed according to the terms in the file - * COPYING.md in the root of the source code directory. - * - ****************************************************************************/ - -#pragma once - -#include - -class QGCApplication; -class QGCCorePlugin; - -/// This is used to manage all of our top level services/tools -class QGCToolbox : public QObject { - Q_OBJECT - -public: - QGCToolbox(QGCApplication* app); - - QGCCorePlugin* corePlugin () { return _corePlugin; } - -private: - void setChildToolboxes(void); - void _scanAndLoadPlugins(QGCApplication *app); - - QGCCorePlugin* _corePlugin = nullptr; - friend class QGCApplication; -}; - -/// This is the base class for all tools -class QGCTool : public QObject { - Q_OBJECT - -public: - // All tools must be parented to the QGCToolbox and go through a two phase creation. In the constructor the toolbox - // should only be passed to QGCTool constructor for correct parenting. It should not be referenced or set in the - // protected member. Then in the second phase of setToolbox calls is where you can reference the toolbox. - QGCTool(QGCApplication* app, QGCToolbox* toolbox); - - // If you override this method, you must call the base class. - virtual void setToolbox(QGCToolbox* toolbox); - -protected: - QGCApplication* _app; - QGCToolbox* _toolbox; -}; diff --git a/src/QmlControls/EditPositionDialogController.cc b/src/QmlControls/EditPositionDialogController.cc index 3d862cfe4a7..44d78de7e0b 100644 --- a/src/QmlControls/EditPositionDialogController.cc +++ b/src/QmlControls/EditPositionDialogController.cc @@ -9,8 +9,6 @@ #include "EditPositionDialogController.h" #include "QGCGeo.h" -#include "QGCApplication.h" -#include "QGCToolbox.h" #include "MultiVehicleManager.h" #include "Vehicle.h" #include "QGCLoggingCategory.h" diff --git a/src/QmlControls/FactValueGrid.cc b/src/QmlControls/FactValueGrid.cc index 4d4b0363404..4384ecabfca 100644 --- a/src/QmlControls/FactValueGrid.cc +++ b/src/QmlControls/FactValueGrid.cc @@ -288,7 +288,7 @@ void FactValueGrid::_loadSettings(void) QString groupNameFormat("%1-%2"); if (!settings.childGroups().contains(groupNameFormat.arg(_userSettingsGroup).arg(_vehicleClass))) { - qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); + QGCCorePlugin::instance()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); } @@ -302,7 +302,7 @@ void FactValueGrid::_loadSettings(void) if (version != 1) { qgcApp()->showAppMessage(tr("Settings version %1 for %2 is not supported. Setup will be reset to defaults.").arg(version).arg(_userSettingsGroup), tr("Load Settings")); settings.remove(""); - qgcApp()->toolbox()->corePlugin()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); + QGCCorePlugin::instance()->factValueGridCreateDefaultSettings(_defaultSettingsGroup); } _fontSize = settings.value(_fontSizeKey, DefaultFontSize).value(); diff --git a/src/QmlControls/HorizontalFactValueGrid.cc b/src/QmlControls/HorizontalFactValueGrid.cc index b946d48ef02..c331f8bb630 100644 --- a/src/QmlControls/HorizontalFactValueGrid.cc +++ b/src/QmlControls/HorizontalFactValueGrid.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "HorizontalFactValueGrid.h" -#include "QGCCorePlugin.h" const QString HorizontalFactValueGrid::telemetryBarUserSettingsGroup ("TelemetryBarUserSettings"); const QString HorizontalFactValueGrid::telemetryBarDefaultSettingsGroup ("TelemetryBarDefaultSettings"); diff --git a/src/QmlControls/InstrumentValueData.cc b/src/QmlControls/InstrumentValueData.cc index ae86bf9fa9b..9d18d31cf30 100644 --- a/src/QmlControls/InstrumentValueData.cc +++ b/src/QmlControls/InstrumentValueData.cc @@ -9,8 +9,6 @@ #include "InstrumentValueData.h" #include "FactValueGrid.h" -#include "QGCApplication.h" -#include "QGCCorePlugin.h" #include "QGC.h" #include "QmlObjectListModel.h" #include "MultiVehicleManager.h" diff --git a/src/QmlControls/QGCPalette.cc b/src/QmlControls/QGCPalette.cc index c2ba0255a7b..38079032b45 100644 --- a/src/QmlControls/QGCPalette.cc +++ b/src/QmlControls/QGCPalette.cc @@ -12,7 +12,6 @@ /// @author Don Gagne #include "QGCPalette.h" -#include "QGCApplication.h" #include "QGCCorePlugin.h" #include diff --git a/src/QmlControls/QGCPalette.h b/src/QmlControls/QGCPalette.h index 5ba2c53f744..44fa29377fe 100644 --- a/src/QmlControls/QGCPalette.h +++ b/src/QmlControls/QGCPalette.h @@ -20,7 +20,7 @@ { QColor(lightDisabled), QColor(lightEnabled) }, \ { QColor(darkDisabled), QColor(darkEnabled) } \ }; \ - qgcApp()->toolbox()->corePlugin()->paletteOverride(#name, colorInfo); \ + QGCCorePlugin::instance()->paletteOverride(#name, colorInfo); \ _colorInfoMap[Light][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupEnabled]; \ _colorInfoMap[Light][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupDisabled]; \ _colorInfoMap[Dark][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupEnabled]; \ @@ -34,7 +34,7 @@ { QColor(disabledColor), QColor(enabledColor) }, \ { QColor(disabledColor), QColor(enabledColor) } \ }; \ - qgcApp()->toolbox()->corePlugin()->paletteOverride(#name, colorInfo); \ + QGCCorePlugin::instance()->paletteOverride(#name, colorInfo); \ _colorInfoMap[Light][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupEnabled]; \ _colorInfoMap[Light][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupDisabled]; \ _colorInfoMap[Dark][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupEnabled]; \ @@ -48,7 +48,7 @@ { QColor(color), QColor(color) }, \ { QColor(color), QColor(color) } \ }; \ - qgcApp()->toolbox()->corePlugin()->paletteOverride(#name, colorInfo); \ + QGCCorePlugin::instance()->paletteOverride(#name, colorInfo); \ _colorInfoMap[Light][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupEnabled]; \ _colorInfoMap[Light][ColorGroupDisabled][QStringLiteral(#name)] = colorInfo[Light][ColorGroupDisabled]; \ _colorInfoMap[Dark][ColorGroupEnabled][QStringLiteral(#name)] = colorInfo[Dark][ColorGroupEnabled]; \ diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index a2b6c5f75ea..7037b08b878 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -10,6 +10,7 @@ #include "QGroundControlQmlGlobal.h" #include "QGCApplication.h" +#include "QGCCorePlugin.h" #include "LinkManager.h" #include "MAVLinkProtocol.h" #include "FirmwarePluginManager.h" @@ -64,16 +65,13 @@ double QGroundControlQmlGlobal::_zoom = 2; static QObject* screenToolsControllerSingletonFactory(QQmlEngine*, QJSEngine*) { - ScreenToolsController* screenToolsController = new ScreenToolsController; + ScreenToolsController* screenToolsController = new ScreenToolsController(); return screenToolsController; } static QObject* qgroundcontrolQmlGlobalSingletonFactory(QQmlEngine*, QJSEngine*) { - // We create this object as a QGCTool even though it isn't in the toolbox - QGroundControlQmlGlobal* qmlGlobal = new QGroundControlQmlGlobal(qgcApp(), qgcApp()->toolbox()); - qmlGlobal->setToolbox(qgcApp()->toolbox()); - + QGroundControlQmlGlobal *const qmlGlobal = new QGroundControlQmlGlobal(); return qmlGlobal; } @@ -106,8 +104,8 @@ void QGroundControlQmlGlobal::registerQmlTypes() qmlRegisterSingletonType ("QGroundControl.ScreenToolsController", 1, 0, "ScreenToolsController", screenToolsControllerSingletonFactory); } -QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox* toolbox) - : QGCTool(app, toolbox) +QGroundControlQmlGlobal::QGroundControlQmlGlobal(QObject *parent) + : QObject(parent) , _mapEngineManager(QGCMapEngineManager::instance()) , _adsbVehicleManager(ADSBVehicleManager::instance()) , _qgcPositionManager(QGCPositionManager::instance()) @@ -116,6 +114,11 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox , _linkManager(LinkManager::instance()) , _multiVehicleManager(MultiVehicleManager::instance()) , _settingsManager(SettingsManager::instance()) + , _corePlugin(QGCCorePlugin::instance()) + , _globalPalette(new QGCPalette(this)) +#ifndef NO_SERIAL_LINK + , _gpsRtkFactGroup(GPSManager::instance()->gpsRtk()->gpsRtkFactGroup()) +#endif #ifndef QGC_AIRLINK_DISABLED , _airlinkManager(AirLinkManager::instance()) #endif @@ -158,17 +161,6 @@ QGroundControlQmlGlobal::~QGroundControlQmlGlobal() { } -void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox) -{ - QGCTool::setToolbox(toolbox); - - _corePlugin = toolbox->corePlugin(); -#ifndef NO_SERIAL_LINK - _gpsRtkFactGroup = GPSManager::instance()->gpsRtk()->gpsRtkFactGroup(); -#endif - _globalPalette = new QGCPalette(this); -} - void QGroundControlQmlGlobal::saveGlobalSetting (const QString& key, const QString& value) { QSettings settings; @@ -340,7 +332,7 @@ void QGroundControlQmlGlobal::setFlightMapZoom(double zoom) QString QGroundControlQmlGlobal::qgcVersion(void) const { - QString versionStr = _app->applicationVersion(); + QString versionStr = qgcApp()->applicationVersion(); if(QSysInfo::buildAbi().contains("32")) { versionStr += QStringLiteral(" %1").arg(tr("32 bit")); @@ -433,15 +425,15 @@ QString QGroundControlQmlGlobal::telemetryFileExtension() const QString QGroundControlQmlGlobal::appName() { - return _app->applicationName(); + return qgcApp()->applicationName(); } void QGroundControlQmlGlobal::deleteAllSettingsNextBoot() { - _app->deleteAllSettingsNextBoot(); + qgcApp()->deleteAllSettingsNextBoot(); } void QGroundControlQmlGlobal::clearDeleteAllSettingsNextBoot() { - _app->clearDeleteAllSettingsNextBoot(); + qgcApp()->clearDeleteAllSettingsNextBoot(); } diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index 42c834614ac..f6633a1ebd2 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -9,7 +9,6 @@ #pragma once -#include "QGCToolbox.h" #include "QmlUnitsConversion.h" #include "QGCLoggingCategory.h" @@ -17,8 +16,6 @@ #include #include -class QGCApplication; - class ADSBVehicleManager; class FactGroup; class LinkManager; @@ -51,12 +48,12 @@ Q_MOC_INCLUDE("UTMSPManager.h") Q_MOC_INCLUDE("AirLinkManager.h") #endif -class QGroundControlQmlGlobal : public QGCTool +class QGroundControlQmlGlobal : public QObject { Q_OBJECT public: - QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox* toolbox); + QGroundControlQmlGlobal(QObject *parent = nullptr); ~QGroundControlQmlGlobal(); enum AltMode { @@ -238,9 +235,6 @@ class QGroundControlQmlGlobal : public QGCTool bool utmspSupported() { return false; } #endif - // Overrides from QGCTool - virtual void setToolbox(QGCToolbox* toolbox); - static void registerQmlTypes(); signals: @@ -260,19 +254,19 @@ class QGroundControlQmlGlobal : public QGCTool LinkManager* _linkManager = nullptr; MultiVehicleManager* _multiVehicleManager = nullptr; SettingsManager* _settingsManager = nullptr; + QGCCorePlugin* _corePlugin = nullptr; + QGCPalette* _globalPalette = nullptr; +#ifndef NO_SERIAL_LINK + FactGroup* _gpsRtkFactGroup = nullptr; +#endif #ifndef QGC_AIRLINK_DISABLED AirLinkManager* _airlinkManager = nullptr; #endif #ifdef QGC_UTM_ADAPTER - UTMSPManager* _utmspManager; + UTMSPManager* _utmspManager = nullptr; #endif double _flightMapInitialZoom = 17.0; - QGCCorePlugin* _corePlugin = nullptr; -#ifndef NO_SERIAL_LINK - FactGroup* _gpsRtkFactGroup = nullptr; -#endif - QGCPalette* _globalPalette = nullptr; QmlUnitsConversion _unitsConversion; bool _skipSetupPage = false; diff --git a/src/QmlControls/RCToParamDialogController.cc b/src/QmlControls/RCToParamDialogController.cc index dd8600c4257..2bfdeea6ade 100644 --- a/src/QmlControls/RCToParamDialogController.cc +++ b/src/QmlControls/RCToParamDialogController.cc @@ -8,8 +8,6 @@ ****************************************************************************/ #include "RCToParamDialogController.h" -#include "QGCApplication.h" -#include "QGCToolbox.h" #include "ParameterManager.h" #include "MultiVehicleManager.h" #include "Vehicle.h" diff --git a/src/Settings/APMMavlinkStreamRateSettings.cc b/src/Settings/APMMavlinkStreamRateSettings.cc index 31ac83d52b6..613a8497074 100644 --- a/src/Settings/APMMavlinkStreamRateSettings.cc +++ b/src/Settings/APMMavlinkStreamRateSettings.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "APMMavlinkStreamRateSettings.h" -#include "QGCApplication.h" #include "Vehicle.h" #include "MultiVehicleManager.h" diff --git a/src/Settings/APMMavlinkStreamRateSettings.h b/src/Settings/APMMavlinkStreamRateSettings.h index 1c440831bb8..e7037e40c51 100644 --- a/src/Settings/APMMavlinkStreamRateSettings.h +++ b/src/Settings/APMMavlinkStreamRateSettings.h @@ -9,7 +9,7 @@ #pragma once #include "SettingsGroup.h" -#include "QGCMAVLink.h" +#include "MAVLinkLib.h" class APMMavlinkStreamRateSettings : public SettingsGroup { diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc index b6f7d8b02d1..9c4dd43b490 100644 --- a/src/Settings/AppSettings.cc +++ b/src/Settings/AppSettings.cc @@ -11,7 +11,6 @@ #include "QGCPalette.h" #include "QGCApplication.h" #include "QGCMAVLink.h" -#include "QGCToolbox.h" #include "LinkManager.h" #ifdef Q_OS_ANDROID diff --git a/src/Settings/GimbalControllerSettings.cc b/src/Settings/GimbalControllerSettings.cc index b95f7467ba4..ef9a2a5bd0b 100644 --- a/src/Settings/GimbalControllerSettings.cc +++ b/src/Settings/GimbalControllerSettings.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "GimbalControllerSettings.h" -#include "QGCApplication.h" #include #include @@ -26,4 +25,4 @@ DECLARE_SETTINGSFACT(GimbalControllerSettings, CameraSlideSpeed) DECLARE_SETTINGSFACT(GimbalControllerSettings, showAzimuthIndicatorOnMap) DECLARE_SETTINGSFACT(GimbalControllerSettings, toolbarIndicatorShowAzimuth) DECLARE_SETTINGSFACT(GimbalControllerSettings, toolbarIndicatorShowAcquireReleaseControl) -DECLARE_SETTINGSFACT(GimbalControllerSettings, joystickButtonsSpeed) \ No newline at end of file +DECLARE_SETTINGSFACT(GimbalControllerSettings, joystickButtonsSpeed) diff --git a/src/Settings/SettingsGroup.cc b/src/Settings/SettingsGroup.cc index f4c4ecd9e58..34a4adda016 100644 --- a/src/Settings/SettingsGroup.cc +++ b/src/Settings/SettingsGroup.cc @@ -9,13 +9,12 @@ #include "SettingsGroup.h" #include "QGCCorePlugin.h" -#include "QGCApplication.h" #include SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup, QObject* parent) : QObject (parent) - , _visible (qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name)) + , _visible (QGCCorePlugin::instance()->overrideSettingsGroupVisibility(name)) , _name (name) , _settingsGroup(settingsGroup) { diff --git a/src/Utilities/CMakeLists.txt b/src/Utilities/CMakeLists.txt index 9fe91ebcfca..b79b88015be 100644 --- a/src/Utilities/CMakeLists.txt +++ b/src/Utilities/CMakeLists.txt @@ -45,7 +45,6 @@ target_link_libraries(Utilities Qt6::Qml FactSystem Geo - QGC QmlControls Settings PUBLIC diff --git a/src/Vehicle/FTPManager.cc b/src/Vehicle/FTPManager.cc index ef7a0c16990..156a8c3883c 100644 --- a/src/Vehicle/FTPManager.cc +++ b/src/Vehicle/FTPManager.cc @@ -11,7 +11,6 @@ #include "MAVLinkProtocol.h" #include "Vehicle.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "QGCLoggingCategory.h" #include diff --git a/src/Vehicle/InitialConnectStateMachine.cc b/src/Vehicle/InitialConnectStateMachine.cc index 8751517b465..971c2c461bd 100644 --- a/src/Vehicle/InitialConnectStateMachine.cc +++ b/src/Vehicle/InitialConnectStateMachine.cc @@ -142,7 +142,7 @@ void InitialConnectStateMachine::_autopilotVersionRequestMessageHandler(void* re nullStr[8] = 0; vehicle->_gitHash = nullStr; } - if (vehicle->_toolbox->corePlugin()->options()->checkFirmwareVersion() && !vehicle->_checkLatestStableFWDone) { + if (QGCCorePlugin::instance()->options()->checkFirmwareVersion() && !vehicle->_checkLatestStableFWDone) { vehicle->_checkLatestStableFWDone = true; vehicle->_firmwarePlugin->checkIfIsLatestStable(vehicle); } diff --git a/src/Vehicle/MultiVehicleManager.cc b/src/Vehicle/MultiVehicleManager.cc index b50931ddfd5..52cf5418f53 100644 --- a/src/Vehicle/MultiVehicleManager.cc +++ b/src/Vehicle/MultiVehicleManager.cc @@ -122,7 +122,7 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle break; } - if ((_vehicles->count() > 0) && !qgcApp()->toolbox()->corePlugin()->options()->multiVehicleEnabled()) { + if ((_vehicles->count() > 0) && !QGCCorePlugin::instance()->options()->multiVehicleEnabled()) { return; } diff --git a/src/Vehicle/TerrainProtocolHandler.cc b/src/Vehicle/TerrainProtocolHandler.cc index 6b5171782f2..05f7aa0414f 100644 --- a/src/Vehicle/TerrainProtocolHandler.cc +++ b/src/Vehicle/TerrainProtocolHandler.cc @@ -10,8 +10,6 @@ #include "TerrainProtocolHandler.h" #include "TerrainQuery.h" #include "Vehicle.h" -#include "QGCApplication.h" -#include "QGCToolbox.h" #include "MAVLinkProtocol.h" #include "QGCLoggingCategory.h" diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 58828f14685..376ab0eaba0 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -88,7 +88,6 @@ Vehicle::Vehicle(LinkInterface* link, , _defaultComponentId (defaultComponentId) , _firmwareType (firmwareType) , _vehicleType (vehicleType) - , _toolbox (qgcApp()->toolbox()) , _defaultCruiseSpeed (SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) , _defaultHoverSpeed (SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) , _trajectoryPoints (new TrajectoryPoints(this, this)) @@ -199,7 +198,6 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, , _offlineEditingVehicle (true) , _firmwareType (firmwareType) , _vehicleType (vehicleType) - , _toolbox (qgcApp()->toolbox()) , _defaultCruiseSpeed (SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) , _defaultHoverSpeed (SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) , _mavlinkProtocolRequestComplete (true) @@ -310,7 +308,7 @@ void Vehicle::_commonInit() _remoteIDManager = new RemoteIDManager(this); // Flight modes can differ based on advanced mode - connect(_toolbox->corePlugin(), &QGCCorePlugin::showAdvancedUIChanged, this, &Vehicle::flightModesChanged); + connect(QGCCorePlugin::instance(), &QGCCorePlugin::showAdvancedUIChanged, this, &Vehicle::flightModesChanged); _createImageProtocolManager(); _createStatusTextHandler(); @@ -502,7 +500,7 @@ void Vehicle::_mavlinkMessageReceived(LinkInterface* link, mavlink_message_t mes } // Give the Core Plugin access to all mavlink traffic - if (!_toolbox->corePlugin()->mavlinkMessage(this, link, message)) { + if (!QGCCorePlugin::instance()->mavlinkMessage(this, link, message)) { return; } diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index 9d0f01c6b45..c0a13a2bdde 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -73,7 +73,6 @@ class TerrainProtocolHandler; class TrajectoryPoints; class VehicleBatteryFactGroup; class VehicleObjectAvoidance; -class QGCToolbox; class GimbalController; #ifdef QGC_UTM_ADAPTER class UTMSPVehicle; @@ -991,7 +990,6 @@ private slots: QObject* _firmwarePluginInstanceData = nullptr; AutoPilotPlugin* _autopilotPlugin = nullptr; bool _soloFirmware = false; - QGCToolbox* _toolbox = nullptr; QTimer _csvLogTimer; QFile _csvLogFile; @@ -1084,8 +1082,6 @@ private slots: QmlObjectListModel _cameraTriggerPoints; //QMap _trafficVehicleMap; - // Toolbox references - bool _allLinksRemovedSent = false; ///< true: allLinkRemoved signal already sent one time uint _messagesReceived = 0; diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 9715420aa46..f264c1c51f0 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.cc +++ b/src/VehicleSetup/FirmwareUpgradeController.cc @@ -103,7 +103,7 @@ uint qHash(const FirmwareUpgradeController::FirmwareIdentifier& firmwareId) /// @Brief Constructs a new FirmwareUpgradeController Widget. This widget is used within the PX4VehicleConfig set of screens. FirmwareUpgradeController::FirmwareUpgradeController(void) - : _singleFirmwareURL (qgcApp()->toolbox()->corePlugin()->options()->firmwareUpgradeSingleURL()) + : _singleFirmwareURL (QGCCorePlugin::instance()->options()->firmwareUpgradeSingleURL()) , _singleFirmwareMode (!_singleFirmwareURL.isEmpty()) , _downloadingFirmwareList (false) , _statusLog (nullptr) diff --git a/src/VideoManager/VideoManager.cc b/src/VideoManager/VideoManager.cc index 0323531297e..729c25479da 100644 --- a/src/VideoManager/VideoManager.cc +++ b/src/VideoManager/VideoManager.cc @@ -13,7 +13,6 @@ #include "QGCCameraManager.h" #include "QGCCorePlugin.h" #include "QGCLoggingCategory.h" -#include "QGCToolbox.h" #include "SettingsManager.h" #include "AppSettings.h" #include "SubtitleWriter.h" @@ -73,11 +72,11 @@ VideoManager::~VideoManager() } if (videoReceiver.sink != nullptr) { - // qgcApp()->toolbox()->corePlugin()->releaseVideoSink(videoReceiver.sink); + // QGCCorePlugin::instance()->releaseVideoSink(videoReceiver.sink); #ifdef QGC_GST_STREAMING // FIXME: AV: we need some interaface for video sink with .release() call // Currently VideoManager is destroyed after corePlugin() and we are crashing on app exit - // calling _toolbox->corePlugin()->releaseVideoSink(_videoSink[i]); + // calling QGCCorePlugin::instance()->releaseVideoSink(_videoSink[i]); // As for now let's call GStreamer::releaseVideoSink() directly GStreamer::releaseVideoSink(videoReceiver.sink); #elif defined(QGC_QT_STREAMING) @@ -128,7 +127,7 @@ void VideoManager::init() int index = 0; for (VideoReceiverData &videoReceiver : _videoReceiverData) { videoReceiver.index = index++; - videoReceiver.receiver = qgcApp()->toolbox()->corePlugin()->createVideoReceiver(this); + videoReceiver.receiver = QGCCorePlugin::instance()->createVideoReceiver(this); if (!videoReceiver.receiver) { continue; } @@ -455,7 +454,7 @@ void VideoManager::_initVideo() for (VideoReceiverData &videoReceiver : _videoReceiverData) { QQuickItem* const widget = root->findChild(widgetTypes.at(videoReceiver.index)); if ((widget != nullptr) && (videoReceiver.receiver != nullptr)) { - videoReceiver.sink = qgcApp()->toolbox()->corePlugin()->createVideoSink(this, widget); + videoReceiver.sink = QGCCorePlugin::instance()->createVideoSink(this, widget); if (videoReceiver.sink != nullptr) { if (videoReceiver.started) { videoReceiver.receiver->startDecoding(videoReceiver.sink); diff --git a/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt b/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt index e97d26e52a0..34be80a67df 100644 --- a/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt +++ b/src/VideoManager/VideoReceiver/GStreamer/CMakeLists.txt @@ -40,7 +40,6 @@ endif() target_link_libraries(GStreamerReceiver PRIVATE - QGC Utilities PUBLIC Qt6::Core diff --git a/test/AnalyzeView/CMakeLists.txt b/test/AnalyzeView/CMakeLists.txt index 5f1451e46b5..4afb2129a73 100644 --- a/test/AnalyzeView/CMakeLists.txt +++ b/test/AnalyzeView/CMakeLists.txt @@ -22,7 +22,6 @@ target_link_libraries(AnalyzeViewTest Qt6::Test AnalyzeView MAVLink - QGC Utilities Vehicle PUBLIC diff --git a/test/AnalyzeView/MavlinkLogTest.cc b/test/AnalyzeView/MavlinkLogTest.cc index 3d7952eaff4..9012878ecbe 100644 --- a/test/AnalyzeView/MavlinkLogTest.cc +++ b/test/AnalyzeView/MavlinkLogTest.cc @@ -15,7 +15,6 @@ #include "MavlinkLogTest.h" #include "QGCTemporaryFile.h" -#include "QGCApplication.h" #include "MultiVehicleManager.h" #include "Vehicle.h" #include "MAVLinkProtocol.h" diff --git a/test/AutoPilotPlugins/CMakeLists.txt b/test/AutoPilotPlugins/CMakeLists.txt index 139696c8929..8be814fec6c 100644 --- a/test/AutoPilotPlugins/CMakeLists.txt +++ b/test/AutoPilotPlugins/CMakeLists.txt @@ -11,7 +11,6 @@ target_link_libraries(AutoPilotPluginsTest APMAutoPilotPlugin AutoPilotPlugins PX4AutoPilotPlugin - QGC Vehicle PUBLIC Qt6::Core diff --git a/test/AutoPilotPlugins/RadioConfigTest.cc b/test/AutoPilotPlugins/RadioConfigTest.cc index 9f4be463380..9e528e1a627 100644 --- a/test/AutoPilotPlugins/RadioConfigTest.cc +++ b/test/AutoPilotPlugins/RadioConfigTest.cc @@ -11,7 +11,6 @@ #include "RadioConfigTest.h" #include "RadioComponentController.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "PX4/PX4AutoPilotPlugin.h" #include "APM/APMAutoPilotPlugin.h" #include "APM/APMRadioComponent.h" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a5a7e80e5b7..246954d671c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -151,7 +151,6 @@ target_link_libraries(qgctest UITest VehicleTest VehicleComponentsTest - QGC Utilities UtilitiesTest PUBLIC diff --git a/test/FactSystem/CMakeLists.txt b/test/FactSystem/CMakeLists.txt index 836aeb7b407..e89f724b017 100644 --- a/test/FactSystem/CMakeLists.txt +++ b/test/FactSystem/CMakeLists.txt @@ -18,7 +18,6 @@ target_link_libraries(FactSystemTest Qt6::Test AutoPilotPlugins FactSystem - QGC Settings Vehicle PUBLIC diff --git a/test/FactSystem/FactSystemTestBase.cc b/test/FactSystem/FactSystemTestBase.cc index 5ff5e8d682d..8cc344b234c 100644 --- a/test/FactSystem/FactSystemTestBase.cc +++ b/test/FactSystem/FactSystemTestBase.cc @@ -14,7 +14,6 @@ #include "FactSystemTestBase.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "ParameterManager.h" #include "AutoPilotPlugin.h" #include "MAVLinkProtocol.h" diff --git a/test/FactSystem/ParameterManagerTest.cc b/test/FactSystem/ParameterManagerTest.cc index 406bc761b3d..cfaf6b4750b 100644 --- a/test/FactSystem/ParameterManagerTest.cc +++ b/test/FactSystem/ParameterManagerTest.cc @@ -11,7 +11,6 @@ #include "ParameterManagerTest.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "ParameterManager.h" #include diff --git a/test/MissionManager/CMakeLists.txt b/test/MissionManager/CMakeLists.txt index d5f87187124..37a93e1d73f 100644 --- a/test/MissionManager/CMakeLists.txt +++ b/test/MissionManager/CMakeLists.txt @@ -32,7 +32,6 @@ target_link_libraries(MissionManagerTest Qt6::Test API FirmwarePlugin - QGC Settings Utilities Vehicle diff --git a/test/MissionManager/CameraSectionTest.cc b/test/MissionManager/CameraSectionTest.cc index 3f3d570defd..99922571ee0 100644 --- a/test/MissionManager/CameraSectionTest.cc +++ b/test/MissionManager/CameraSectionTest.cc @@ -12,7 +12,6 @@ #include "MissionCommandTree.h" #include "MissionCommandUIInfo.h" #include "PlanMasterController.h" -#include "QGCApplication.h" #include "SimpleMissionItem.h" #include "MultiSignalSpy.h" diff --git a/test/MissionManager/MissionCommandTreeEditorTest.cc b/test/MissionManager/MissionCommandTreeEditorTest.cc index a3c0229baba..44e40ac75a5 100644 --- a/test/MissionManager/MissionCommandTreeEditorTest.cc +++ b/test/MissionManager/MissionCommandTreeEditorTest.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "MissionCommandTreeEditorTest.h" -#include "QGCApplication.h" #include "QGCCorePlugin.h" #include "FirmwarePlugin.h" #include "FirmwarePluginManager.h" @@ -49,7 +48,7 @@ void MissionCommandTreeEditorTest::_testEditorsWorker(QGCMAVLink::FirmwareClass_ varSimpleItems.append(QVariant::fromValue(simpleItem)); } - QQmlApplicationEngine* qmlAppEngine = qgcApp()->toolbox()->corePlugin()->createQmlApplicationEngine(this); + QQmlApplicationEngine* qmlAppEngine = QGCCorePlugin::instance()->createQmlApplicationEngine(this); qmlAppEngine->rootContext()->setContextProperty("planMasterController", &masterController); qmlAppEngine->rootContext()->setContextProperty("missionItems", varSimpleItems); qmlAppEngine->rootContext()->setContextProperty("cColumns", cColumns); diff --git a/test/MissionManager/MissionControllerManagerTest.cc b/test/MissionManager/MissionControllerManagerTest.cc index ba5c0866b88..30800e8a9f7 100644 --- a/test/MissionManager/MissionControllerManagerTest.cc +++ b/test/MissionManager/MissionControllerManagerTest.cc @@ -11,7 +11,6 @@ #include "MissionControllerManagerTest.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "MultiSignalSpy.h" MissionControllerManagerTest::MissionControllerManagerTest(void) diff --git a/test/Vehicle/CMakeLists.txt b/test/Vehicle/CMakeLists.txt index d21a293a968..bfbc35b94cc 100644 --- a/test/Vehicle/CMakeLists.txt +++ b/test/Vehicle/CMakeLists.txt @@ -23,7 +23,6 @@ qt_add_library(VehicleTest target_link_libraries(VehicleTest PRIVATE Qt6::Test - QGC PUBLIC Comms qgcunittest diff --git a/test/Vehicle/FTPManagerTest.cc b/test/Vehicle/FTPManagerTest.cc index 318231ca666..977da004485 100644 --- a/test/Vehicle/FTPManagerTest.cc +++ b/test/Vehicle/FTPManagerTest.cc @@ -10,7 +10,6 @@ #include "FTPManagerTest.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "MockLink.h" #include "FTPManager.h" diff --git a/test/Vehicle/InitialConnectTest.cc b/test/Vehicle/InitialConnectTest.cc index 1f4ab2e7094..4dfe40d0efa 100644 --- a/test/Vehicle/InitialConnectTest.cc +++ b/test/Vehicle/InitialConnectTest.cc @@ -9,7 +9,6 @@ #include "InitialConnectTest.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "LinkManager.h" #include "MockLink.h" #include "Vehicle.h" diff --git a/test/Vehicle/MAVLinkLogManagerTest.cc b/test/Vehicle/MAVLinkLogManagerTest.cc index 85dabadeb5f..3405e7e98ef 100644 --- a/test/Vehicle/MAVLinkLogManagerTest.cc +++ b/test/Vehicle/MAVLinkLogManagerTest.cc @@ -11,8 +11,6 @@ #include "MAVLinkLogManager.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" -#include "QGCToolbox.h" #include #include diff --git a/test/Vehicle/RequestMessageTest.cc b/test/Vehicle/RequestMessageTest.cc index bda0743fe83..483f9a19740 100644 --- a/test/Vehicle/RequestMessageTest.cc +++ b/test/Vehicle/RequestMessageTest.cc @@ -9,7 +9,6 @@ #include "RequestMessageTest.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "MockLink.h" #include diff --git a/test/Vehicle/SendMavCommandWithHandlerTest.cc b/test/Vehicle/SendMavCommandWithHandlerTest.cc index 8c0a90405b0..52a5e04c5f2 100644 --- a/test/Vehicle/SendMavCommandWithHandlerTest.cc +++ b/test/Vehicle/SendMavCommandWithHandlerTest.cc @@ -9,7 +9,6 @@ #include "SendMavCommandWithHandlerTest.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "MockLink.h" #include diff --git a/test/Vehicle/SendMavCommandWithSignallingTest.cc b/test/Vehicle/SendMavCommandWithSignallingTest.cc index 84409bc2893..8d0b3123362 100644 --- a/test/Vehicle/SendMavCommandWithSignallingTest.cc +++ b/test/Vehicle/SendMavCommandWithSignallingTest.cc @@ -9,7 +9,6 @@ #include "SendMavCommandWithSignallingTest.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "MockLink.h" SendMavCommandWithSignallingTest::TestCase_t SendMavCommandWithSignallingTest::_rgTestCases[] = { diff --git a/test/Vehicle/VehicleLinkManagerTest.cc b/test/Vehicle/VehicleLinkManagerTest.cc index b6d8021545c..31c58c7461c 100644 --- a/test/Vehicle/VehicleLinkManagerTest.cc +++ b/test/Vehicle/VehicleLinkManagerTest.cc @@ -8,12 +8,10 @@ ****************************************************************************/ #include "VehicleLinkManagerTest.h" -#include "QGCApplication.h" #include "MockLink.h" #include "LinkManager.h" #include "MultiVehicleManager.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "MultiSignalSpyV2.h" #include diff --git a/test/qgcunittest/CMakeLists.txt b/test/qgcunittest/CMakeLists.txt index 4c31d712fb8..cbdc537a359 100644 --- a/test/qgcunittest/CMakeLists.txt +++ b/test/qgcunittest/CMakeLists.txt @@ -20,7 +20,6 @@ target_link_libraries(qgcunittest PRIVATE FactSystem MissionManager - QGC Settings Vehicle VehicleComponents