From d21b5e3b427c0c0f35fd0959ca48ec7279ff8b03 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 15 Sep 2016 09:24:13 +0200 Subject: [PATCH] LP-245 config: add exportMode() method to ConfigTaskPanel --- .../src/plugins/config/config_cc_hw_widget.cpp | 10 +++------- .../config/configcamerastabilizationwidget.cpp | 9 +-------- .../src/plugins/config/configccattitudewidget.cpp | 8 +------- .../gcs/src/plugins/config/configinputwidget.cpp | 15 ++++----------- .../gcs/src/plugins/config/configoplinkwidget.cpp | 9 +-------- .../gcs/src/plugins/config/configoutputwidget.cpp | 9 ++------- .../gcs/src/plugins/config/configrevohwwidget.cpp | 10 +--------- .../src/plugins/config/configrevonanohwwidget.cpp | 10 +--------- .../gcs/src/plugins/config/configrevowidget.cpp | 10 +--------- .../src/plugins/config/configsparky2hwwidget.cpp | 10 +--------- .../plugins/config/configstabilizationwidget.cpp | 9 +-------- .../gcs/src/plugins/config/configtxpidwidget.cpp | 10 +--------- .../plugins/config/configvehicletypewidget.cpp | 9 ++------- .../uavobjectwidgetutils/configtaskwidget.cpp | 9 +++++++++ .../uavobjectwidgetutils/configtaskwidget.h | 3 ++- 15 files changed, 31 insertions(+), 109 deletions(-) diff --git a/ground/gcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/gcs/src/plugins/config/config_cc_hw_widget.cpp index e2cbf6f66..c27cd49d2 100644 --- a/ground/gcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/gcs/src/plugins/config/config_cc_hw_widget.cpp @@ -31,7 +31,6 @@ #include "ui_cc_hw_settings.h" #include -#include #include "hwsettings.h" @@ -58,13 +57,10 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) addApplySaveButtons(m_telemetry->saveTelemetryToRAM, m_telemetry->saveTelemetryToSD); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_telemetry->saveTelemetryToRAM->setVisible(false); - } + m_telemetry->saveTelemetryToRAM->setVisible(expertMode()); - UAVObjectUtilManager *utilMngr = pm->getObject(); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectUtilManager *utilMngr = pm->getObject(); int id = utilMngr->getBoardModel(); switch (id) { case 0x0101: diff --git a/ground/gcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/gcs/src/plugins/config/configcamerastabilizationwidget.cpp index 18471f155..48caebac2 100644 --- a/ground/gcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/gcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -38,9 +38,6 @@ #include "ui_camerastabilization.h" -#include -#include - #include "camerastabsettings.h" #include "hwsettings.h" #include "mixersettings.h" @@ -60,11 +57,7 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent addApplySaveButtons(ui->camerastabilizationSaveRAM, ui->camerastabilizationSaveSD); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - ui->camerastabilizationSaveRAM->setVisible(false); - } + ui->camerastabilizationSaveRAM->setVisible(expertMode()); // These widgets don't have direct relation to UAVObjects // and need special processing diff --git a/ground/gcs/src/plugins/config/configccattitudewidget.cpp b/ground/gcs/src/plugins/config/configccattitudewidget.cpp index 761e268ef..e0480e15c 100644 --- a/ground/gcs/src/plugins/config/configccattitudewidget.cpp +++ b/ground/gcs/src/plugins/config/configccattitudewidget.cpp @@ -30,8 +30,6 @@ #include "ui_ccattitude.h" #include "utils/coordinateconversions.h" -#include -#include #include #include "attitudesettings.h" @@ -60,11 +58,7 @@ ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) : addApplySaveButtons(ui->applyButton, ui->saveButton); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - ui->applyButton->setVisible(false); - } + ui->applyButton->setVisible(expertMode()); addUAVObject("AttitudeSettings"); addUAVObject("AccelGyroSettings"); diff --git a/ground/gcs/src/plugins/config/configinputwidget.cpp b/ground/gcs/src/plugins/config/configinputwidget.cpp index 301dce104..bb77ca5db 100644 --- a/ground/gcs/src/plugins/config/configinputwidget.cpp +++ b/ground/gcs/src/plugins/config/configinputwidget.cpp @@ -28,11 +28,6 @@ #include "configinputwidget.h" -#include -#include -#include -#include - #include "ui_input.h" #include "ui_input_wizard.h" @@ -42,6 +37,9 @@ #include "failsafechannelform.h" #include "ui_failsafechannelform.h" +#include +#include + #include #include @@ -96,12 +94,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : connect(ui->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(ui->saveRCInputToRAM, ui->saveRCInputToSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - ui->saveRCInputToRAM->setVisible(false); - } + ui->saveRCInputToRAM->setVisible(expertMode()); manualCommandObj = ManualControlCommand::GetInstance(getObjectManager()); manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager()); diff --git a/ground/gcs/src/plugins/config/configoplinkwidget.cpp b/ground/gcs/src/plugins/config/configoplinkwidget.cpp index bef996e65..9d5c49294 100644 --- a/ground/gcs/src/plugins/config/configoplinkwidget.cpp +++ b/ground/gcs/src/plugins/config/configoplinkwidget.cpp @@ -30,8 +30,6 @@ #include "ui_oplink.h" -#include - #include #include @@ -59,12 +57,7 @@ ConfigOPLinkWidget::ConfigOPLinkWidget(QWidget *parent) : ConfigTaskWidget(paren disableMouseWheelEvents(); addApplySaveButtons(m_oplink->Apply, m_oplink->Save); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_oplink->Apply->setVisible(false); - } + m_oplink->Apply->setVisible(expertMode()); oplinkStatusObj = dynamic_cast(getObject("OPLinkStatus")); Q_ASSERT(oplinkStatusObj); diff --git a/ground/gcs/src/plugins/config/configoutputwidget.cpp b/ground/gcs/src/plugins/config/configoutputwidget.cpp index 4b8109f7e..0b0db96e9 100644 --- a/ground/gcs/src/plugins/config/configoutputwidget.cpp +++ b/ground/gcs/src/plugins/config/configoutputwidget.cpp @@ -36,7 +36,6 @@ #include "uavsettingsimportexport/uavsettingsimportexportfactory.h" #include -#include #include #include "mixersettings.h" @@ -70,15 +69,11 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren connect(m_ui->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_ui->saveRCOutputToRAM, m_ui->saveRCOutputToSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_ui->saveRCOutputToRAM->setVisible(false); - } + m_ui->saveRCOutputToRAM->setVisible(expertMode()); m_ui->gvFrame->setVisible(false); + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVSettingsImportExportFactory *importexportplugin = pm->getObject(); connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(stopTests())); diff --git a/ground/gcs/src/plugins/config/configrevohwwidget.cpp b/ground/gcs/src/plugins/config/configrevohwwidget.cpp index e2e26806b..12111614f 100644 --- a/ground/gcs/src/plugins/config/configrevohwwidget.cpp +++ b/ground/gcs/src/plugins/config/configrevohwwidget.cpp @@ -29,8 +29,6 @@ #include "ui_configrevohwwidget.h" -#include -#include #include #include "hwsettings.h" @@ -53,13 +51,7 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren connect(m_ui->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_ui->saveTelemetryToRAM, m_ui->saveTelemetryToSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_ui->saveTelemetryToRAM->setEnabled(false); - m_ui->saveTelemetryToRAM->setVisible(false); - } + m_ui->saveTelemetryToRAM->setVisible(expertMode()); addWidgetBinding("HwSettings", "RM_FlexiPort", m_ui->cbFlexi); addWidgetBinding("HwSettings", "RM_MainPort", m_ui->cbMain); diff --git a/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp b/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp index 8477a1d87..9511d182b 100644 --- a/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp +++ b/ground/gcs/src/plugins/config/configrevonanohwwidget.cpp @@ -29,8 +29,6 @@ #include "ui_configrevonanohwwidget.h" -#include -#include #include #include "hwsettings.h" @@ -53,13 +51,7 @@ ConfigRevoNanoHWWidget::ConfigRevoNanoHWWidget(QWidget *parent) : ConfigTaskWidg connect(m_ui->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_ui->saveTelemetryToRAM, m_ui->saveTelemetryToSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_ui->saveTelemetryToRAM->setEnabled(false); - m_ui->saveTelemetryToRAM->setVisible(false); - } + m_ui->saveTelemetryToRAM->setVisible(expertMode()); addWidgetBinding("HwSettings", "RM_FlexiPort", m_ui->cbFlexi); addWidgetBinding("HwSettings", "RM_MainPort", m_ui->cbMain); diff --git a/ground/gcs/src/plugins/config/configrevowidget.cpp b/ground/gcs/src/plugins/config/configrevowidget.cpp index 3103bab03..ee9e21a00 100644 --- a/ground/gcs/src/plugins/config/configrevowidget.cpp +++ b/ground/gcs/src/plugins/config/configrevowidget.cpp @@ -38,9 +38,6 @@ #include #include -#include -#include - #include "assertions.h" #include "calibration.h" #include "calibration/calibrationutils.h" @@ -93,12 +90,7 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) : connect(m_ui->attitudeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_ui->revoCalSettingsSaveRAM, m_ui->revoCalSettingsSaveSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_ui->revoCalSettingsSaveRAM->setVisible(false); - } + m_ui->revoCalSettingsSaveRAM->setVisible(expertMode()); // Initialization of the visual help m_ui->calibrationVisualHelp->setScene(new QGraphicsScene(this)); diff --git a/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp b/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp index 7a0e67e5c..f0286b414 100644 --- a/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp +++ b/ground/gcs/src/plugins/config/configsparky2hwwidget.cpp @@ -29,8 +29,6 @@ #include "ui_configsparky2hwwidget.h" -#include -#include #include #include "hwsettings.h" @@ -53,13 +51,7 @@ ConfigSparky2HWWidget::ConfigSparky2HWWidget(QWidget *parent) : ConfigTaskWidget connect(m_ui->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_ui->saveTelemetryToRAM, m_ui->saveTelemetryToSD); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_ui->saveTelemetryToRAM->setEnabled(false); - m_ui->saveTelemetryToRAM->setVisible(false); - } + m_ui->saveTelemetryToRAM->setVisible(expertMode()); addWidgetBinding("HwSettings", "SPK2_FlexiPort", m_ui->cbFlexi); addWidgetBinding("HwSettings", "SPK2_MainPort", m_ui->cbMain); diff --git a/ground/gcs/src/plugins/config/configstabilizationwidget.cpp b/ground/gcs/src/plugins/config/configstabilizationwidget.cpp index d64a7036f..6495bdcb1 100644 --- a/ground/gcs/src/plugins/config/configstabilizationwidget.cpp +++ b/ground/gcs/src/plugins/config/configstabilizationwidget.cpp @@ -29,9 +29,6 @@ #include "ui_stabilization.h" -#include -#include - #include "objectpersistence.h" #include "altitudeholdsettings.h" #include "stabilizationsettings.h" @@ -70,11 +67,7 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa disableMouseWheelEvents(); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - ui->saveStabilizationToRAM_6->setVisible(false); - } + ui->saveStabilizationToRAM_6->setVisible(expertMode()); setupExpoPlot(); diff --git a/ground/gcs/src/plugins/config/configtxpidwidget.cpp b/ground/gcs/src/plugins/config/configtxpidwidget.cpp index 202003026..ba4c8a600 100644 --- a/ground/gcs/src/plugins/config/configtxpidwidget.cpp +++ b/ground/gcs/src/plugins/config/configtxpidwidget.cpp @@ -30,9 +30,6 @@ #include "ui_txpid.h" -#include -#include - #include "txpidsettings.h" #include "hwsettings.h" #include "attitudesettings.h" @@ -54,12 +51,7 @@ ConfigTxPIDWidget::ConfigTxPIDWidget(QWidget *parent) : ConfigTaskWidget(parent) disableMouseWheelEvents(); addApplySaveButtons(m_txpid->Apply, m_txpid->Save); - - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_txpid->Apply->setVisible(false); - } + m_txpid->Apply->setVisible(expertMode()); // Cannot use addUAVObjectToWidgetRelation() for OptionaModules enum because // QCheckBox returns bool (0 or -1) and this value is then set to enum instead diff --git a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp index 3815161ee..2f0a59016 100644 --- a/ground/gcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/gcs/src/plugins/config/configvehicletypewidget.cpp @@ -31,7 +31,6 @@ #include "configgadgetfactory.h" #include -#include #include "systemsettings.h" #include "actuatorsettings.h" @@ -130,13 +129,9 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD); + m_aircraft->saveAircraftToRAM->setVisible(expertMode()); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - Core::Internal::GeneralSettings *settings = pm->getObject(); - if (!settings->useExpertMode()) { - m_aircraft->saveAircraftToRAM->setVisible(false); - } - ConfigGadgetFactory *configGadgetFactory = pm->getObject(); connect(m_aircraft->vehicleSetupWizardButton, SIGNAL(clicked()), configGadgetFactory, SIGNAL(onOpenVehicleConfigurationWizard())); @@ -258,7 +253,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgetsImpl() UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); Q_ASSERT(system); - QPointer field = system->getField(QString("AirframeType")); + UAVObjectField *field = system->getField(QString("AirframeType")); if (field) { field->setValue(airframeType); } diff --git a/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index e9eb4c072..51e6595c2 100644 --- a/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -27,6 +27,7 @@ */ #include "configtaskwidget.h" +#include #include "uavobjectmanager.h" #include "uavobject.h" #include "uavobjectutilmanager.h" @@ -89,6 +90,14 @@ ConfigTaskWidget::~ConfigTaskWidget() } } +bool ConfigTaskWidget::expertMode() const +{ + Core::Internal::GeneralSettings *settings = m_pluginManager->getObject(); + + return settings->useExpertMode(); +} + + void ConfigTaskWidget::addWidget(QWidget *widget) { addWidgetBinding("", "", widget); diff --git a/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index f10d15171..f155ada5a 100644 --- a/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/gcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -173,10 +173,11 @@ signals: void enableControlsChanged(bool enable); protected: - int boardModel() + int boardModel() const { return m_currentBoardId; } + bool expertMode() const; virtual void enableControls(bool enable); virtual QString mapObjectName(const QString objectName); virtual UAVObject *getObject(const QString name, quint32 instId = 0);