From 4797dd757414c7e11a5636fe2cb08bba4872aba5 Mon Sep 17 00:00:00 2001 From: Holden Date: Fri, 29 Nov 2024 05:16:02 -0500 Subject: [PATCH] Convert SettingsManager to Singleton --- CMakeLists.txt | 8 +- src/ADSB/ADSBVehicleManager.cc | 3 +- src/API/QGCCorePlugin.cc | 3 +- src/AnalyzeView/LogDownloadController.cc | 4 +- src/Camera/SimulatedCameraControl.cc | 5 +- src/Camera/VehicleCameraControl.cc | 7 +- src/Comms/AirLink/AirLinkLink.cc | 2 +- src/Comms/AirLink/AirLinkManager.cc | 4 +- src/Comms/LinkInterface.cc | 2 +- src/Comms/LinkManager.cc | 10 +- src/Comms/MAVLinkProtocol.cc | 12 +- src/Comms/UDPLink.cc | 4 +- src/FactSystem/FactMetaData.cc | 6 +- src/FirmwarePlugin/APM/APMFirmwarePlugin.cc | 10 +- src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc | 2 +- src/FollowMe/CMakeLists.txt | 1 - src/FollowMe/FollowMe.cc | 5 +- src/GPS/CMakeLists.txt | 1 - src/GPS/GPSRtk.cc | 3 +- src/GPS/RTCMMavlink.cc | 1 - src/Gimbal/CMakeLists.txt | 1 - src/Gimbal/GimbalController.cc | 12 +- src/Joystick/CMakeLists.txt | 1 - src/Joystick/Joystick.cc | 7 +- src/Joystick/JoystickManager.cc | 1 - src/MissionManager/ComplexMissionItem.cc | 4 +- src/MissionManager/ComplexMissionItem.h | 5 - src/MissionManager/CorridorScanComplexItem.cc | 2 +- src/MissionManager/GeoFenceController.cc | 3 +- src/MissionManager/MissionController.cc | 8 +- src/MissionManager/PlanMasterController.cc | 2 +- src/MissionManager/RallyPointController.cc | 3 +- src/MissionManager/SimpleMissionItem.cc | 4 +- .../StructureScanComplexItem.cc | 2 +- src/MissionManager/SurveyComplexItem.cc | 2 +- src/MissionManager/TakeoffMissionItem.cc | 4 +- src/MissionManager/VTOLLandingComplexItem.cc | 4 +- src/QGCApplication.cc | 7 +- src/QGCToolbox.cc | 7 - src/QGCToolbox.h | 5 - src/QmlControls/AppMessages.cc | 18 +- src/QmlControls/CustomActionManager.cc | 3 +- src/QmlControls/QGCFileDialogController.cc | 4 +- src/QmlControls/QGroundControlQmlGlobal.cc | 2 +- src/QmlControls/QGroundControlQmlGlobal.h | 2 +- src/QmlControls/ScreenToolsController.cc | 3 +- .../Providers/EsriMapProvider.cpp | 4 +- .../Providers/GenericMapProvider.cpp | 6 +- .../Providers/MapboxMapProvider.cpp | 8 +- src/QtLocationPlugin/QGeoFileTileCacheQGC.cpp | 8 +- .../QMLControl/QGCMapEngineManager.cc | 6 +- src/Settings/CMakeLists.txt | 5 +- src/Settings/SettingsManager.cc | 143 ++++++++---- src/Settings/SettingsManager.h | 221 ++++++++++-------- src/Settings/VideoSettings.cc | 1 - src/Terrain/TerrainTileManager.cc | 4 +- src/Vehicle/MAVLinkLogManager.cc | 8 +- src/Vehicle/MultiVehicleManager.cc | 3 +- src/Vehicle/RemoteIDManager.cc | 3 +- src/Vehicle/Vehicle.cc | 54 ++--- src/Vehicle/Vehicle.h | 2 - src/VehicleSetup/FirmwareUpgradeController.cc | 4 +- src/VideoManager/CMakeLists.txt | 3 +- src/VideoManager/VideoManager.cc | 47 ++-- src/VideoManager/VideoManager.h | 6 +- src/Viewer3D/CMakeLists.txt | 1 - src/Viewer3D/CityMapGeometry.cc | 4 +- src/Viewer3D/OsmParser.cc | 4 +- src/Viewer3D/Viewer3DQmlBackend.cc | 3 +- src/Viewer3D/Viewer3DTerrainGeometry.cc | 3 +- src/Viewer3D/Viewer3DTerrainTexture.cc | 3 +- test/FollowMe/CMakeLists.txt | 1 - test/FollowMe/FollowMeTest.cc | 4 +- .../MissionCommandTreeEditorTest.cc | 3 +- test/MissionManager/MissionControllerTest.cc | 6 +- test/MissionManager/SimpleMissionItemTest.cc | 4 +- .../TransectStyleComplexItemTestBase.cc | 3 +- test/qgcunittest/UnitTest.cc | 3 +- 78 files changed, 426 insertions(+), 361 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d438c55388..2b76489844a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,6 +229,10 @@ if(QGC_DISABLE_APM_MAVLINK) add_compile_definitions(NO_ARDUPILOT_DIALECT) endif() +if(QGC_VIEWER3D) + add_compile_definitions(QGC_VIEWER3D) +endif() + if("${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm64;x86_64" OR "${CMAKE_OSX_ARCHITECTURES}" MATCHES "x86_64;arm64") set(MACOS_UNIVERSAL_BUILD ON CACHE INTERNAL "" FORCE) endif() @@ -246,10 +250,6 @@ if(QGC_CUSTOM_BUILD) add_subdirectory(custom) endif() -if(QGC_DISABLE_APM_MAVLINK) - add_compile_definitions(NO_ARDUPILOT_DIALECT) -endif() - ####################################################### # QGroundControl Resources ####################################################### diff --git a/src/ADSB/ADSBVehicleManager.cc b/src/ADSB/ADSBVehicleManager.cc index 503d52c9c3e..add199fa173 100644 --- a/src/ADSB/ADSBVehicleManager.cc +++ b/src/ADSB/ADSBVehicleManager.cc @@ -9,7 +9,6 @@ #include "ADSBVehicleManager.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "SettingsManager.h" #include "ADSBVehicleManagerSettings.h" #include "ADSBTCPLink.h" @@ -23,7 +22,7 @@ QGC_LOGGING_CATEGORY(ADSBVehicleManagerLog, "qgc.adsb.adsbvehiclemanager") -Q_APPLICATION_STATIC(ADSBVehicleManager, _adsbVehicleManager, qgcApp()->toolbox()->settingsManager()->adsbVehicleManagerSettings()); +Q_APPLICATION_STATIC(ADSBVehicleManager, _adsbVehicleManager, SettingsManager::instance()->adsbVehicleManagerSettings()); ADSBVehicleManager::ADSBVehicleManager(ADSBVehicleManagerSettings *settings, QObject *parent) : QObject(parent) diff --git a/src/API/QGCCorePlugin.cc b/src/API/QGCCorePlugin.cc index 29bfc2db1d8..e57159e0ce5 100644 --- a/src/API/QGCCorePlugin.cc +++ b/src/API/QGCCorePlugin.cc @@ -13,6 +13,7 @@ #include "QmlComponentInfo.h" #include "FactMetaData.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "AppMessages.h" #include "QmlObjectListModel.h" #include "JoystickManager.h" @@ -400,7 +401,7 @@ QVariantList QGCCorePlugin::firstRunPromptsToShow(void) rgIdsToShow.append(firstRunPromptStdIds()); rgIdsToShow.append(firstRunPromptCustomIds()); - QList rgAlreadyShownIds = AppSettings::firstRunPromptsIdsVariantToList(_toolbox->settingsManager()->appSettings()->firstRunPromptIdsShown()->rawValue()); + QList rgAlreadyShownIds = AppSettings::firstRunPromptsIdsVariantToList(SettingsManager::instance()->appSettings()->firstRunPromptIdsShown()->rawValue()); for (int idToRemove: rgAlreadyShownIds) { rgIdsToShow.removeOne(idToRemove); diff --git a/src/AnalyzeView/LogDownloadController.cc b/src/AnalyzeView/LogDownloadController.cc index a100b86c071..45910ebc440 100644 --- a/src/AnalyzeView/LogDownloadController.cc +++ b/src/AnalyzeView/LogDownloadController.cc @@ -10,10 +10,10 @@ #include "LogDownloadController.h" #include "MultiVehicleManager.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "ParameterManager.h" #include "Vehicle.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "MAVLinkProtocol.h" #include "LogEntry.h" #include "QGCLoggingCategory.h" @@ -445,7 +445,7 @@ LogDownloadController::download(QString path) { QString dir = path; if (dir.isEmpty()) { - dir = qgcApp()->toolbox()->settingsManager()->appSettings()->logSavePath(); + dir = SettingsManager::instance()->appSettings()->logSavePath(); } downloadToDirectory(dir); } diff --git a/src/Camera/SimulatedCameraControl.cc b/src/Camera/SimulatedCameraControl.cc index 2f41a9ea42d..574be395161 100644 --- a/src/Camera/SimulatedCameraControl.cc +++ b/src/Camera/SimulatedCameraControl.cc @@ -11,6 +11,7 @@ #include "VideoManager.h" #include "QGCApplication.h" #include "SettingsManager.h" +#include "FlyViewSettings.h" #include "Vehicle.h" #include @@ -24,7 +25,7 @@ SimulatedCameraControl::SimulatedCameraControl(Vehicle* vehicle, QObject* parent connect(VideoManager::instance(), &VideoManager::recordingChanged, this, &SimulatedCameraControl::videoCaptureStatusChanged); - auto flyViewSettings = qgcApp()->toolbox()->settingsManager()->flyViewSettings(); + auto flyViewSettings = SettingsManager::instance()->flyViewSettings(); connect(flyViewSettings->showSimpleCameraControl(), &Fact::rawValueChanged, this, &SimulatedCameraControl::infoChanged); _videoRecordTimeUpdateTimer.setInterval(1000); @@ -201,7 +202,7 @@ void SimulatedCameraControl::setPhotoLapse(double) bool SimulatedCameraControl::capturesPhotos() { - return qgcApp()->toolbox()->settingsManager()->flyViewSettings()->showSimpleCameraControl()->rawValue().toBool(); + return SettingsManager::instance()->flyViewSettings()->showSimpleCameraControl()->rawValue().toBool(); } bool SimulatedCameraControl::hasVideoStream() diff --git a/src/Camera/VehicleCameraControl.cc b/src/Camera/VehicleCameraControl.cc index a8c6f3afeed..fc725fd77c8 100644 --- a/src/Camera/VehicleCameraControl.cc +++ b/src/Camera/VehicleCameraControl.cc @@ -18,6 +18,7 @@ #include "QGCCameraIO.h" #include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "VideoManager.h" #include "QGCCameraManager.h" #include "FTPManager.h" @@ -130,7 +131,7 @@ VehicleCameraControl::VehicleCameraControl(const mavlink_camera_information_t *i _modelName = QString(reinterpret_cast(info->model_name)); int ver = static_cast(_info.cam_definition_version); _cacheFile = QString::asprintf("%s/%s_%s_%03d.xml", - qgcApp()->toolbox()->settingsManager()->appSettings()->parameterSavePath().toStdString().c_str(), + SettingsManager::instance()->appSettings()->parameterSavePath().toStdString().c_str(), _vendor.toStdString().c_str(), _modelName.toStdString().c_str(), ver); @@ -1560,7 +1561,7 @@ VehicleCameraControl::handleCaptureStatus(const mavlink_camera_capture_status_t& //-- Time Lapse if(photoCaptureStatus() == PHOTO_CAPTURE_INTERVAL_IDLE || photoCaptureStatus() == PHOTO_CAPTURE_INTERVAL_IN_PROGRESS) { //-- Capture local image as well - QString photoPath = qgcApp()->toolbox()->settingsManager()->appSettings()->savePath()->rawValue().toString() + QStringLiteral("/Photo"); + QString photoPath = SettingsManager::instance()->appSettings()->savePath()->rawValue().toString() + QStringLiteral("/Photo"); QDir().mkpath(photoPath); photoPath += + "/" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss.zzz") + ".jpg"; VideoManager::instance()->grabImage(photoPath); @@ -2038,7 +2039,7 @@ VehicleCameraControl::_handleDefinitionFile(const QString &url) ext.toStdString().c_str()); connect(_vehicle->ftpManager(), &FTPManager::downloadComplete, this, &VehicleCameraControl::_ftpDownloadComplete); _vehicle->ftpManager()->download(_compID, url, - qgcApp()->toolbox()->settingsManager()->appSettings()->parameterSavePath().toStdString().c_str(), + SettingsManager::instance()->appSettings()->parameterSavePath().toStdString().c_str(), fileName); return; } diff --git a/src/Comms/AirLink/AirLinkLink.cc b/src/Comms/AirLink/AirLinkLink.cc index 6a5ba33e054..1e7e45b8929 100644 --- a/src/Comms/AirLink/AirLinkLink.cc +++ b/src/Comms/AirLink/AirLinkLink.cc @@ -183,7 +183,7 @@ void AirLinkConfiguration::setModemName(const QString &modemName) void AirLinkConfiguration::loadSettings(QSettings &settings, const QString &root) { - AppSettings *const appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings *const appSettings = SettingsManager::instance()->appSettings(); settings.beginGroup(root); diff --git a/src/Comms/AirLink/AirLinkManager.cc b/src/Comms/AirLink/AirLinkManager.cc index 9bfe3d9199e..499a7e1b2a9 100644 --- a/src/Comms/AirLink/AirLinkManager.cc +++ b/src/Comms/AirLink/AirLinkManager.cc @@ -47,8 +47,8 @@ bool AirLinkManager::isOnline(const QString &drone) void AirLinkManager::updateCredentials(const QString &login, const QString &pass) { - qgcApp()->toolbox()->settingsManager()->appSettings()->loginAirLink()->setRawValue(login); - qgcApp()->toolbox()->settingsManager()->appSettings()->passAirLink()->setRawValue(pass); + SettingsManager::instance()->appSettings()->loginAirLink()->setRawValue(login); + SettingsManager::instance()->appSettings()->passAirLink()->setRawValue(pass); } void AirLinkManager::_connectToAirLinkServer(const QString &login, const QString &pass) diff --git a/src/Comms/LinkInterface.cc b/src/Comms/LinkInterface.cc index ba5122e6b60..3126448f07b 100644 --- a/src/Comms/LinkInterface.cc +++ b/src/Comms/LinkInterface.cc @@ -56,7 +56,7 @@ bool LinkInterface::mavlinkChannelIsSet() const bool LinkInterface::initMavlinkSigning(void) { if (!isSecureConnection()) { - auto appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + auto appSettings = SettingsManager::instance()->appSettings(); QByteArray signingKeyBytes = appSettings->mavlink2SigningKey()->rawValue().toByteArray(); if (MAVLinkSigning::initSigning(static_cast(_mavlinkChannel), signingKeyBytes, MAVLinkSigning::insecureConnectionAccceptUnsignedCallback)) { if (signingKeyBytes.isEmpty()) { diff --git a/src/Comms/LinkManager.cc b/src/Comms/LinkManager.cc index 7f3b191f9b6..9c0981c89ef 100644 --- a/src/Comms/LinkManager.cc +++ b/src/Comms/LinkManager.cc @@ -16,6 +16,8 @@ #include "QGCLoggingCategory.h" #include "QmlObjectListModel.h" #include "SettingsManager.h" +#include "AppSettings.h" +#include "AutoConnectSettings.h" #include "TCPLink.h" #include "UDPLink.h" @@ -96,7 +98,7 @@ void LinkManager::registerQmlTypes() void LinkManager::init() { - _autoConnectSettings = qgcApp()->toolbox()->settingsManager()->autoConnectSettings(); + _autoConnectSettings = SettingsManager::instance()->autoConnectSettings(); if (!qgcApp()->runningUnitTests()) { (void) connect(_portListTimer, &QTimer::timeout, this, &LinkManager::_updateAutoConnectLinks); @@ -398,7 +400,7 @@ void LinkManager::_addUDPAutoConnectLink() void LinkManager::_addMAVLinkForwardingLink() { - if (!qgcApp()->toolbox()->settingsManager()->appSettings()->forwardMavlink()->rawValue().toBool()) { + if (!SettingsManager::instance()->appSettings()->forwardMavlink()->rawValue().toBool()) { return; } @@ -410,7 +412,7 @@ void LinkManager::_addMAVLinkForwardingLink() } } - const QString hostName = qgcApp()->toolbox()->settingsManager()->appSettings()->forwardMavlinkHostName()->rawValue().toString(); + const QString hostName = SettingsManager::instance()->appSettings()->forwardMavlinkHostName()->rawValue().toString(); _createDynamicForwardLink(_mavlinkForwardingLinkName, hostName); } @@ -615,7 +617,7 @@ void LinkManager::removeConfiguration(LinkConfiguration *config) void LinkManager::createMavlinkForwardingSupportLink() { - const QString hostName = qgcApp()->toolbox()->settingsManager()->appSettings()->forwardMavlinkAPMSupportHostName()->rawValue().toString(); + const QString hostName = SettingsManager::instance()->appSettings()->forwardMavlinkAPMSupportHostName()->rawValue().toString(); _createDynamicForwardLink(_mavlinkForwardingSupportLinkName, hostName); _mavlinkSupportForwardingEnabled = true; emit mavlinkSupportForwardingEnabledChanged(); diff --git a/src/Comms/MAVLinkProtocol.cc b/src/Comms/MAVLinkProtocol.cc index 092b8a60350..d91e774c5b2 100644 --- a/src/Comms/MAVLinkProtocol.cc +++ b/src/Comms/MAVLinkProtocol.cc @@ -13,8 +13,8 @@ #include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "QGCTemporaryFile.h" -#include "QGCToolbox.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "QmlObjectListModel.h" #include @@ -220,7 +220,7 @@ void MAVLinkProtocol::_forward(const mavlink_message_t &message) return; } - if (!qgcApp()->toolbox()->settingsManager()->appSettings()->forwardMavlink()->rawValue().toBool()) { + if (!SettingsManager::instance()->appSettings()->forwardMavlink()->rawValue().toBool()) { return; } @@ -343,7 +343,7 @@ void MAVLinkProtocol::_startLogging() return; } - AppSettings *const appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings *const appSettings = SettingsManager::instance()->appSettings(); if (appSettings->disableAllPersistence()->rawValue().toBool()) { return; } @@ -379,7 +379,7 @@ void MAVLinkProtocol::_startLogging() void MAVLinkProtocol::_stopLogging() { if (_tempLogFile->isOpen() && _closeLogFile()) { - AppSettings *const appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings *const appSettings = SettingsManager::instance()->appSettings(); if ((_vehicleWasArmed || appSettings->telemetrySaveNotArmed()->rawValue().toBool()) && appSettings->telemetrySave()->rawValue().toBool() && !appSettings->disableAllPersistence()->rawValue().toBool()) { _saveTelemetryLog(_tempLogFile->fileName()); } else { @@ -426,7 +426,7 @@ void MAVLinkProtocol::deleteTempLogFiles() void MAVLinkProtocol::_saveTelemetryLog(const QString &tempLogfile) { if (_checkTelemetrySavePath()) { - const QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->telemetrySavePath(); + const QString saveDirPath = SettingsManager::instance()->appSettings()->telemetrySavePath(); const QDir saveDir(saveDirPath); const QString nameFormat("%1%2.%3"); @@ -451,7 +451,7 @@ void MAVLinkProtocol::_saveTelemetryLog(const QString &tempLogfile) bool MAVLinkProtocol::_checkTelemetrySavePath() { - const QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->telemetrySavePath(); + const QString saveDirPath = SettingsManager::instance()->appSettings()->telemetrySavePath(); if (saveDirPath.isEmpty()) { const QString error = tr("Unable to save telemetry log. Application save directory is not set."); qgcApp()->showAppMessage(error); diff --git a/src/Comms/UDPLink.cc b/src/Comms/UDPLink.cc index ec92d15cad2..352d0883b5c 100644 --- a/src/Comms/UDPLink.cc +++ b/src/Comms/UDPLink.cc @@ -315,7 +315,7 @@ bool UDPLink::isSecureConnection() UDPConfiguration::UDPConfiguration(const QString& name) : LinkConfiguration(name) { - AutoConnectSettings* settings = qgcApp()->toolbox()->settingsManager()->autoConnectSettings(); + AutoConnectSettings* settings = SettingsManager::instance()->autoConnectSettings(); _localPort = settings->udpListenPort()->rawValue().toInt(); QString targetHostIP = settings->udpTargetHostIP()->rawValue().toString(); if (!targetHostIP.isEmpty()) { @@ -434,7 +434,7 @@ void UDPConfiguration::saveSettings(QSettings& settings, const QString& root) void UDPConfiguration::loadSettings(QSettings& settings, const QString& root) { - AutoConnectSettings* acSettings = qgcApp()->toolbox()->settingsManager()->autoConnectSettings(); + AutoConnectSettings* acSettings = SettingsManager::instance()->autoConnectSettings(); _clearTargetHosts(); settings.beginGroup(root); _localPort = (quint16)settings.value("port", acSettings->udpListenPort()->rawValue().toInt()).toUInt(); diff --git a/src/FactSystem/FactMetaData.cc b/src/FactSystem/FactMetaData.cc index e9e649c441a..f80f2d50dae 100644 --- a/src/FactSystem/FactMetaData.cc +++ b/src/FactSystem/FactMetaData.cc @@ -9,8 +9,8 @@ #include "FactMetaData.h" #include "SettingsManager.h" +#include "UnitsSettings.h" #include "JsonHelper.h" -#include "QGCApplication.h" #include #include @@ -908,7 +908,7 @@ void FactMetaData::_setAppSettingsTranslators(void) continue; } - UnitsSettings* settings = qgcApp()->toolbox()->settingsManager()->unitsSettings(); + UnitsSettings* settings = SettingsManager::instance()->unitsSettings(); uint settingsUnits = 0; switch (pAppSettingsTranslation->unitType) { @@ -953,7 +953,7 @@ const FactMetaData::AppSettingsTranslation_s* FactMetaData::_findAppSettingsUnit } uint unitOption = 0; - auto unitsSettings = qgcApp()->toolbox()->settingsManager()->unitsSettings(); + auto unitsSettings = SettingsManager::instance()->unitsSettings(); switch (type) { case UnitHorizontalDistance: unitOption = unitsSettings->horizontalDistanceUnits()->rawValue().toUInt(); diff --git a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc index b4126e0753c..d7a3c404a99 100644 --- a/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc +++ b/src/FirmwarePlugin/APM/APMFirmwarePlugin.cc @@ -20,6 +20,8 @@ #include "ParameterManager.h" #include "SettingsManager.h" #include "AppSettings.h" +#include "PlanViewSettings.h" +#include "VideoSettings.h" #include "APMMavlinkStreamRateSettings.h" #include "ArduPlaneFirmwarePlugin.h" #include "ArduCopterFirmwarePlugin.h" @@ -411,9 +413,9 @@ void APMFirmwarePlugin::initializeStreamRates(Vehicle* vehicle) vehicle->setFirmwarePluginInstanceData(instanceData); } - if (qgcApp()->toolbox()->settingsManager()->appSettings()->apmStartMavlinkStreams()->rawValue().toBool()) { + if (SettingsManager::instance()->appSettings()->apmStartMavlinkStreams()->rawValue().toBool()) { - APMMavlinkStreamRateSettings* streamRates = qgcApp()->toolbox()->settingsManager()->apmMavlinkStreamRateSettings(); + APMMavlinkStreamRateSettings* streamRates = SettingsManager::instance()->apmMavlinkStreamRateSettings(); struct StreamInfo_s { MAV_DATA_STREAM mavStream; @@ -487,7 +489,7 @@ void APMFirmwarePlugin::initializeVehicle(Vehicle* vehicle) initializeStreamRates(vehicle); } - if (qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSource()->rawValue() == VideoSettings::videoSource3DRSolo) { + if (SettingsManager::instance()->videoSettings()->videoSource()->rawValue() == VideoSettings::videoSource3DRSolo) { _soloVideoHandshake(); } } @@ -573,7 +575,7 @@ QList APMFirmwarePlugin::supportedMissionCommands(QGCMAVLink::VehicleCl supportedCommands += flightCommands; } - if (qgcApp()->toolbox()->settingsManager()->planViewSettings()->useConditionGate()->rawValue().toBool()) { + if (SettingsManager::instance()->planViewSettings()->useConditionGate()->rawValue().toBool()) { supportedCommands.append(MAV_CMD_CONDITION_GATE); } diff --git a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc index 270209d3214..2a217e766b2 100644 --- a/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc +++ b/src/FirmwarePlugin/PX4/PX4FirmwarePlugin.cc @@ -304,7 +304,7 @@ QList PX4FirmwarePlugin::supportedMissionCommands(QGCMAVLink::VehicleCl supportedCommands += flightCommands; } - if (qgcApp()->toolbox()->settingsManager()->planViewSettings()->useConditionGate()->rawValue().toBool()) { + if (SettingsManager::instance()->planViewSettings()->useConditionGate()->rawValue().toBool()) { supportedCommands.append(MAV_CMD_CONDITION_GATE); } diff --git a/src/FollowMe/CMakeLists.txt b/src/FollowMe/CMakeLists.txt index e705fd61df3..228475d34c9 100644 --- a/src/FollowMe/CMakeLists.txt +++ b/src/FollowMe/CMakeLists.txt @@ -10,7 +10,6 @@ target_link_libraries(FollowMe Qt6::Positioning FirmwarePlugin PositionManager - QGC Settings Utilities Vehicle diff --git a/src/FollowMe/FollowMe.cc b/src/FollowMe/FollowMe.cc index 1e69be7ea68..710f91392c5 100644 --- a/src/FollowMe/FollowMe.cc +++ b/src/FollowMe/FollowMe.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "FollowMe.h" -#include "QGCApplication.h" #include "MultiVehicleManager.h" #include "FirmwarePlugin.h" #include "Vehicle.h" @@ -47,9 +46,9 @@ void FollowMe::init() static bool once = false; if (!once) { (void) connect(_gcsMotionReportTimer, &QTimer::timeout, this, &FollowMe::_sendGCSMotionReport); - (void) connect(qgcApp()->toolbox()->settingsManager()->appSettings()->followTarget(), &Fact::rawValueChanged, this, &FollowMe::_settingsChanged); + (void) connect(SettingsManager::instance()->appSettings()->followTarget(), &Fact::rawValueChanged, this, &FollowMe::_settingsChanged); - _settingsChanged(qgcApp()->toolbox()->settingsManager()->appSettings()->followTarget()->rawValue()); + _settingsChanged(SettingsManager::instance()->appSettings()->followTarget()->rawValue()); } once = true; } diff --git a/src/GPS/CMakeLists.txt b/src/GPS/CMakeLists.txt index b680e706254..9dc4ea32fd8 100644 --- a/src/GPS/CMakeLists.txt +++ b/src/GPS/CMakeLists.txt @@ -69,7 +69,6 @@ target_link_libraries(GPS PRIVATE Comms MAVLink - QGC Settings Utilities Vehicle diff --git a/src/GPS/GPSRtk.cc b/src/GPS/GPSRtk.cc index 153c4d8cd65..78ef642155a 100644 --- a/src/GPS/GPSRtk.cc +++ b/src/GPS/GPSRtk.cc @@ -10,7 +10,6 @@ #include "GPSRtk.h" #include "GPSProvider.h" #include "GPSRTKFactGroup.h" -#include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "RTCMMavlink.h" #include "RTKSettings.h" @@ -76,7 +75,7 @@ void GPSRtk::connectGPS(const QString &device, QStringView gps_type) disconnectGPS(); - RTKSettings* const rtkSettings = qgcApp()->toolbox()->settingsManager()->rtkSettings(); + RTKSettings* const rtkSettings = SettingsManager::instance()->rtkSettings(); _requestGpsStop = false; const GPSProvider::rtk_data_s rtkData = { rtkSettings->surveyInAccuracyLimit()->rawValue().toDouble(), diff --git a/src/GPS/RTCMMavlink.cc b/src/GPS/RTCMMavlink.cc index e73d8de1153..bd34cfeb7e5 100644 --- a/src/GPS/RTCMMavlink.cc +++ b/src/GPS/RTCMMavlink.cc @@ -10,7 +10,6 @@ #include "RTCMMavlink.h" #include "MAVLinkProtocol.h" #include "MultiVehicleManager.h" -#include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "Vehicle.h" diff --git a/src/Gimbal/CMakeLists.txt b/src/Gimbal/CMakeLists.txt index 4c258639e32..33e494933a7 100644 --- a/src/Gimbal/CMakeLists.txt +++ b/src/Gimbal/CMakeLists.txt @@ -8,7 +8,6 @@ qt_add_library(Gimbal STATIC target_link_libraries(Gimbal PRIVATE Comms - QGC Settings Utilities Vehicle diff --git a/src/Gimbal/GimbalController.cc b/src/Gimbal/GimbalController.cc index 744a866f821..971bd98fccb 100644 --- a/src/Gimbal/GimbalController.cc +++ b/src/Gimbal/GimbalController.cc @@ -9,8 +9,8 @@ #include "GimbalController.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "GimbalControllerSettings.h" #include "QGCLoggingCategory.h" #include "ParameterManager.h" #include "MAVLinkProtocol.h" @@ -460,7 +460,7 @@ void GimbalController::gimbalPitchStart(int direction) return; } - float speed = qgcApp()->toolbox()->settingsManager()->gimbalControllerSettings()->joystickButtonsSpeed()->rawValue().toInt(); + float speed = SettingsManager::instance()->gimbalControllerSettings()->joystickButtonsSpeed()->rawValue().toInt(); activeGimbal()->setPitchRate(direction * speed); sendRate(); @@ -473,7 +473,7 @@ void GimbalController::gimbalYawStart(int direction) return; } - float speed = qgcApp()->toolbox()->settingsManager()->gimbalControllerSettings()->joystickButtonsSpeed()->rawValue().toInt(); + float speed = SettingsManager::instance()->gimbalControllerSettings()->joystickButtonsSpeed()->rawValue().toInt(); activeGimbal()->setYawRate(direction * speed); sendRate(); } @@ -518,8 +518,8 @@ void GimbalController::gimbalOnScreenControl(float panPct, float tiltPct, bool c } // click and point, based on FOV if (clickAndPoint) { - float hFov = qgcApp()->toolbox()->settingsManager()->gimbalControllerSettings()->CameraHFov()->rawValue().toFloat(); - float vFov = qgcApp()->toolbox()->settingsManager()->gimbalControllerSettings()->CameraVFov()->rawValue().toFloat(); + float hFov = SettingsManager::instance()->gimbalControllerSettings()->CameraHFov()->rawValue().toFloat(); + float vFov = SettingsManager::instance()->gimbalControllerSettings()->CameraVFov()->rawValue().toFloat(); float panIncDesired = panPct * hFov * 0.5f; float tiltIncDesired = tiltPct * vFov * 0.5f; @@ -538,7 +538,7 @@ void GimbalController::gimbalOnScreenControl(float panPct, float tiltPct, bool c // Should send rate commands, but it seems for some reason it is not working on AP side. // Pitch works ok but yaw doesn't stop, it keeps like inertia, like if it was buffering the messages. // So we do a workaround with angle targets - float maxSpeed = qgcApp()->toolbox()->settingsManager()->gimbalControllerSettings()->CameraSlideSpeed()->rawValue().toFloat(); + float maxSpeed = SettingsManager::instance()->gimbalControllerSettings()->CameraSlideSpeed()->rawValue().toFloat(); float panIncDesired = panPct * maxSpeed * 0.1f; float tiltIncDesired = tiltPct * maxSpeed * 0.1f; diff --git a/src/Joystick/CMakeLists.txt b/src/Joystick/CMakeLists.txt index 4a7793783c9..a4dc216c71d 100644 --- a/src/Joystick/CMakeLists.txt +++ b/src/Joystick/CMakeLists.txt @@ -12,7 +12,6 @@ target_link_libraries(Joystick Qt6::Qml FirmwarePlugin Gimbal - QGC Settings Utilities Vehicle diff --git a/src/Joystick/Joystick.cc b/src/Joystick/Joystick.cc index 7908e3b5687..29a052414a6 100644 --- a/src/Joystick/Joystick.cc +++ b/src/Joystick/Joystick.cc @@ -9,8 +9,6 @@ #include "Joystick.h" -#include "QGC.h" -#include "QGCApplication.h" #include "CustomAction.h" #include "SettingsManager.h" #include "CustomMavlinkActionsSettings.h" @@ -22,6 +20,7 @@ #include "QmlObjectListModel.h" #include +#include // JoystickLog Category declaration moved to QGCLoggingCategory.cc to allow access in Vehicle QGC_LOGGING_CATEGORY(JoystickValuesLog, "JoystickValuesLog") @@ -48,7 +47,7 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC , _hatCount (hatCount) , _hatButtonCount (4 * hatCount) , _totalButtonCount (_buttonCount+_hatButtonCount) - , _customActionManager (qgcApp()->toolbox()->settingsManager()->customMavlinkActionsSettings()->joystickActionsFile()) + , _customActionManager (SettingsManager::instance()->customMavlinkActionsSettings()->joystickActionsFile()) { // qCDebug(JoystickLog) << Q_FUNC_INFO << this; @@ -451,7 +450,7 @@ void Joystick::run() if (axisCount() != 0) { _handleAxis(); } - QGC::SLEEP::msleep(qMin(static_cast(1000.0f / _maxAxisFrequencyHz), static_cast(1000.0f / _maxButtonFrequencyHz)) / 2); + QThread::msleep(qMin(static_cast(1000.0f / _maxAxisFrequencyHz), static_cast(1000.0f / _maxButtonFrequencyHz)) / 2); } _close(); } diff --git a/src/Joystick/JoystickManager.cc b/src/Joystick/JoystickManager.cc index 5fcf800f77d..a003c1d69e1 100644 --- a/src/Joystick/JoystickManager.cc +++ b/src/Joystick/JoystickManager.cc @@ -14,7 +14,6 @@ #elif defined(Q_OS_ANDROID) #include "JoystickAndroid.h" #endif -#include "QGCApplication.h" #include "MultiVehicleManager.h" #include "QGCLoggingCategory.h" diff --git a/src/MissionManager/ComplexMissionItem.cc b/src/MissionManager/ComplexMissionItem.cc index 477b04c7cdf..82cb3f90c23 100644 --- a/src/MissionManager/ComplexMissionItem.cc +++ b/src/MissionManager/ComplexMissionItem.cc @@ -23,8 +23,6 @@ ComplexMissionItem::ComplexMissionItem(PlanMasterController* masterController, bool flyView) : VisualMissionItem (masterController, flyView) - , _toolbox (qgcApp()->toolbox()) - , _settingsManager (_toolbox->settingsManager()) { connect(_missionController, &MissionController::plannedHomePositionChanged, this, &ComplexMissionItem::_amslEntryAltChanged); connect(_missionController, &MissionController::plannedHomePositionChanged, this, &ComplexMissionItem::_amslExitAltChanged); @@ -86,7 +84,7 @@ void ComplexMissionItem::_savePresetJson(const QString& name, QJsonObject& prese // Use this to save a survey preset as a JSON file to be included in the build // as a built-in survey preset that cannot be deleted. #if 0 - QString savePath = _settingsManager->appSettings()->missionSavePath(); + QString savePath = SettingsManager::instance()->appSettings()->missionSavePath(); QDir saveDir(savePath); QString fileName = saveDir.absoluteFilePath(name); diff --git a/src/MissionManager/ComplexMissionItem.h b/src/MissionManager/ComplexMissionItem.h index 41220380abd..839dfefb659 100644 --- a/src/MissionManager/ComplexMissionItem.h +++ b/src/MissionManager/ComplexMissionItem.h @@ -16,8 +16,6 @@ class PlanMasterController; class MissionController; class KMLPlanDomDocument; -class SettingsManager; -class QGCToolbox; class ComplexMissionItem : public VisualMissionItem { @@ -123,8 +121,5 @@ protected slots: QMap _metaDataMap; - QGCToolbox* _toolbox; - SettingsManager* _settingsManager; - static constexpr const char* _presetSettingsKey = "_presets"; }; diff --git a/src/MissionManager/CorridorScanComplexItem.cc b/src/MissionManager/CorridorScanComplexItem.cc index e2576a76a93..3010beb671f 100644 --- a/src/MissionManager/CorridorScanComplexItem.cc +++ b/src/MissionManager/CorridorScanComplexItem.cc @@ -31,7 +31,7 @@ CorridorScanComplexItem::CorridorScanComplexItem(PlanMasterController* masterCon // We override the altitude to the mission default if (_cameraCalc.isManualCamera() || !_cameraCalc.valueSetIsDistance()->rawValue().toBool()) { - _cameraCalc.distanceToSurface()->setRawValue(qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue()); + _cameraCalc.distanceToSurface()->setRawValue(SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue()); } connect(&_corridorWidthFact, &Fact::valueChanged, this, &CorridorScanComplexItem::_setDirty); diff --git a/src/MissionManager/GeoFenceController.cc b/src/MissionManager/GeoFenceController.cc index 954760852fa..112252bfaeb 100644 --- a/src/MissionManager/GeoFenceController.cc +++ b/src/MissionManager/GeoFenceController.cc @@ -13,7 +13,6 @@ #include "GeoFenceController.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "ParameterManager.h" #include "JsonHelper.h" #include "PlanMasterController.h" @@ -36,7 +35,7 @@ GeoFenceController::GeoFenceController(PlanMasterController* masterController, Q , _managerVehicle (masterController->managerVehicle()) , _geoFenceManager (masterController->managerVehicle()->geoFenceManager()) , _breachReturnAltitudeFact (0, _breachReturnAltitudeFactName, FactMetaData::valueTypeDouble) - , _breachReturnDefaultAltitude (qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble()) + , _breachReturnDefaultAltitude (SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble()) { if (_metaDataMap.isEmpty()) { _metaDataMap = FactMetaData::createMapFromJsonFile(QStringLiteral(":/json/BreachReturn.FactMetaData.json"), nullptr /* metaDataParent */); diff --git a/src/MissionManager/MissionController.cc b/src/MissionManager/MissionController.cc index 8754f4abd01..8c113dd3bd1 100644 --- a/src/MissionManager/MissionController.cc +++ b/src/MissionManager/MissionController.cc @@ -46,8 +46,8 @@ MissionController::MissionController(PlanMasterController* masterController, QOb , _managerVehicle (masterController->managerVehicle()) , _missionManager (masterController->managerVehicle()->missionManager()) , _visualItems (new QmlObjectListModel(this)) - , _planViewSettings (qgcApp()->toolbox()->settingsManager()->planViewSettings()) - , _appSettings (qgcApp()->toolbox()->settingsManager()->appSettings()) + , _planViewSettings (SettingsManager::instance()->planViewSettings()) + , _appSettings (SettingsManager::instance()->appSettings()) { _resetMissionFlightStatus(); @@ -97,7 +97,7 @@ void MissionController::_resetMissionFlightStatus(void) _controllerVehicle->firmwarePlugin()->batteryConsumptionData(_controllerVehicle, _missionFlightStatus.mAhBattery, _missionFlightStatus.hoverAmps, _missionFlightStatus.cruiseAmps); if (_missionFlightStatus.mAhBattery != 0) { - double batteryPercentRemainingAnnounce = qgcApp()->toolbox()->settingsManager()->appSettings()->batteryPercentRemainingAnnounce()->rawValue().toDouble(); + double batteryPercentRemainingAnnounce = SettingsManager::instance()->appSettings()->batteryPercentRemainingAnnounce()->rawValue().toDouble(); _missionFlightStatus.ampMinutesAvailable = static_cast(_missionFlightStatus.mAhBattery) / 1000.0 * 60.0 * ((100.0 - batteryPercentRemainingAnnounce) / 100.0); } @@ -725,7 +725,7 @@ bool MissionController::_loadJsonMissionFileV2(const QJsonObject& json, QmlObjec qCDebug(MissionControllerLog) << "MissionController::_loadJsonMissionFileV2 itemCount:" << json[_jsonItemsKey].toArray().count(); - AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings* appSettings = SettingsManager::instance()->appSettings(); // Get the firmware/vehicle type from the plan file MAV_AUTOPILOT planFileFirmwareType = static_cast(json[_jsonFirmwareTypeKey].toInt()); diff --git a/src/MissionManager/PlanMasterController.cc b/src/MissionManager/PlanMasterController.cc index 523125d4723..00fdc48228a 100644 --- a/src/MissionManager/PlanMasterController.cc +++ b/src/MissionManager/PlanMasterController.cc @@ -129,7 +129,7 @@ void PlanMasterController::_activeVehicleChanged(Vehicle* activeVehicle) _managerVehicle = activeVehicle; // Update controllerVehicle to the currently connected vehicle - AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings* appSettings = SettingsManager::instance()->appSettings(); appSettings->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(_managerVehicle->firmwareType())); appSettings->offlineEditingVehicleClass()->setRawValue(QGCMAVLink::vehicleClass(_managerVehicle->vehicleType())); diff --git a/src/MissionManager/RallyPointController.cc b/src/MissionManager/RallyPointController.cc index 24acd87bffb..98cb84bbdd7 100644 --- a/src/MissionManager/RallyPointController.cc +++ b/src/MissionManager/RallyPointController.cc @@ -10,7 +10,6 @@ #include "RallyPointController.h" #include "RallyPoint.h" #include "Vehicle.h" -#include "QGCApplication.h" #include "JsonHelper.h" #include "SettingsManager.h" #include "AppSettings.h" @@ -240,7 +239,7 @@ void RallyPointController::addPoint(QGeoCoordinate point) defaultAlt = qobject_cast(_points[_points.count() - 1])->coordinate().altitude(); } else { if(_masterController->controllerVehicle()->fixedWing()) { - defaultAlt = qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble(); + defaultAlt = SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble(); } else { defaultAlt = RallyPoint::getDefaultFactAltitude(); diff --git a/src/MissionManager/SimpleMissionItem.cc b/src/MissionManager/SimpleMissionItem.cc index 3ca110fa9c0..b77f35f33e5 100644 --- a/src/MissionManager/SimpleMissionItem.cc +++ b/src/MissionManager/SimpleMissionItem.cc @@ -8,12 +8,12 @@ ****************************************************************************/ #include "SimpleMissionItem.h" -#include "QGCApplication.h" #include "JsonHelper.h" #include "MissionCommandTree.h" #include "MissionCommandUIInfo.h" #include "QGroundControlQmlGlobal.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "PlanMasterController.h" #include "SpeedSection.h" #include "MultiVehicleManager.h" @@ -767,7 +767,7 @@ void SimpleMissionItem::_setDefaultsForCommand(void) emit altitudeModeChanged(); _amslAltAboveTerrainFact.setRawValue(qQNaN()); if (specifiesAltitude()) { - double defaultAlt = qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble(); + double defaultAlt = SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble(); _altitudeFact.setRawValue(defaultAlt); _missionItem._param7Fact.setRawValue(defaultAlt); // Note that setAltitudeMode will also set MAV_FRAME correctly through signalling diff --git a/src/MissionManager/StructureScanComplexItem.cc b/src/MissionManager/StructureScanComplexItem.cc index 5e38cb50645..fc843abd482 100644 --- a/src/MissionManager/StructureScanComplexItem.cc +++ b/src/MissionManager/StructureScanComplexItem.cc @@ -42,7 +42,7 @@ StructureScanComplexItem::StructureScanComplexItem(PlanMasterController* masterC { _editorQml = "qrc:/qml/StructureScanEditor.qml"; - _entranceAltFact.setRawValue(qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue()); + _entranceAltFact.setRawValue(SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue()); connect(&_entranceAltFact, &Fact::valueChanged, this, &StructureScanComplexItem::_setDirty); connect(&_scanBottomAltFact, &Fact::valueChanged, this, &StructureScanComplexItem::_setDirty); diff --git a/src/MissionManager/SurveyComplexItem.cc b/src/MissionManager/SurveyComplexItem.cc index 3270617fc8e..5710dd02766 100644 --- a/src/MissionManager/SurveyComplexItem.cc +++ b/src/MissionManager/SurveyComplexItem.cc @@ -45,7 +45,7 @@ SurveyComplexItem::SurveyComplexItem(PlanMasterController* masterController, boo // We override the altitude to the mission default if (_cameraCalc.isManualCamera() || !_cameraCalc.valueSetIsDistance()->rawValue().toBool()) { - _cameraCalc.distanceToSurface()->setRawValue(qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue()); + _cameraCalc.distanceToSurface()->setRawValue(SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue()); } connect(&_gridAngleFact, &Fact::valueChanged, this, &SurveyComplexItem::_setDirty); diff --git a/src/MissionManager/TakeoffMissionItem.cc b/src/MissionManager/TakeoffMissionItem.cc index 314b5088194..4f2a38b60c1 100644 --- a/src/MissionManager/TakeoffMissionItem.cc +++ b/src/MissionManager/TakeoffMissionItem.cc @@ -8,10 +8,10 @@ ****************************************************************************/ #include "TakeoffMissionItem.h" -#include "QGCApplication.h" #include "MissionCommandTree.h" #include "QGroundControlQmlGlobal.h" #include "SettingsManager.h" +#include "PlanViewSettings.h" #include "PlanMasterController.h" #include "MissionSettingsItem.h" #include "MultiVehicleManager.h" @@ -172,7 +172,7 @@ void TakeoffMissionItem::setLaunchCoordinate(const QGeoCoordinate& launchCoordin if (_launchTakeoffAtSameLocation) { takeoffCoordinate = launchCoordinate; } else { - double distance = qgcApp()->toolbox()->settingsManager()->planViewSettings()->vtolTransitionDistance()->rawValue().toDouble(); // Default distance is VTOL transition to takeoff point distance + double distance = SettingsManager::instance()->planViewSettings()->vtolTransitionDistance()->rawValue().toDouble(); // Default distance is VTOL transition to takeoff point distance if (_controllerVehicle->fixedWing()) { double altitude = this->altitude()->rawValue().toDouble(); diff --git a/src/MissionManager/VTOLLandingComplexItem.cc b/src/MissionManager/VTOLLandingComplexItem.cc index 94f1101212a..d6f2c9d7784 100644 --- a/src/MissionManager/VTOLLandingComplexItem.cc +++ b/src/MissionManager/VTOLLandingComplexItem.cc @@ -8,13 +8,13 @@ ****************************************************************************/ #include "VTOLLandingComplexItem.h" -#include "QGCApplication.h" #include "JsonHelper.h" #include "MissionController.h" #include "PlanMasterController.h" #include "FlightPathSegment.h" #include "MissionItem.h" #include "SettingsManager.h" +#include "PlanViewSettings.h" #include "QGC.h" #include "QGCLoggingCategory.h" @@ -44,7 +44,7 @@ VTOLLandingComplexItem::VTOLLandingComplexItem(PlanMasterController* masterContr // We adjust landing distance meta data to Plan View settings unless there was a custom build override if (QGC::fuzzyCompare(_landingDistanceFact.rawValue().toDouble(), _landingDistanceFact.rawDefaultValue().toDouble())) { - Fact* vtolTransitionDistanceFact = qgcApp()->toolbox()->settingsManager()->planViewSettings()->vtolTransitionDistance(); + Fact* vtolTransitionDistanceFact = SettingsManager::instance()->planViewSettings()->vtolTransitionDistance(); double vtolTransitionDistance = vtolTransitionDistanceFact->rawValue().toDouble(); _landingDistanceFact.metaData()->setRawDefaultValue(vtolTransitionDistance); _landingDistanceFact.setRawValue(vtolTransitionDistance); diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index b5d5477c399..2369bcf97fd 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -57,6 +57,7 @@ #include "QGCLoggingCategory.h" #include "QGroundControlQmlGlobal.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "ShapeFileHelper.h" #include "SyslinkComponentController.h" #include "UDPLink.h" @@ -264,6 +265,8 @@ QGCApplication::~QGCApplication() void QGCApplication::init() { + SettingsManager::instance()->init(); + // Register our Qml objects LinkManager::registerQmlTypes(); @@ -273,6 +276,8 @@ void QGCApplication::init() QGCCameraManager::registerQmlTypes(); MultiVehicleManager::registerQmlTypes(); QGCPositionManager::registerQmlTypes(); + SettingsManager::registerQmlTypes(); + VideoManager::registerQmlTypes(); #ifdef QGC_VIEWER3D Viewer3DManager::registerQmlTypes(); #endif @@ -334,7 +339,7 @@ void QGCApplication::_initForNormalAppBoot() QObject::connect(_qmlAppEngine, &QQmlApplicationEngine::objectCreationFailed, this, QCoreApplication::quit, Qt::QueuedConnection); _toolbox->corePlugin()->createRootWindow(_qmlAppEngine); - AudioOutput::instance()->init(_toolbox->settingsManager()->appSettings()->audioMuted()); + AudioOutput::instance()->init(SettingsManager::instance()->appSettings()->audioMuted()); FollowMe::instance()->init(); QGCPositionManager::instance()->init(); LinkManager::instance()->init(); diff --git a/src/QGCToolbox.cc b/src/QGCToolbox.cc index e89da6784dc..ce3dd100500 100644 --- a/src/QGCToolbox.cc +++ b/src/QGCToolbox.cc @@ -9,7 +9,6 @@ #include "QGCToolbox.h" #include "QGCCorePlugin.h" -#include "SettingsManager.h" #include "QGCApplication.h" #if defined(QGC_CUSTOM_BUILD) @@ -19,18 +18,12 @@ QGCToolbox::QGCToolbox(QGCApplication* app) : QObject(app) { - // SettingsManager must be first so settings are available to any subsequent tools - _settingsManager = new SettingsManager (app, this); - //-- Scan and load plugins _scanAndLoadPlugins(app); } void QGCToolbox::setChildToolboxes(void) { - // SettingsManager must be first so settings are available to any subsequent tools - _settingsManager->setToolbox(this); - _corePlugin->setToolbox(this); } diff --git a/src/QGCToolbox.h b/src/QGCToolbox.h index e13cdc37a8a..0f87104c19f 100644 --- a/src/QGCToolbox.h +++ b/src/QGCToolbox.h @@ -7,15 +7,12 @@ * ****************************************************************************/ - #pragma once - #include class QGCApplication; class QGCCorePlugin; -class SettingsManager; /// This is used to manage all of our top level services/tools class QGCToolbox : public QObject { @@ -25,14 +22,12 @@ class QGCToolbox : public QObject { QGCToolbox(QGCApplication* app); QGCCorePlugin* corePlugin () { return _corePlugin; } - SettingsManager* settingsManager () { return _settingsManager; } private: void setChildToolboxes(void); void _scanAndLoadPlugins(QGCApplication *app); QGCCorePlugin* _corePlugin = nullptr; - SettingsManager* _settingsManager = nullptr; friend class QGCApplication; }; diff --git a/src/QmlControls/AppMessages.cc b/src/QmlControls/AppMessages.cc index 6e31f96675d..753473731d6 100644 --- a/src/QmlControls/AppMessages.cc +++ b/src/QmlControls/AppMessages.cc @@ -96,17 +96,13 @@ void AppLogModel::threadsafeLog(const QString message) if (qgcApp() && qgcApp()->logOutput() && _logFile.fileName().isEmpty()) { qDebug() << _logFile.fileName().isEmpty() << qgcApp()->logOutput(); - QGCToolbox* toolbox = qgcApp()->toolbox(); - // Be careful of toolbox not being open yet - if (toolbox) { - QString saveDirPath = qgcApp()->toolbox()->settingsManager()->appSettings()->crashSavePath(); - QDir saveDir(saveDirPath); - QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log")); - - _logFile.setFileName(saveFilePath); - if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) { - qgcApp()->showAppMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString())); - } + QString saveDirPath = SettingsManager::instance()->appSettings()->crashSavePath(); + QDir saveDir(saveDirPath); + QString saveFilePath = saveDir.absoluteFilePath(QStringLiteral("QGCConsole.log")); + + _logFile.setFileName(saveFilePath); + if (!_logFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + qgcApp()->showAppMessage(tr("Open console log output file failed %1 : %2").arg(_logFile.fileName()).arg(_logFile.errorString())); } } diff --git a/src/QmlControls/CustomActionManager.cc b/src/QmlControls/CustomActionManager.cc index 654afe6da80..38933a24651 100644 --- a/src/QmlControls/CustomActionManager.cc +++ b/src/QmlControls/CustomActionManager.cc @@ -13,6 +13,7 @@ #include "JsonHelper.h" #include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "QGCLoggingCategory.h" #include "QmlObjectListModel.h" @@ -59,7 +60,7 @@ void CustomActionManager::_loadActionsFile() } // Custom actions are always loaded from the custom actions save path - const QString savePath = qgcApp()->toolbox()->settingsManager()->appSettings()->customActionsSavePath(); + const QString savePath = SettingsManager::instance()->appSettings()->customActionsSavePath(); const QDir saveDir = QDir(savePath); const QString fullPath = saveDir.absoluteFilePath(actionFileName); diff --git a/src/QmlControls/QGCFileDialogController.cc b/src/QmlControls/QGCFileDialogController.cc index f52393537b6..c517ff93bec 100644 --- a/src/QmlControls/QGCFileDialogController.cc +++ b/src/QmlControls/QGCFileDialogController.cc @@ -10,8 +10,8 @@ #include "QGCFileDialogController.h" #include "QGCLoggingCategory.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" #include @@ -93,7 +93,7 @@ void QGCFileDialogController::deleteFile(const QString &filename) QString QGCFileDialogController::fullFolderPathToShortMobilePath(const QString &fullFolderPath) { #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) - const QString defaultSavePath = qgcApp()->toolbox()->settingsManager()->appSettings()->savePath()->rawValueString(); + const QString defaultSavePath = SettingsManager::instance()->appSettings()->savePath()->rawValueString(); if (fullFolderPath.startsWith(defaultSavePath)) { const int lastDirSepIndex = fullFolderPath.lastIndexOf(QStringLiteral("/")); return (QCoreApplication::applicationName() + QStringLiteral("/") + fullFolderPath.right(fullFolderPath.length() - lastDirSepIndex)); diff --git a/src/QmlControls/QGroundControlQmlGlobal.cc b/src/QmlControls/QGroundControlQmlGlobal.cc index 6f0a1e6d481..a2b6c5f75ea 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.cc +++ b/src/QmlControls/QGroundControlQmlGlobal.cc @@ -115,6 +115,7 @@ QGroundControlQmlGlobal::QGroundControlQmlGlobal(QGCApplication* app, QGCToolbox , _videoManager(VideoManager::instance()) , _linkManager(LinkManager::instance()) , _multiVehicleManager(MultiVehicleManager::instance()) + , _settingsManager(SettingsManager::instance()) #ifndef QGC_AIRLINK_DISABLED , _airlinkManager(AirLinkManager::instance()) #endif @@ -162,7 +163,6 @@ void QGroundControlQmlGlobal::setToolbox(QGCToolbox* toolbox) QGCTool::setToolbox(toolbox); _corePlugin = toolbox->corePlugin(); - _settingsManager = toolbox->settingsManager(); #ifndef NO_SERIAL_LINK _gpsRtkFactGroup = GPSManager::instance()->gpsRtk()->gpsRtkFactGroup(); #endif diff --git a/src/QmlControls/QGroundControlQmlGlobal.h b/src/QmlControls/QGroundControlQmlGlobal.h index 735735a63bc..42c834614ac 100644 --- a/src/QmlControls/QGroundControlQmlGlobal.h +++ b/src/QmlControls/QGroundControlQmlGlobal.h @@ -259,6 +259,7 @@ class QGroundControlQmlGlobal : public QGCTool VideoManager* _videoManager = nullptr; LinkManager* _linkManager = nullptr; MultiVehicleManager* _multiVehicleManager = nullptr; + SettingsManager* _settingsManager = nullptr; #ifndef QGC_AIRLINK_DISABLED AirLinkManager* _airlinkManager = nullptr; #endif @@ -268,7 +269,6 @@ class QGroundControlQmlGlobal : public QGCTool double _flightMapInitialZoom = 17.0; QGCCorePlugin* _corePlugin = nullptr; - SettingsManager* _settingsManager = nullptr; #ifndef NO_SERIAL_LINK FactGroup* _gpsRtkFactGroup = nullptr; #endif diff --git a/src/QmlControls/ScreenToolsController.cc b/src/QmlControls/ScreenToolsController.cc index ccc25c4c1d5..f3e0b24209e 100644 --- a/src/QmlControls/ScreenToolsController.cc +++ b/src/QmlControls/ScreenToolsController.cc @@ -15,6 +15,7 @@ #include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "SettingsManager.h" +#include "AppSettings.h" #include #include @@ -77,7 +78,7 @@ QString ScreenToolsController::fixedFontFamily() QString ScreenToolsController::normalFontFamily() { //-- See App.SettinsGroup.json for index - const int langID = qgcApp()->toolbox()->settingsManager()->appSettings()->qLocaleLanguage()->rawValue().toInt(); + const int langID = SettingsManager::instance()->appSettings()->qLocaleLanguage()->rawValue().toInt(); if (langID == QLocale::Korean) { return QStringLiteral("NanumGothic"); } diff --git a/src/QtLocationPlugin/Providers/EsriMapProvider.cpp b/src/QtLocationPlugin/Providers/EsriMapProvider.cpp index 0c2bc640ce2..91a9865c23b 100644 --- a/src/QtLocationPlugin/Providers/EsriMapProvider.cpp +++ b/src/QtLocationPlugin/Providers/EsriMapProvider.cpp @@ -8,12 +8,12 @@ ****************************************************************************/ #include "EsriMapProvider.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" QByteArray EsriMapProvider::getToken() const { - return qgcApp()->toolbox()->settingsManager()->appSettings()->esriToken()->rawValue().toString().toUtf8(); + return SettingsManager::instance()->appSettings()->esriToken()->rawValue().toString().toUtf8(); } QString EsriMapProvider::_getURL(int x, int y, int zoom) const diff --git a/src/QtLocationPlugin/Providers/GenericMapProvider.cpp b/src/QtLocationPlugin/Providers/GenericMapProvider.cpp index ea940dbcd04..426e5005a42 100644 --- a/src/QtLocationPlugin/Providers/GenericMapProvider.cpp +++ b/src/QtLocationPlugin/Providers/GenericMapProvider.cpp @@ -8,12 +8,12 @@ ****************************************************************************/ #include "GenericMapProvider.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" QString CustomURLMapProvider::_getURL(int x, int y, int zoom) const { - QString url = qgcApp()->toolbox()->settingsManager()->appSettings()->customURL()->rawValue().toString(); + QString url = SettingsManager::instance()->appSettings()->customURL()->rawValue().toString(); (void) url.replace("{x}", QString::number(x)); (void) url.replace("{y}", QString::number(y)); static const QRegularExpression zoomRegExp("\\{(z|zoom)\\}"); @@ -66,6 +66,6 @@ QString VWorldMapProvider::_getURL(int x, int y, int zoom) const return QString(); } - const QString VWorldMapToken = qgcApp()->toolbox()->settingsManager()->appSettings()->vworldToken()->rawValue().toString(); + const QString VWorldMapToken = SettingsManager::instance()->appSettings()->vworldToken()->rawValue().toString(); return _mapUrl.arg(VWorldMapToken, _mapName).arg(zoom).arg(y).arg(x).arg(_imageFormat); } diff --git a/src/QtLocationPlugin/Providers/MapboxMapProvider.cpp b/src/QtLocationPlugin/Providers/MapboxMapProvider.cpp index 5463d6a2470..e4d7506c5cd 100644 --- a/src/QtLocationPlugin/Providers/MapboxMapProvider.cpp +++ b/src/QtLocationPlugin/Providers/MapboxMapProvider.cpp @@ -8,17 +8,17 @@ ****************************************************************************/ #include "MapboxMapProvider.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" QString MapboxMapProvider::_getURL(int x, int y, int zoom) const { - const QString mapBoxToken = qgcApp()->toolbox()->settingsManager()->appSettings()->mapboxToken()->rawValue().toString(); + const QString mapBoxToken = SettingsManager::instance()->appSettings()->mapboxToken()->rawValue().toString(); if (!mapBoxToken.isEmpty()) { if (_mapTypeId == QStringLiteral("mapbox.custom")) { static const QString MapBoxUrlCustom = QStringLiteral("https://api.mapbox.com/styles/v1/%1/%2/tiles/256/%3/%4/%5?access_token=%6"); - const QString mapBoxAccount = qgcApp()->toolbox()->settingsManager()->appSettings()->mapboxAccount()->rawValue().toString(); - const QString mapBoxStyle = qgcApp()->toolbox()->settingsManager()->appSettings()->mapboxStyle()->rawValue().toString(); + const QString mapBoxAccount = SettingsManager::instance()->appSettings()->mapboxAccount()->rawValue().toString(); + const QString mapBoxStyle = SettingsManager::instance()->appSettings()->mapboxStyle()->rawValue().toString(); return MapBoxUrlCustom.arg(mapBoxAccount).arg(mapBoxStyle).arg(zoom).arg(x).arg(y).arg(mapBoxToken); } diff --git a/src/QtLocationPlugin/QGeoFileTileCacheQGC.cpp b/src/QtLocationPlugin/QGeoFileTileCacheQGC.cpp index 35124019617..4a68dabaf45 100644 --- a/src/QtLocationPlugin/QGeoFileTileCacheQGC.cpp +++ b/src/QtLocationPlugin/QGeoFileTileCacheQGC.cpp @@ -10,8 +10,8 @@ #include "QGeoFileTileCacheQGC.h" #include "QGCMapEngine.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "MapsSettings.h" #include "QGCMapUrlEngine.h" #include "QGCMapTasks.h" @@ -89,12 +89,12 @@ uint32_t QGeoFileTileCacheQGC::_getMemLimit(const QVariantMap ¶meters) quint32 QGeoFileTileCacheQGC::_getMaxMemCacheSetting() { - return qgcApp()->toolbox()->settingsManager()->mapsSettings()->maxCacheMemorySize()->rawValue().toUInt(); + return SettingsManager::instance()->mapsSettings()->maxCacheMemorySize()->rawValue().toUInt(); } quint32 QGeoFileTileCacheQGC::getMaxDiskCacheSetting() { - return qgcApp()->toolbox()->settingsManager()->mapsSettings()->maxCacheDiskSize()->rawValue().toUInt(); + return SettingsManager::instance()->mapsSettings()->maxCacheDiskSize()->rawValue().toUInt(); } void QGeoFileTileCacheQGC::cacheTile(const QString &type, int x, int y, int z, const QByteArray &image, const QString &format, qulonglong set) @@ -105,7 +105,7 @@ void QGeoFileTileCacheQGC::cacheTile(const QString &type, int x, int y, int z, c void QGeoFileTileCacheQGC::cacheTile(const QString &type, const QString &hash, const QByteArray &image, const QString &format, qulonglong set) { - AppSettings* const appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings* const appSettings = SettingsManager::instance()->appSettings(); if (!appSettings->disableAllPersistence()->rawValue().toBool()) { QGCCacheTile* const tile = new QGCCacheTile(hash, image, format, type, set); QGCSaveTileTask* const task = new QGCSaveTileTask(tile); diff --git a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc index 116d415d170..9a1f2fc5a41 100644 --- a/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc +++ b/src/QtLocationPlugin/QMLControl/QGCMapEngineManager.cc @@ -19,8 +19,8 @@ #include "ElevationMapProvider.h" #include "QmlObjectListModel.h" #include "QGCApplication.h" -#include "QGCToolbox.h" #include "SettingsManager.h" +#include "FlightMapSettings.h" #include "QGCLoggingCategory.h" #include @@ -74,7 +74,7 @@ void QGCMapEngineManager::updateForCurrentView(double lon0, double lat0, double } if (_fetchElevation) { - const QString elevationProviderName = qgcApp()->toolbox()->settingsManager()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); + const QString elevationProviderName = SettingsManager::instance()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); const QGCTileSet set = UrlFactory::getTileCount(1, lon0, lat0, lon1, lat1, elevationProviderName); _elevationSet += set; } @@ -145,7 +145,7 @@ void QGCMapEngineManager::startDownload(const QString &name, const QString &mapT const int mapid = UrlFactory::getQtMapIdFromProviderType(mapType); if (_fetchElevation && !UrlFactory::isElevation(mapid)) { QGCCachedTileSet* const set = new QGCCachedTileSet(name + QStringLiteral(" Elevation")); - const QString elevationProviderName = qgcApp()->toolbox()->settingsManager()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); + const QString elevationProviderName = SettingsManager::instance()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); set->setMapTypeStr(elevationProviderName); set->setTopleftLat(_topleftLat); set->setTopleftLon(_topleftLon); diff --git a/src/Settings/CMakeLists.txt b/src/Settings/CMakeLists.txt index 3a9b440c2c2..8ac08cc85f7 100644 --- a/src/Settings/CMakeLists.txt +++ b/src/Settings/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt6 REQUIRED COMPONENTS Core Multimedia Qml) +find_package(Qt6 REQUIRED COMPONENTS Core Multimedia Qml QmlIntegration) qt_add_library(Settings STATIC ADSBVehicleManagerSettings.cc @@ -52,6 +52,7 @@ target_link_libraries(Settings Qt6::Multimedia API GStreamerReceiver + QGC QmlControls Vehicle VideoManager @@ -59,9 +60,9 @@ target_link_libraries(Settings PUBLIC Qt6::Core Qt6::Qml + Qt6::QmlIntegration Comms FactSystem - QGC ) target_include_directories(Settings PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/Settings/SettingsManager.cc b/src/Settings/SettingsManager.cc index 0d39c5aeef0..c74f47925b3 100644 --- a/src/Settings/SettingsManager.cc +++ b/src/Settings/SettingsManager.cc @@ -8,63 +8,110 @@ ****************************************************************************/ #include "SettingsManager.h" +#include "QGCLoggingCategory.h" +#include "ADSBVehicleManagerSettings.h" +#ifndef NO_ARDUPILOT_DIALECT +#include "APMMavlinkStreamRateSettings.h" +#endif +#include "AppSettings.h" +#include "AutoConnectSettings.h" +#include "BatteryIndicatorSettings.h" +#include "BrandImageSettings.h" +#include "CustomMavlinkActionsSettings.h" +#include "FirmwareUpgradeSettings.h" +#include "FlightMapSettings.h" +#include "FlightModeSettings.h" +#include "FlyViewSettings.h" +#include "GimbalControllerSettings.h" +#include "MapsSettings.h" +#include "OfflineMapsSettings.h" +#include "PlanViewSettings.h" +#include "RemoteIDSettings.h" +#include "RTKSettings.h" +#include "UnitsSettings.h" +#include "VideoSettings.h" +#ifdef QGC_VIEWER3D +#include "Viewer3DSettings.h" +#endif -#include +#include +#include -SettingsManager::SettingsManager(QGCApplication* app, QGCToolbox* toolbox) - : QGCTool(app, toolbox) - , _appSettings (nullptr) - , _unitsSettings (nullptr) - , _autoConnectSettings (nullptr) - , _videoSettings (nullptr) - , _flightMapSettings (nullptr) - , _flightModeSettings (nullptr) - , _rtkSettings (nullptr) - , _flyViewSettings (nullptr) - , _planViewSettings (nullptr) - , _brandImageSettings (nullptr) - , _offlineMapsSettings (nullptr) - , _firmwareUpgradeSettings (nullptr) - , _adsbVehicleManagerSettings (nullptr) - , _batteryIndicatorSettings (nullptr) - , _mapsSettings (nullptr) - , _viewer3DSettings (nullptr) - , _gimbalControllerSettings (nullptr) -#if !defined(NO_ARDUPILOT_DIALECT) - , _apmMavlinkStreamRateSettings (nullptr) -#endif - , _remoteIDSettings (nullptr) - , _customMavlinkActionsSettings (nullptr) +QGC_LOGGING_CATEGORY(SettingsManagerLog, "qgc.settings.settingsmanager") + +Q_APPLICATION_STATIC(SettingsManager, _settingsManagerInstance); + +SettingsManager::SettingsManager(QObject *parent) + : QObject(parent) { + // qCDebug(SettingsManagerLog) << Q_FUNC_INFO << this; +} +SettingsManager::~SettingsManager() +{ + // qCDebug(SettingsManagerLog) << Q_FUNC_INFO << this; } -void SettingsManager::setToolbox(QGCToolbox *toolbox) +SettingsManager *SettingsManager::instance() { - QGCTool::setToolbox(toolbox); - QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); - qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "SettingsManager", "Reference only"); + return _settingsManagerInstance(); +} - _unitsSettings = new UnitsSettings (this); // Must be first since AppSettings references it - _appSettings = new AppSettings (this); - _autoConnectSettings = new AutoConnectSettings (this); - _videoSettings = new VideoSettings (this); - _flightMapSettings = new FlightMapSettings (this); - _flightModeSettings = new FlightModeSettings (this); - _rtkSettings = new RTKSettings (this); - _flyViewSettings = new FlyViewSettings (this); - _planViewSettings = new PlanViewSettings (this); - _brandImageSettings = new BrandImageSettings (this); - _offlineMapsSettings = new OfflineMapsSettings (this); - _firmwareUpgradeSettings = new FirmwareUpgradeSettings (this); - _adsbVehicleManagerSettings = new ADSBVehicleManagerSettings (this); - _batteryIndicatorSettings = new BatteryIndicatorSettings (this); - _mapsSettings = new MapsSettings (this); - _viewer3DSettings = new Viewer3DSettings (this); - _gimbalControllerSettings = new GimbalControllerSettings (this); -#if !defined(NO_ARDUPILOT_DIALECT) +void SettingsManager::registerQmlTypes() +{ + (void) qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "SettingsManager", "Reference only"); +} + +void SettingsManager::init() +{ + _unitsSettings = new UnitsSettings(this); // Must be first since AppSettings references it + + _adsbVehicleManagerSettings = new ADSBVehicleManagerSettings(this); +#ifndef NO_ARDUPILOT_DIALECT _apmMavlinkStreamRateSettings = new APMMavlinkStreamRateSettings(this); #endif - _remoteIDSettings = new RemoteIDSettings (this); + _appSettings = new AppSettings(this); + _autoConnectSettings = new AutoConnectSettings(this); + _batteryIndicatorSettings = new BatteryIndicatorSettings(this); + _brandImageSettings = new BrandImageSettings(this); _customMavlinkActionsSettings = new CustomMavlinkActionsSettings(this); + _firmwareUpgradeSettings = new FirmwareUpgradeSettings(this); + _flightMapSettings = new FlightMapSettings(this); + _flightModeSettings = new FlightModeSettings(this); + _flyViewSettings = new FlyViewSettings(this); + _gimbalControllerSettings = new GimbalControllerSettings(this); + _mapsSettings = new MapsSettings(this); + _offlineMapsSettings = new OfflineMapsSettings(this); + _planViewSettings = new PlanViewSettings(this); + _remoteIDSettings = new RemoteIDSettings(this); + _rtkSettings = new RTKSettings(this); + _videoSettings = new VideoSettings(this); +#ifdef QGC_VIEWER3D + _viewer3DSettings = new Viewer3DSettings(this); +#endif } + +ADSBVehicleManagerSettings *SettingsManager::adsbVehicleManagerSettings() const { return _adsbVehicleManagerSettings; } +#ifndef NO_ARDUPILOT_DIALECT +APMMavlinkStreamRateSettings *SettingsManager::apmMavlinkStreamRateSettings() const { return _apmMavlinkStreamRateSettings; } +#endif +AppSettings *SettingsManager::appSettings() const { return _appSettings; } +AutoConnectSettings *SettingsManager::autoConnectSettings() const { return _autoConnectSettings; } +BatteryIndicatorSettings *SettingsManager::batteryIndicatorSettings() const { return _batteryIndicatorSettings; } +BrandImageSettings *SettingsManager::brandImageSettings() const { return _brandImageSettings; } +CustomMavlinkActionsSettings *SettingsManager::customMavlinkActionsSettings() const { return _customMavlinkActionsSettings; } +FirmwareUpgradeSettings *SettingsManager::firmwareUpgradeSettings() const { return _firmwareUpgradeSettings; } +FlightMapSettings *SettingsManager::flightMapSettings() const { return _flightMapSettings; } +FlightModeSettings *SettingsManager::flightModeSettings() const { return _flightModeSettings; } +FlyViewSettings *SettingsManager::flyViewSettings() const { return _flyViewSettings; } +GimbalControllerSettings *SettingsManager::gimbalControllerSettings() const { return _gimbalControllerSettings; } +MapsSettings *SettingsManager::mapsSettings() const { return _mapsSettings; } +OfflineMapsSettings *SettingsManager::offlineMapsSettings() const { return _offlineMapsSettings; } +PlanViewSettings *SettingsManager::planViewSettings() const { return _planViewSettings; } +RemoteIDSettings *SettingsManager::remoteIDSettings() const { return _remoteIDSettings; } +RTKSettings *SettingsManager::rtkSettings() const { return _rtkSettings; } +UnitsSettings *SettingsManager::unitsSettings() const { return _unitsSettings; } +VideoSettings *SettingsManager::videoSettings() const { return _videoSettings; } +#ifdef QGC_VIEWER3D +Viewer3DSettings *SettingsManager::viewer3DSettings() const { return _viewer3DSettings; } +#endif diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h index 090b439ec4c..dba1929d150 100644 --- a/src/Settings/SettingsManager.h +++ b/src/Settings/SettingsManager.h @@ -9,109 +9,144 @@ #pragma once -#include "QGCToolbox.h" -#include "AppSettings.h" -#include "UnitsSettings.h" -#include "AutoConnectSettings.h" -#include "VideoSettings.h" -#include "FlightMapSettings.h" -#include "FlightModeSettings.h" -#include "RTKSettings.h" -#include "FlyViewSettings.h" -#include "MapsSettings.h" -#include "PlanViewSettings.h" -#include "BrandImageSettings.h" -#include "OfflineMapsSettings.h" -#if !defined(NO_ARDUPILOT_DIALECT) -#include "APMMavlinkStreamRateSettings.h" -#endif -#include "FirmwareUpgradeSettings.h" -#include "ADSBVehicleManagerSettings.h" -#include "BatteryIndicatorSettings.h" -#include "GimbalControllerSettings.h" -#include "RemoteIDSettings.h" -#include "Viewer3DSettings.h" -#include "CustomMavlinkActionsSettings.h" +#include +#include +#include + +class ADSBVehicleManagerSettings; +class APMMavlinkStreamRateSettings; +class AppSettings; +class AutoConnectSettings; +class BatteryIndicatorSettings; +class BrandImageSettings; +class CustomMavlinkActionsSettings; +class FirmwareUpgradeSettings; +class FlightMapSettings; +class FlightModeSettings; +class FlyViewSettings; +class GimbalControllerSettings; +class MapsSettings; +class OfflineMapsSettings; +class PlanViewSettings; +class RemoteIDSettings; +class RTKSettings; +class UnitsSettings; +class VideoSettings; +class Viewer3DSettings; + +Q_DECLARE_LOGGING_CATEGORY(SettingsManagerLog) /// Provides access to all app settings -class SettingsManager : public QGCTool +class SettingsManager : public QObject { Q_OBJECT - -public: - SettingsManager(QGCApplication* app, QGCToolbox* toolbox); - - Q_PROPERTY(QObject* appSettings READ appSettings CONSTANT) - Q_PROPERTY(QObject* unitsSettings READ unitsSettings CONSTANT) - Q_PROPERTY(QObject* autoConnectSettings READ autoConnectSettings CONSTANT) - Q_PROPERTY(QObject* videoSettings READ videoSettings CONSTANT) - Q_PROPERTY(QObject* flightMapSettings READ flightMapSettings CONSTANT) - Q_PROPERTY(QObject* flightModeSettings READ flightModeSettings CONSTANT) - Q_PROPERTY(QObject* rtkSettings READ rtkSettings CONSTANT) - Q_PROPERTY(QObject* flyViewSettings READ flyViewSettings CONSTANT) - Q_PROPERTY(QObject* planViewSettings READ planViewSettings CONSTANT) - Q_PROPERTY(QObject* brandImageSettings READ brandImageSettings CONSTANT) - Q_PROPERTY(QObject* offlineMapsSettings READ offlineMapsSettings CONSTANT) - Q_PROPERTY(QObject* firmwareUpgradeSettings READ firmwareUpgradeSettings CONSTANT) - Q_PROPERTY(QObject* adsbVehicleManagerSettings READ adsbVehicleManagerSettings CONSTANT) - Q_PROPERTY(QObject* batteryIndicatorSettings READ batteryIndicatorSettings CONSTANT) - Q_PROPERTY(QObject* mapsSettings READ mapsSettings CONSTANT) - Q_PROPERTY(QObject* viewer3DSettings READ viewer3DSettings CONSTANT) - Q_PROPERTY(QObject* gimbalControllerSettings READ gimbalControllerSettings CONSTANT) -#if !defined(NO_ARDUPILOT_DIALECT) - Q_PROPERTY(QObject* apmMavlinkStreamRateSettings READ apmMavlinkStreamRateSettings CONSTANT) + QML_ELEMENT + QML_UNCREATABLE("") + Q_MOC_INCLUDE("ADSBVehicleManagerSettings.h") +#ifndef NO_ARDUPILOT_DIALECT + Q_MOC_INCLUDE("APMMavlinkStreamRateSettings.h") +#endif + Q_MOC_INCLUDE("AppSettings.h") + Q_MOC_INCLUDE("AutoConnectSettings.h") + Q_MOC_INCLUDE("BatteryIndicatorSettings.h") + Q_MOC_INCLUDE("BrandImageSettings.h") + Q_MOC_INCLUDE("CustomMavlinkActionsSettings.h") + Q_MOC_INCLUDE("FirmwareUpgradeSettings.h") + Q_MOC_INCLUDE("FlightMapSettings.h") + Q_MOC_INCLUDE("FlightModeSettings.h") + Q_MOC_INCLUDE("FlyViewSettings.h") + Q_MOC_INCLUDE("GimbalControllerSettings.h") + Q_MOC_INCLUDE("MapsSettings.h") + Q_MOC_INCLUDE("OfflineMapsSettings.h") + Q_MOC_INCLUDE("PlanViewSettings.h") + Q_MOC_INCLUDE("RemoteIDSettings.h") + Q_MOC_INCLUDE("RTKSettings.h") + Q_MOC_INCLUDE("UnitsSettings.h") + Q_MOC_INCLUDE("VideoSettings.h") +#ifdef QGC_VIEWER3D + Q_MOC_INCLUDE("Viewer3DSettings.h") #endif - Q_PROPERTY(QObject* remoteIDSettings READ remoteIDSettings CONSTANT) - Q_PROPERTY(QObject* customMavlinkActionsSettings READ customMavlinkActionsSettings CONSTANT) + Q_PROPERTY(QObject *adsbVehicleManagerSettings READ adsbVehicleManagerSettings CONSTANT) +#ifndef NO_ARDUPILOT_DIALECT + Q_PROPERTY(QObject *apmMavlinkStreamRateSettings READ apmMavlinkStreamRateSettings CONSTANT) +#endif + Q_PROPERTY(QObject *appSettings READ appSettings CONSTANT) + Q_PROPERTY(QObject *autoConnectSettings READ autoConnectSettings CONSTANT) + Q_PROPERTY(QObject *batteryIndicatorSettings READ batteryIndicatorSettings CONSTANT) + Q_PROPERTY(QObject *brandImageSettings READ brandImageSettings CONSTANT) + Q_PROPERTY(QObject *customMavlinkActionsSettings READ customMavlinkActionsSettings CONSTANT) + Q_PROPERTY(QObject *firmwareUpgradeSettings READ firmwareUpgradeSettings CONSTANT) + Q_PROPERTY(QObject *flightMapSettings READ flightMapSettings CONSTANT) + Q_PROPERTY(QObject *flightModeSettings READ flightModeSettings CONSTANT) + Q_PROPERTY(QObject *flyViewSettings READ flyViewSettings CONSTANT) + Q_PROPERTY(QObject *gimbalControllerSettings READ gimbalControllerSettings CONSTANT) + Q_PROPERTY(QObject *mapsSettings READ mapsSettings CONSTANT) + Q_PROPERTY(QObject *offlineMapsSettings READ offlineMapsSettings CONSTANT) + Q_PROPERTY(QObject *planViewSettings READ planViewSettings CONSTANT) + Q_PROPERTY(QObject *remoteIDSettings READ remoteIDSettings CONSTANT) + Q_PROPERTY(QObject *rtkSettings READ rtkSettings CONSTANT) + Q_PROPERTY(QObject *unitsSettings READ unitsSettings CONSTANT) + Q_PROPERTY(QObject *videoSettings READ videoSettings CONSTANT) +#ifdef QGC_VIEWER3D + Q_PROPERTY(QObject *viewer3DSettings READ viewer3DSettings CONSTANT) +#endif +public: + SettingsManager(QObject *parent = nullptr); + ~SettingsManager(); + static SettingsManager *instance(); + static void registerQmlTypes(); - // Override from QGCTool - virtual void setToolbox(QGCToolbox *toolbox); + void init(); - AppSettings* appSettings (void) { return _appSettings; } - UnitsSettings* unitsSettings (void) { return _unitsSettings; } - AutoConnectSettings* autoConnectSettings (void) { return _autoConnectSettings; } - VideoSettings* videoSettings (void) { return _videoSettings; } - FlightMapSettings* flightMapSettings (void) { return _flightMapSettings; } - FlightModeSettings* flightModeSettings (void) { return _flightModeSettings; } - RTKSettings* rtkSettings (void) { return _rtkSettings; } - FlyViewSettings* flyViewSettings (void) { return _flyViewSettings; } - PlanViewSettings* planViewSettings (void) { return _planViewSettings; } - BrandImageSettings* brandImageSettings (void) { return _brandImageSettings; } - OfflineMapsSettings* offlineMapsSettings (void) { return _offlineMapsSettings; } - FirmwareUpgradeSettings* firmwareUpgradeSettings (void) { return _firmwareUpgradeSettings; } - ADSBVehicleManagerSettings* adsbVehicleManagerSettings (void) { return _adsbVehicleManagerSettings; } - BatteryIndicatorSettings* batteryIndicatorSettings (void) { return _batteryIndicatorSettings; } - MapsSettings* mapsSettings (void) { return _mapsSettings; } - Viewer3DSettings* viewer3DSettings (void) { return _viewer3DSettings; } - GimbalControllerSettings* gimbalControllerSettings (void) { return _gimbalControllerSettings; } -#if !defined(NO_ARDUPILOT_DIALECT) - APMMavlinkStreamRateSettings* apmMavlinkStreamRateSettings(void) { return _apmMavlinkStreamRateSettings; } + ADSBVehicleManagerSettings *adsbVehicleManagerSettings() const; +#ifndef NO_ARDUPILOT_DIALECT + APMMavlinkStreamRateSettings *apmMavlinkStreamRateSettings() const; +#endif + AppSettings *appSettings() const; + AutoConnectSettings *autoConnectSettings() const; + BatteryIndicatorSettings *batteryIndicatorSettings() const; + BrandImageSettings *brandImageSettings() const; + CustomMavlinkActionsSettings *customMavlinkActionsSettings() const; + FirmwareUpgradeSettings *firmwareUpgradeSettings() const; + FlightMapSettings *flightMapSettings() const; + FlightModeSettings *flightModeSettings() const; + FlyViewSettings *flyViewSettings() const; + GimbalControllerSettings *gimbalControllerSettings() const; + MapsSettings *mapsSettings() const; + OfflineMapsSettings *offlineMapsSettings() const; + PlanViewSettings *planViewSettings() const; + RemoteIDSettings *remoteIDSettings() const; + RTKSettings *rtkSettings() const; + UnitsSettings *unitsSettings() const; + VideoSettings *videoSettings() const; +#ifdef QGC_VIEWER3D + Viewer3DSettings *viewer3DSettings() const; #endif - RemoteIDSettings* remoteIDSettings (void) { return _remoteIDSettings; } - CustomMavlinkActionsSettings* customMavlinkActionsSettings(void) { return _customMavlinkActionsSettings; } private: - AppSettings* _appSettings; - UnitsSettings* _unitsSettings; - AutoConnectSettings* _autoConnectSettings; - VideoSettings* _videoSettings; - FlightMapSettings* _flightMapSettings; - FlightModeSettings* _flightModeSettings; - RTKSettings* _rtkSettings; - FlyViewSettings* _flyViewSettings; - PlanViewSettings* _planViewSettings; - BrandImageSettings* _brandImageSettings; - OfflineMapsSettings* _offlineMapsSettings; - FirmwareUpgradeSettings* _firmwareUpgradeSettings; - ADSBVehicleManagerSettings* _adsbVehicleManagerSettings; - BatteryIndicatorSettings* _batteryIndicatorSettings; - MapsSettings* _mapsSettings; - Viewer3DSettings* _viewer3DSettings; - GimbalControllerSettings* _gimbalControllerSettings; -#if !defined(NO_ARDUPILOT_DIALECT) - APMMavlinkStreamRateSettings* _apmMavlinkStreamRateSettings; + ADSBVehicleManagerSettings *_adsbVehicleManagerSettings = nullptr; +#ifndef NO_ARDUPILOT_DIALECT + APMMavlinkStreamRateSettings *_apmMavlinkStreamRateSettings = nullptr; +#endif + AppSettings *_appSettings = nullptr; + AutoConnectSettings *_autoConnectSettings = nullptr; + BatteryIndicatorSettings *_batteryIndicatorSettings = nullptr; + BrandImageSettings *_brandImageSettings = nullptr; + CustomMavlinkActionsSettings *_customMavlinkActionsSettings = nullptr; + FirmwareUpgradeSettings *_firmwareUpgradeSettings = nullptr; + FlightMapSettings *_flightMapSettings = nullptr; + FlightModeSettings *_flightModeSettings = nullptr; + FlyViewSettings *_flyViewSettings = nullptr; + GimbalControllerSettings *_gimbalControllerSettings = nullptr; + MapsSettings *_mapsSettings = nullptr; + OfflineMapsSettings *_offlineMapsSettings = nullptr; + PlanViewSettings *_planViewSettings = nullptr; + RemoteIDSettings *_remoteIDSettings = nullptr; + RTKSettings *_rtkSettings = nullptr; + UnitsSettings *_unitsSettings = nullptr; + VideoSettings *_videoSettings = nullptr; +#ifdef QGC_VIEWER3D + Viewer3DSettings *_viewer3DSettings = nullptr; #endif - RemoteIDSettings* _remoteIDSettings; - CustomMavlinkActionsSettings* _customMavlinkActionsSettings; }; diff --git a/src/Settings/VideoSettings.cc b/src/Settings/VideoSettings.cc index b5bafb77dbd..fda625f09f3 100644 --- a/src/Settings/VideoSettings.cc +++ b/src/Settings/VideoSettings.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "VideoSettings.h" -#include "QGCApplication.h" #include "VideoManager.h" #include diff --git a/src/Terrain/TerrainTileManager.cc b/src/Terrain/TerrainTileManager.cc index 126a676aa05..1561bec6f41 100644 --- a/src/Terrain/TerrainTileManager.cc +++ b/src/Terrain/TerrainTileManager.cc @@ -14,8 +14,8 @@ #include "QGeoMapReplyQGC.h" #include "QGCMapUrlEngine.h" #include "ElevationMapProvider.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "FlightMapSettings.h" #include "QGCLoggingCategory.h" #include @@ -56,7 +56,7 @@ bool TerrainTileManager::getAltitudesForCoordinates(const QList { error = false; - const QString elevationProviderName = qgcApp()->toolbox()->settingsManager()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); + const QString elevationProviderName = SettingsManager::instance()->flightMapSettings()->elevationMapProvider()->rawValue().toString(); const SharedMapProvider provider = UrlFactory::getMapProviderFromProviderType(elevationProviderName); for (const QGeoCoordinate &coordinate: coordinates) { const QString tileHash = UrlFactory::getTileHash( diff --git a/src/Vehicle/MAVLinkLogManager.cc b/src/Vehicle/MAVLinkLogManager.cc index e81b37c09af..70bd62f749e 100644 --- a/src/Vehicle/MAVLinkLogManager.cc +++ b/src/Vehicle/MAVLinkLogManager.cc @@ -8,10 +8,10 @@ ****************************************************************************/ #include "MAVLinkLogManager.h" -#include "QGCApplication.h" #include "QGCLoggingCategory.h" #include "QmlObjectListModel.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "Vehicle.h" #include @@ -290,8 +290,8 @@ MAVLinkLogManager::MAVLinkLogManager(Vehicle *vehicle, QObject *parent) , _vehicle(vehicle) , _networkManager(new QNetworkAccessManager(this)) , _logFiles(new QmlObjectListModel(this)) - , _ulogExtension(QStringLiteral(".") + qgcApp()->toolbox()->settingsManager()->appSettings()->logFileExtension) - , _logPath(qgcApp()->toolbox()->settingsManager()->appSettings()->logSavePath()) + , _ulogExtension(QStringLiteral(".") + SettingsManager::instance()->appSettings()->logFileExtension) + , _logPath(SettingsManager::instance()->appSettings()->logSavePath()) { // qCDebug(MAVLinkLogManagerLog) << Q_FUNC_INFO << this; @@ -595,7 +595,7 @@ void MAVLinkLogManager::cancelUpload() void MAVLinkLogManager::startLogging() { - AppSettings *const appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings *const appSettings = SettingsManager::instance()->appSettings(); if (appSettings->disableAllPersistence()->rawValue().toBool()) { return; } diff --git a/src/Vehicle/MultiVehicleManager.cc b/src/Vehicle/MultiVehicleManager.cc index 1e03a5ce2ad..b50931ddfd5 100644 --- a/src/Vehicle/MultiVehicleManager.cc +++ b/src/Vehicle/MultiVehicleManager.cc @@ -12,6 +12,7 @@ #include "QGCApplication.h" #include "ParameterManager.h" #include "SettingsManager.h" +#include "FirmwareUpgradeSettings.h" #include "QGCCorePlugin.h" #include "QGCOptions.h" #include "LinkManager.h" @@ -150,7 +151,7 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle // Send QGC heartbeat ASAP, this allows PX4 to start accepting commands _sendGCSHeartbeat(); - qgcApp()->toolbox()->settingsManager()->firmwareUpgradeSettings()->defaultFirmwareType()->setRawValue(vehicleFirmwareType); + SettingsManager::instance()->firmwareUpgradeSettings()->defaultFirmwareType()->setRawValue(vehicleFirmwareType); emit vehicleAdded(vehicle); diff --git a/src/Vehicle/RemoteIDManager.cc b/src/Vehicle/RemoteIDManager.cc index 2d1885aadf0..c16538585c7 100644 --- a/src/Vehicle/RemoteIDManager.cc +++ b/src/Vehicle/RemoteIDManager.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "RemoteIDManager.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "RemoteIDSettings.h" #include "PositionManager.h" @@ -44,7 +43,7 @@ RemoteIDManager::RemoteIDManager(Vehicle* vehicle) , _targetComponent (0) // By default 0 means broadcast , _enforceSendingSelfID (false) { - _settings = qgcApp()->toolbox()->settingsManager()->remoteIDSettings(); + _settings = SettingsManager::instance()->remoteIDSettings(); // Timer to track a healthy RID device. When expired we let the operator know _odidTimeoutTimer.setSingleShot(true); diff --git a/src/Vehicle/Vehicle.cc b/src/Vehicle/Vehicle.cc index 06f864325e5..58828f14685 100644 --- a/src/Vehicle/Vehicle.cc +++ b/src/Vehicle/Vehicle.cc @@ -40,6 +40,8 @@ #include "RallyPointManager.h" #include "RemoteIDManager.h" #include "SettingsManager.h" +#include "AppSettings.h" +#include "FlyViewSettings.h" #include "StandardModes.h" #include "TerrainProtocolHandler.h" #include "TerrainQuery.h" @@ -87,9 +89,8 @@ Vehicle::Vehicle(LinkInterface* link, , _firmwareType (firmwareType) , _vehicleType (vehicleType) , _toolbox (qgcApp()->toolbox()) - , _settingsManager (_toolbox->settingsManager()) - , _defaultCruiseSpeed (_settingsManager->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) - , _defaultHoverSpeed (_settingsManager->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) + , _defaultCruiseSpeed (SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) + , _defaultHoverSpeed (SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) , _trajectoryPoints (new TrajectoryPoints(this, this)) , _mavlinkStreamConfig (std::bind(&Vehicle::_setMessageInterval, this, std::placeholders::_1, std::placeholders::_2)) , _vehicleFactGroup (this) @@ -137,9 +138,9 @@ Vehicle::Vehicle(LinkInterface* link, _vehicleLinkManager->_addLink(link); // Set video stream to udp if running ArduSub and Video is disabled - if (sub() && _settingsManager->videoSettings()->videoSource()->rawValue() == VideoSettings::videoDisabled) { - _settingsManager->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); - _settingsManager->videoSettings()->lowLatencyMode()->setRawValue(true); + if (sub() && SettingsManager::instance()->videoSettings()->videoSource()->rawValue() == VideoSettings::videoDisabled) { + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); + SettingsManager::instance()->videoSettings()->lowLatencyMode()->setRawValue(true); } #ifdef QGC_UTM_ADAPTER @@ -199,9 +200,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, , _firmwareType (firmwareType) , _vehicleType (vehicleType) , _toolbox (qgcApp()->toolbox()) - , _settingsManager (_toolbox->settingsManager()) - , _defaultCruiseSpeed (_settingsManager->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) - , _defaultHoverSpeed (_settingsManager->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) + , _defaultCruiseSpeed (SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed()->rawValue().toDouble()) + , _defaultHoverSpeed (SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed()->rawValue().toDouble()) , _mavlinkProtocolRequestComplete (true) , _maxProtoVersion (200) , _capabilityBitsKnown (true) @@ -225,8 +225,8 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, _commonInit(); - connect(_settingsManager->appSettings()->offlineEditingCruiseSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineCruiseSpeedSettingChanged); - connect(_settingsManager->appSettings()->offlineEditingHoverSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineHoverSpeedSettingChanged); + connect(SettingsManager::instance()->appSettings()->offlineEditingCruiseSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineCruiseSpeedSettingChanged); + connect(SettingsManager::instance()->appSettings()->offlineEditingHoverSpeed(), &Fact::rawValueChanged, this, &Vehicle::_offlineHoverSpeedSettingChanged); _offlineFirmwareTypeSettingChanged(_firmwareType); // This adds correct terrain capability bit _firmwarePlugin->initializeVehicle(this); @@ -234,17 +234,17 @@ Vehicle::Vehicle(MAV_AUTOPILOT firmwareType, void Vehicle::trackFirmwareVehicleTypeChanges(void) { - connect(_settingsManager->appSettings()->offlineEditingFirmwareClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged); - connect(_settingsManager->appSettings()->offlineEditingVehicleClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged); + connect(SettingsManager::instance()->appSettings()->offlineEditingFirmwareClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged); + connect(SettingsManager::instance()->appSettings()->offlineEditingVehicleClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged); - _offlineFirmwareTypeSettingChanged(_settingsManager->appSettings()->offlineEditingFirmwareClass()->rawValue()); - _offlineVehicleTypeSettingChanged(_settingsManager->appSettings()->offlineEditingVehicleClass()->rawValue()); + _offlineFirmwareTypeSettingChanged(SettingsManager::instance()->appSettings()->offlineEditingFirmwareClass()->rawValue()); + _offlineVehicleTypeSettingChanged(SettingsManager::instance()->appSettings()->offlineEditingVehicleClass()->rawValue()); } void Vehicle::stopTrackingFirmwareVehicleTypeChanges(void) { - disconnect(_settingsManager->appSettings()->offlineEditingFirmwareClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged); - disconnect(_settingsManager->appSettings()->offlineEditingVehicleClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged); + disconnect(SettingsManager::instance()->appSettings()->offlineEditingFirmwareClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineFirmwareTypeSettingChanged); + disconnect(SettingsManager::instance()->appSettings()->offlineEditingVehicleClass(), &Fact::rawValueChanged, this, &Vehicle::_offlineVehicleTypeSettingChanged); } void Vehicle::_commonInit() @@ -351,9 +351,9 @@ void Vehicle::_commonInit() connect(&_flightTimeUpdater, &QTimer::timeout, this, &Vehicle::_updateFlightTime); // Set video stream to udp if running ArduSub and Video is disabled - if (sub() && _settingsManager->videoSettings()->videoSource()->rawValue() == VideoSettings::videoDisabled) { - _settingsManager->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); - _settingsManager->videoSettings()->lowLatencyMode()->setRawValue(true); + if (sub() && SettingsManager::instance()->videoSettings()->videoSource()->rawValue() == VideoSettings::videoDisabled) { + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); + SettingsManager::instance()->videoSettings()->lowLatencyMode()->setRawValue(true); } // enable Joystick if appropriate @@ -1106,8 +1106,8 @@ void Vehicle::_updateArmed(bool armed) _trajectoryPoints->stop(); _flightTimerStop(); // Also handle Video Streaming - if(_settingsManager->videoSettings()->disableWhenDisarmed()->rawValue().toBool()) { - _settingsManager->videoSettings()->streamEnabled()->setRawValue(false); + if(SettingsManager::instance()->videoSettings()->disableWhenDisarmed()->rawValue().toBool()) { + SettingsManager::instance()->videoSettings()->streamEnabled()->setRawValue(false); VideoManager::instance()->stopVideo(); } } @@ -2119,7 +2119,7 @@ void Vehicle::guidedModeGotoLocation(const QGeoCoordinate& gotoCoord) if (!coordinate().isValid()) { return; } - double maxDistance = _settingsManager->flyViewSettings()->maxGoToLocationDistance()->rawValue().toDouble(); + double maxDistance = SettingsManager::instance()->flyViewSettings()->maxGoToLocationDistance()->rawValue().toDouble(); if (coordinate().distanceTo(gotoCoord) > maxDistance) { qgcApp()->showAppMessage(QString("New location is too far. Must be less than %1 %2.").arg(qRound(FactMetaData::metersToAppSettingsHorizontalDistanceUnits(maxDistance).toDouble())).arg(FactMetaData::appSettingsHorizontalDistanceUnitsString())); return; @@ -3365,7 +3365,7 @@ void Vehicle::_updateDistanceToGCS() void Vehicle::_updateHomepoint() { const bool setHomeCmdSupported = firmwarePlugin()->supportedMissionCommands(vehicleClass()).contains(MAV_CMD_DO_SET_HOME); - const bool updateHomeActivated = _toolbox->settingsManager()->flyViewSettings()->updateHomePosition()->rawValue().toBool(); + const bool updateHomeActivated = SettingsManager::instance()->flyViewSettings()->updateHomePosition()->rawValue().toBool(); if(setHomeCmdSupported && updateHomeActivated){ QGeoCoordinate gcsPosition = QGCPositionManager::instance()->gcsPosition(); if (coordinate().isValid() && gcsPosition.isValid()) { @@ -3477,12 +3477,12 @@ bool Vehicle::isInitialConnectComplete() const void Vehicle::_initializeCsv() { - if(!_toolbox->settingsManager()->appSettings()->saveCsvTelemetry()->rawValue().toBool()){ + if(!SettingsManager::instance()->appSettings()->saveCsvTelemetry()->rawValue().toBool()){ return; } QString now = QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss"); QString fileName = QString("%1 vehicle%2.csv").arg(now).arg(_id); - QDir saveDir(_toolbox->settingsManager()->appSettings()->telemetrySavePath()); + QDir saveDir(SettingsManager::instance()->appSettings()->telemetrySavePath()); _csvLogFile.setFileName(saveDir.absoluteFilePath(fileName)); if (!_csvLogFile.open(QIODevice::Append)) { @@ -3506,7 +3506,7 @@ void Vehicle::_writeCsvLine() { // Only save the logs after the the vehicle gets armed, unless "Save logs even if vehicle was not armed" is checked if(!_csvLogFile.isOpen() && - (_armed || _toolbox->settingsManager()->appSettings()->telemetrySaveNotArmed()->rawValue().toBool())){ + (_armed || SettingsManager::instance()->appSettings()->telemetrySaveNotArmed()->rawValue().toBool())){ _initializeCsv(); } diff --git a/src/Vehicle/Vehicle.h b/src/Vehicle/Vehicle.h index d69a212f9d8..9d0f01c6b45 100644 --- a/src/Vehicle/Vehicle.h +++ b/src/Vehicle/Vehicle.h @@ -67,7 +67,6 @@ class RemoteIDManager; class RequestMessageTest; class SendMavCommandWithHandlerTest; class SendMavCommandWithSignallingTest; -class SettingsManager; class StandardModes; class TerrainAtCoordinateQuery; class TerrainProtocolHandler; @@ -993,7 +992,6 @@ private slots: AutoPilotPlugin* _autopilotPlugin = nullptr; bool _soloFirmware = false; QGCToolbox* _toolbox = nullptr; - SettingsManager* _settingsManager = nullptr; QTimer _csvLogTimer; QFile _csvLogFile; diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 960be3892d4..9715420aa46 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.cc +++ b/src/VehicleSetup/FirmwareUpgradeController.cc @@ -110,8 +110,8 @@ FirmwareUpgradeController::FirmwareUpgradeController(void) , _selectedFirmwareBuildType (StableFirmware) , _image (nullptr) , _apmBoardDescriptionReplaceText ("") - , _apmChibiOSSetting (qgcApp()->toolbox()->settingsManager()->firmwareUpgradeSettings()->apmChibiOS()) - , _apmVehicleTypeSetting (qgcApp()->toolbox()->settingsManager()->firmwareUpgradeSettings()->apmVehicleType()) + , _apmChibiOSSetting (SettingsManager::instance()->firmwareUpgradeSettings()->apmChibiOS()) + , _apmVehicleTypeSetting (SettingsManager::instance()->firmwareUpgradeSettings()->apmVehicleType()) { _manifestMavFirmwareVersionTypeToFirmwareBuildTypeMap["OFFICIAL"] = StableFirmware; _manifestMavFirmwareVersionTypeToFirmwareBuildTypeMap["BETA"] = BetaFirmware; diff --git a/src/VideoManager/CMakeLists.txt b/src/VideoManager/CMakeLists.txt index eccf8859cc8..f1e3b36b708 100644 --- a/src/VideoManager/CMakeLists.txt +++ b/src/VideoManager/CMakeLists.txt @@ -1,4 +1,4 @@ -find_package(Qt6 REQUIRED COMPONENTS Core) +find_package(Qt6 REQUIRED COMPONENTS Core QmlIntegration) qt_add_library(VideoManager STATIC SubtitleWriter.cc @@ -31,6 +31,7 @@ target_link_libraries(VideoManager VideoReceiver PUBLIC Qt6::Core + Qt6::QmlIntegration ) target_include_directories(VideoManager PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/VideoManager/VideoManager.cc b/src/VideoManager/VideoManager.cc index ccdd700c3ff..0323531297e 100644 --- a/src/VideoManager/VideoManager.cc +++ b/src/VideoManager/VideoManager.cc @@ -15,6 +15,7 @@ #include "QGCLoggingCategory.h" #include "QGCToolbox.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "SubtitleWriter.h" #include "Vehicle.h" #include "VideoReceiver.h" @@ -54,23 +55,13 @@ Q_APPLICATION_STATIC(VideoManager, _videoManagerInstance); VideoManager::VideoManager(QObject *parent) : QObject(parent) , _subtitleWriter(new SubtitleWriter(this)) - , _videoSettings(qgcApp()->toolbox()->settingsManager()->videoSettings()) + , _videoSettings(SettingsManager::instance()->videoSettings()) { // qCDebug(VideoManagerLog) << Q_FUNC_INFO << this; if (qgcApp()->runningUnitTests()) { return; } - - (void) qmlRegisterUncreatableType ("QGroundControl.VideoManager", 1, 0, "VideoManager", "Reference only"); - (void) qmlRegisterUncreatableType("QGroundControl", 1, 0, "VideoReceiver","Reference only"); - -#ifdef QGC_GST_STREAMING - GStreamer::initialize(); - GStreamer::blacklist(static_cast(_videoSettings->forceVideoDecoder()->rawValue().toInt())); -#else - (void) qmlRegisterType("org.freedesktop.gstreamer.Qt6GLVideoItem", 1, 0, "GstGLQt6VideoItem"); -#endif } VideoManager::~VideoManager() @@ -103,12 +94,28 @@ VideoManager *VideoManager::instance() return _videoManagerInstance(); } +void VideoManager::registerQmlTypes() +{ + (void) qmlRegisterUncreatableType("QGroundControl.VideoManager", 1, 0, "VideoManager", "Reference only"); + (void) qmlRegisterUncreatableType("QGroundControl", 1, 0, "VideoReceiver","Reference only"); + #ifdef QGC_GST_STREAMING + GStreamer::initialize(); + GStreamer::blacklist(static_cast(SettingsManager::instance()->videoSettings()->forceVideoDecoder()->rawValue().toInt())); + #else + (void) qmlRegisterType("org.freedesktop.gstreamer.Qt6GLVideoItem", 1, 0, "GstGLQt6VideoItem"); + #endif +} + void VideoManager::init() { if (_initialized) { return; } +#ifdef QGC_GST_STREAMING + +#endif + // TODO: Those connections should be Per Video, not per VideoManager. (void) connect(_videoSettings->videoSource(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged); (void) connect(_videoSettings->udpPort(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged); @@ -247,7 +254,7 @@ void VideoManager::startRecording(const QString &videoFile) _cleanupOldVideos(); - const QString savePath = qgcApp()->toolbox()->settingsManager()->appSettings()->videoSavePath(); + const QString savePath = SettingsManager::instance()->appSettings()->videoSavePath(); if (savePath.isEmpty()) { qgcApp()->showAppMessage(tr("Unabled to record video. Video save path must be specified in Settings.")); return; @@ -281,7 +288,7 @@ void VideoManager::stopRecording() void VideoManager::grabImage(const QString &imageFile) { if (imageFile.isEmpty()) { - _imageFile = qgcApp()->toolbox()->settingsManager()->appSettings()->photoSavePath(); + _imageFile = SettingsManager::instance()->appSettings()->photoSavePath(); _imageFile += "/" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss.zzz") + ".jpg"; } else { _imageFile = imageFile; @@ -464,11 +471,11 @@ void VideoManager::_initVideo() void VideoManager::_cleanupOldVideos() { - if (!qgcApp()->toolbox()->settingsManager()->videoSettings()->enableStorageLimit()->rawValue().toBool()) { + if (!SettingsManager::instance()->videoSettings()->enableStorageLimit()->rawValue().toBool()) { return; } - const QString savePath = qgcApp()->toolbox()->settingsManager()->appSettings()->videoSavePath(); + const QString savePath = SettingsManager::instance()->appSettings()->videoSavePath(); QDir videoDir = QDir(savePath); videoDir.setFilter(QDir::Files | QDir::Readable | QDir::NoSymLinks | QDir::Writable); videoDir.setSorting(QDir::Time); @@ -486,7 +493,7 @@ void VideoManager::_cleanupOldVideos() total += vidList[i].size(); } - const uint64_t maxSize = qgcApp()->toolbox()->settingsManager()->videoSettings()->maxVideoSize()->rawValue().toUInt() * qPow(1024, 2); + const uint64_t maxSize = SettingsManager::instance()->videoSettings()->maxVideoSize()->rawValue().toUInt() * qPow(1024, 2); while ((total >= maxSize) && !vidList.isEmpty()) { total -= vidList.last().size(); qCDebug(VideoManagerLog) << "Removing old video file:" << vidList.last().filePath(); @@ -574,27 +581,27 @@ bool VideoManager::_updateAutoStream(unsigned id) case VIDEO_STREAM_TYPE_RTSP: settingsChanged = _updateVideoUri(id, pInfo->uri()); if (settingsChanged) { - qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceRTSP); + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceRTSP); } break; case VIDEO_STREAM_TYPE_TCP_MPEG: settingsChanged = _updateVideoUri(id, pInfo->uri()); if (settingsChanged) { - qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceTCP); + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceTCP); } break; case VIDEO_STREAM_TYPE_RTPUDP: { const QString url = pInfo->uri().contains("udp://") ? pInfo->uri() : QStringLiteral("udp://0.0.0.0:%1").arg(pInfo->uri()); settingsChanged = _updateVideoUri(id, url); if (settingsChanged) { - qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceUDPH264); } break; } case VIDEO_STREAM_TYPE_MPEG_TS: settingsChanged = _updateVideoUri(id, QStringLiteral("mpegts://0.0.0.0:%1").arg(pInfo->uri())); if (settingsChanged) { - qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceMPEGTS); + SettingsManager::instance()->videoSettings()->videoSource()->setRawValue(VideoSettings::videoSourceMPEGTS); } break; default: diff --git a/src/VideoManager/VideoManager.h b/src/VideoManager/VideoManager.h index 32179ea1631..db31eecbf9f 100644 --- a/src/VideoManager/VideoManager.h +++ b/src/VideoManager/VideoManager.h @@ -13,6 +13,7 @@ #include #include #include +#include Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog) @@ -27,7 +28,9 @@ class VideoSettings; class VideoManager : public QObject { Q_OBJECT - + QML_ELEMENT + QML_UNCREATABLE("") + Q_MOC_INCLUDE("Vehicle.h") Q_PROPERTY(bool gstreamerEnabled READ gstreamerEnabled CONSTANT) Q_PROPERTY(bool qtmultimediaEnabled READ qtmultimediaEnabled CONSTANT) Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT) @@ -57,6 +60,7 @@ class VideoManager : public QObject /// Gets the singleton instance of VideoManager. /// @return The singleton instance. static VideoManager *instance(); + static void registerQmlTypes(); Q_INVOKABLE void grabImage(const QString &imageFile = QString()); Q_INVOKABLE void startRecording(const QString &videoFile = QString()); diff --git a/src/Viewer3D/CMakeLists.txt b/src/Viewer3D/CMakeLists.txt index 9d9f50e98c8..74000590f6b 100644 --- a/src/Viewer3D/CMakeLists.txt +++ b/src/Viewer3D/CMakeLists.txt @@ -36,7 +36,6 @@ if(QGC_VIEWER3D) target_link_libraries(Viewer3D PRIVATE Qt6::Network - QGC QGCLocation Settings Vehicle diff --git a/src/Viewer3D/CityMapGeometry.cc b/src/Viewer3D/CityMapGeometry.cc index c918dcb1f66..b062e8b6434 100644 --- a/src/Viewer3D/CityMapGeometry.cc +++ b/src/Viewer3D/CityMapGeometry.cc @@ -8,8 +8,8 @@ ****************************************************************************/ #include "CityMapGeometry.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "Viewer3DSettings.h" #include "OsmParser.h" @@ -20,7 +20,7 @@ CityMapGeometry::CityMapGeometry() _vertexData.clear(); _mapLoadedFlag = 0; - _viewer3DSettings = qgcApp()->toolbox()->settingsManager()->viewer3DSettings(); + _viewer3DSettings = SettingsManager::instance()->viewer3DSettings(); setOsmFilePath(_viewer3DSettings->osmFilePath()->rawValue()); connect(_viewer3DSettings->osmFilePath(), &Fact::rawValueChanged, this, &CityMapGeometry::setOsmFilePath); diff --git a/src/Viewer3D/OsmParser.cc b/src/Viewer3D/OsmParser.cc index b72eddce1fd..f11bdc94b7c 100644 --- a/src/Viewer3D/OsmParser.cc +++ b/src/Viewer3D/OsmParser.cc @@ -8,8 +8,8 @@ ****************************************************************************/ #include "OsmParser.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "Viewer3DSettings.h" #include "OsmParserThread.h" #include "earcut.hpp" @@ -36,7 +36,7 @@ OsmParser::OsmParser(QObject *parent) _doubleStoreyLeisure.append("sports_hall"); _doubleStoreyLeisure.append("sauna"); - _viewer3DSettings = qgcApp()->toolbox()->settingsManager()->viewer3DSettings(); + _viewer3DSettings = SettingsManager::instance()->viewer3DSettings(); _gpsRefSet = false; _mapLoadedFlag = false; diff --git a/src/Viewer3D/Viewer3DQmlBackend.cc b/src/Viewer3D/Viewer3DQmlBackend.cc index 3f9fbcea2a0..9d94463bda5 100644 --- a/src/Viewer3D/Viewer3DQmlBackend.cc +++ b/src/Viewer3D/Viewer3DQmlBackend.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "Viewer3DQmlBackend.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "MultiVehicleManager.h" #include "Vehicle.h" @@ -24,7 +23,7 @@ Viewer3DQmlBackend::Viewer3DQmlBackend(QObject *parent) { _gpsRefSet = GPS_REF_NOT_SET; _activeVehicle = nullptr; - _viewer3DSettings = qgcApp()->toolbox()->settingsManager()->viewer3DSettings(); + _viewer3DSettings = SettingsManager::instance()->viewer3DSettings(); } void Viewer3DQmlBackend::init(OsmParser* osmThr) diff --git a/src/Viewer3D/Viewer3DTerrainGeometry.cc b/src/Viewer3D/Viewer3DTerrainGeometry.cc index 656c5c10d2a..f88d03b0853 100644 --- a/src/Viewer3D/Viewer3DTerrainGeometry.cc +++ b/src/Viewer3D/Viewer3DTerrainGeometry.cc @@ -9,7 +9,6 @@ #include "Viewer3DTerrainGeometry.h" #include "Viewer3DUtils.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "Viewer3DSettings.h" @@ -21,7 +20,7 @@ Viewer3DTerrainGeometry::Viewer3DTerrainGeometry() { - _viewer3DSettings = qgcApp()->toolbox()->settingsManager()->viewer3DSettings(); + _viewer3DSettings = SettingsManager::instance()->viewer3DSettings(); setSectorCount(0); setStackCount(0); setRadius(EarthRadius); diff --git a/src/Viewer3D/Viewer3DTerrainTexture.cc b/src/Viewer3D/Viewer3DTerrainTexture.cc index 95bc65fda33..873827c0c6d 100644 --- a/src/Viewer3D/Viewer3DTerrainTexture.cc +++ b/src/Viewer3D/Viewer3DTerrainTexture.cc @@ -9,7 +9,6 @@ #include "Viewer3DTerrainTexture.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "QGCMapEngine.h" #include "QGCMapUrlEngine.h" @@ -20,7 +19,7 @@ Viewer3DTerrainTexture::Viewer3DTerrainTexture() { _terrainTileLoader = nullptr; - _flightMapSettings = qgcApp()->toolbox()->settingsManager()->flightMapSettings(); + _flightMapSettings = SettingsManager::instance()->flightMapSettings(); mapTypeChangedEvent(); setTextureGeometryDone(false); diff --git a/test/FollowMe/CMakeLists.txt b/test/FollowMe/CMakeLists.txt index 1866931a428..9d5c020ddca 100644 --- a/test/FollowMe/CMakeLists.txt +++ b/test/FollowMe/CMakeLists.txt @@ -10,7 +10,6 @@ target_link_libraries(FollowMeTest PRIVATE Qt6::Test FollowMe - QGC Vehicle PUBLIC qgcunittest diff --git a/test/FollowMe/FollowMeTest.cc b/test/FollowMe/FollowMeTest.cc index 82a1c177f65..9a6d1f0eef4 100644 --- a/test/FollowMe/FollowMeTest.cc +++ b/test/FollowMe/FollowMeTest.cc @@ -9,11 +9,11 @@ #include "FollowMeTest.h" #include "FollowMe.h" -#include "QGCApplication.h" #include "MultiVehicleManager.h" #include "PositionManager.h" #include "Vehicle.h" #include "SettingsManager.h" +#include "AppSettings.h" #include #include @@ -28,7 +28,7 @@ void FollowMeTest::_testFollowMe() MultiVehicleManager *vehicleMgr = MultiVehicleManager::instance(); Vehicle *vehicle = vehicleMgr->activeVehicle(); vehicle->setFlightMode(vehicle->followFlightMode()); - qgcApp()->toolbox()->settingsManager()->appSettings()->followTarget()->setRawValue(1); + SettingsManager::instance()->appSettings()->followTarget()->setRawValue(1); QSignalSpy spyGCSMotionReport(vehicle, &Vehicle::messagesSentChanged); diff --git a/test/MissionManager/MissionCommandTreeEditorTest.cc b/test/MissionManager/MissionCommandTreeEditorTest.cc index 709de2e053d..a3c0229baba 100644 --- a/test/MissionManager/MissionCommandTreeEditorTest.cc +++ b/test/MissionManager/MissionCommandTreeEditorTest.cc @@ -13,6 +13,7 @@ #include "FirmwarePlugin.h" #include "FirmwarePluginManager.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "SimpleMissionItem.h" #include "PlanMasterController.h" @@ -30,7 +31,7 @@ void MissionCommandTreeEditorTest::_testEditorsWorker(QGCMAVLink::FirmwareClass_ QString firmwareClassString = QGCMAVLink::firmwareClassToString(firmwareClass).replace(" ", ""); QString vehicleClassString = QGCMAVLink::vehicleClassToUserVisibleString(vehicleClass).replace(" ", ""); - AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings* appSettings = SettingsManager::instance()->appSettings(); appSettings->offlineEditingFirmwareClass()->setRawValue(firmwareClass); appSettings->offlineEditingVehicleClass()->setRawValue(vehicleClass); PlanMasterController masterController; diff --git a/test/MissionManager/MissionControllerTest.cc b/test/MissionManager/MissionControllerTest.cc index 2594a83f61f..8229f29213f 100644 --- a/test/MissionManager/MissionControllerTest.cc +++ b/test/MissionManager/MissionControllerTest.cc @@ -13,9 +13,9 @@ #include "PlanMasterController.h" #include "SimpleMissionItem.h" #include "MissionSettingsItem.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "AppSettings.h" +#include "PlanViewSettings.h" #include "MultiSignalSpy.h" #include @@ -50,7 +50,7 @@ void MissionControllerTest::_initForFirmwareType(MAV_AUTOPILOT firmwareType) _rgMissionControllerSignals[visualItemsChangedSignalIndex] = SIGNAL(visualItemsChanged()); // Master controller pulls offline vehicle info from settings - qgcApp()->toolbox()->settingsManager()->appSettings()->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(firmwareType)); + SettingsManager::instance()->appSettings()->offlineEditingFirmwareClass()->setRawValue(QGCMAVLink::firmwareClass(firmwareType)); _masterController = new PlanMasterController(this); _masterController->setFlyView(false); _missionController = _masterController->missionController(); @@ -172,7 +172,7 @@ void MissionControllerTest::_testGimbalRecalc(void) SimpleMissionItem* item = _missionController->visualItems()->value(yawIndex); item->cameraSection()->setSpecifyGimbal(true); item->cameraSection()->gimbalYaw()->setRawValue(0.0); - qgcApp()->toolbox()->settingsManager()->planViewSettings()->showGimbalOnlyWhenSet()->setRawValue(false); + SettingsManager::instance()->planViewSettings()->showGimbalOnlyWhenSet()->setRawValue(false); QTest::qWait(100); // Recalcs in MissionController are queued to remove dups. Allow return to main message loop. for (int i=1; i<_missionController->visualItems()->count(); i++) { //qDebug() << i; diff --git a/test/MissionManager/SimpleMissionItemTest.cc b/test/MissionManager/SimpleMissionItemTest.cc index 9e5919e0e72..bacefb2de67 100644 --- a/test/MissionManager/SimpleMissionItemTest.cc +++ b/test/MissionManager/SimpleMissionItemTest.cc @@ -9,8 +9,8 @@ #include "SimpleMissionItemTest.h" #include "SimpleMissionItem.h" -#include "QGCApplication.h" #include "SettingsManager.h" +#include "AppSettings.h" #include "PlanMasterController.h" #include "MultiSignalSpy.h" #include "CameraSection.h" @@ -249,7 +249,7 @@ void SimpleMissionItemTest::_testDefaultValues(void) item.missionItem().setCommand(MAV_CMD_NAV_WAYPOINT); item.missionItem().setFrame(MAV_FRAME_GLOBAL_RELATIVE_ALT); - QCOMPARE(item.missionItem().param7(), qgcApp()->toolbox()->settingsManager()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble()); + QCOMPARE(item.missionItem().param7(), SettingsManager::instance()->appSettings()->defaultMissionItemAltitude()->rawValue().toDouble()); } void SimpleMissionItemTest::_testSignals(void) diff --git a/test/MissionManager/TransectStyleComplexItemTestBase.cc b/test/MissionManager/TransectStyleComplexItemTestBase.cc index 6583dfee960..72ab1d37949 100644 --- a/test/MissionManager/TransectStyleComplexItemTestBase.cc +++ b/test/MissionManager/TransectStyleComplexItemTestBase.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "TransectStyleComplexItemTestBase.h" -#include "QGCApplication.h" #include "SettingsManager.h" #include "PlanMasterController.h" #include "PlanViewSettings.h" @@ -22,7 +21,7 @@ void TransectStyleComplexItemTestBase::init(void) { UnitTest::init(); - _planViewSettings = qgcApp()->toolbox()->settingsManager()->planViewSettings(); + _planViewSettings = SettingsManager::instance()->planViewSettings(); _masterController = new PlanMasterController(this); _controllerVehicle = _masterController->controllerVehicle(); } diff --git a/test/qgcunittest/UnitTest.cc b/test/qgcunittest/UnitTest.cc index 85ba0edb807..8d6fb3c3beb 100644 --- a/test/qgcunittest/UnitTest.cc +++ b/test/qgcunittest/UnitTest.cc @@ -8,7 +8,6 @@ ****************************************************************************/ #include "UnitTest.h" -#include "QGCApplication.h" #include "MAVLinkProtocol.h" #include "MultiVehicleManager.h" #include "Vehicle.h" @@ -95,7 +94,7 @@ void UnitTest::init(void) LinkManager::instance()->setConnectionsAllowed(); // Force offline vehicle back to defaults - AppSettings* appSettings = qgcApp()->toolbox()->settingsManager()->appSettings(); + AppSettings* appSettings = SettingsManager::instance()->appSettings(); appSettings->offlineEditingFirmwareClass()->setRawValue(appSettings->offlineEditingFirmwareClass()->rawDefaultValue()); appSettings->offlineEditingVehicleClass()->setRawValue(appSettings->offlineEditingVehicleClass()->rawDefaultValue());