From b9f1532598cc577238fd925b2811e1f683c240d5 Mon Sep 17 00:00:00 2001 From: zedamota Date: Tue, 26 Jul 2011 20:35:38 +0100 Subject: [PATCH] Refractured the Airframe config widget. Corrected some language mistakes. --- .../src/plugins/config/airframe.ui | 181 +++++++----------- .../src/plugins/config/cc_hw_settings.ui | 31 ++- .../plugins/config/config_cc_hw_widget.cpp | 19 +- .../plugins/config/config_pro_hw_widget.cpp | 2 +- .../plugins/config/configairframewidget.cpp | 94 ++++----- .../src/plugins/config/configairframewidget.h | 7 +- .../src/plugins/config/configinputwidget.cpp | 2 +- .../src/plugins/config/configtaskwidget.cpp | 111 ++++++++++- .../src/plugins/config/configtaskwidget.h | 15 +- .../src/plugins/config/smartsavebutton.cpp | 4 + .../src/plugins/config/smartsavebutton.h | 4 + 11 files changed, 269 insertions(+), 201 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 1f3c6446a..fd039a906 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -23,7 +23,7 @@ Mixer Settings - + 5 @@ -74,7 +74,7 @@ - 3 + 1 @@ -1731,75 +1731,6 @@ Typical value is 50% for + or X configuration on quads. - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 32 - 32 - - - - - - - - :/core/images/helpicon.svg:/core/images/helpicon.svg - - - - 32 - 32 - - - - true - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - @@ -1808,7 +1739,7 @@ Typical value is 50% for + or X configuration on quads. - + @@ -2106,49 +2037,81 @@ p, li { white-space: pre-wrap; } - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Send to board, but don't save permanently (flash or SD). - - - Apply - - - - - - - Applies and Saves all settings to flash or SD depending on board. - - - Save - - - - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 32 + 32 + + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 32 + 32 + + + + true + + + + + + + Send to board, but don't save permanently (flash or SD). + + + Apply + + + + + + + Applies and Saves all settings to flash or SD depending on board. + + + Save + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui index ecabe8de1..b0ffec294 100644 --- a/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui +++ b/ground/openpilotgcs/src/plugins/config/cc_hw_settings.ui @@ -64,7 +64,7 @@ - Flexiport + FlexiPort Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft @@ -124,6 +124,25 @@ + + + + + 75 + true + + + + + + + Qt::AutoText + + + true + + + @@ -140,15 +159,9 @@ - + - - - - Qt::AutoText - - - true + Changes on this page require an Hw reboot to be applied diff --git a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp index eb11b872f..03296210b 100644 --- a/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_cc_hw_widget.cpp @@ -39,10 +39,10 @@ ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry = new Ui_CC_HW_Widget(); m_telemetry->setupUi(this); setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); - addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); - addObjectToWidget("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); - addObjectToWidget("HwSettings","CC_MainPort",m_telemetry->cbTele); - addObjectToWidget("ManualControlSettings","InputMode",m_telemetry->receiverType); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addUAVObjectToWidgetRelation("HwSettings","CC_FlexiPort",m_telemetry->cbFlexi); + addUAVObjectToWidgetRelation("HwSettings","CC_MainPort",m_telemetry->cbTele); + addUAVObjectToWidgetRelation("ManualControlSettings","InputMode",m_telemetry->receiverType); enableControls(false); populateWidgets(); refreshWidgetsValues(); @@ -59,26 +59,27 @@ void ConfigCCHWWidget::refreshValues() void ConfigCCHWWidget::widgetsContentsChanged() { + ConfigTaskWidget::widgetsContentsChanged(); enableControls(false); if((m_telemetry->cbFlexi->currentText()==m_telemetry->cbTele->currentText()) && m_telemetry->cbTele->currentText()!="Disabled") { - m_telemetry->problems->setText("Warning-You have configured the main port and the flexi port for the same function, this is currently not suported"); + m_telemetry->problems->setText("Warning: you have configured the MainPort and the FlexiPort for the same function, this is currently not suported"); } else if((m_telemetry->cbTele->currentText()=="Spektrum" ||m_telemetry->cbFlexi->currentText()=="Spektrum") && m_telemetry->receiverType->currentText()!="Spektrum") { - m_telemetry->problems->setText("Warning-You have at least one port configured as 'Spektrum' however thats not your selected input type"); + m_telemetry->problems->setText("Warning: you have at least one port configured as 'Spektrum' however that is not your selected input type"); } else if(m_telemetry->cbTele->currentText()=="S.Bus" && m_telemetry->receiverType->currentText()!="S.Bus") { - m_telemetry->problems->setText("Warning-You have at least one port configured as 'S.Bus' however thats not your selected input type"); + m_telemetry->problems->setText("Warning: you have at least one port configured as 'S.Bus' however that is not your selected input type"); } else if(m_telemetry->cbTele->currentText()!="S.Bus" && m_telemetry->receiverType->currentText()=="S.Bus") { - m_telemetry->problems->setText("Warning-You have at selected 'S.Bus' as your input type however you have no port configured for that protocol"); + m_telemetry->problems->setText("Warning: you have selected 'S.Bus' as your input type however you have no port configured for that protocol"); } else if((m_telemetry->cbTele->currentText()!="Spektrum" && m_telemetry->cbFlexi->currentText()!="Spektrum") && m_telemetry->receiverType->currentText()=="Spektrum") { - m_telemetry->problems->setText("Warning-You have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); + m_telemetry->problems->setText("Warning: you have at selected 'Spektrum' as your input type however you have no port configured for that protocol"); } else { diff --git a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp index cfe0741e4..b3f562acd 100644 --- a/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp +++ b/ground/openpilotgcs/src/plugins/config/config_pro_hw_widget.cpp @@ -40,7 +40,7 @@ ConfigProHWWidget::ConfigProHWWidget(QWidget *parent) : ConfigTaskWidget(parent) m_telemetry->setupUi(this); setupButtons(m_telemetry->saveTelemetryToRAM,m_telemetry->saveTelemetryToSD); - addObjectToWidget("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); + addUAVObjectToWidgetRelation("TelemetrySettings","Speed",m_telemetry->telemetrySpeed); enableControls(false); populateWidgets(); refreshWidgetsValues(); diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp index 0044afa62..dcf743915 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.cpp @@ -91,6 +91,32 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft = new Ui_AircraftWidget(); m_aircraft->setupUi(this); + setupButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD); + addWidget(m_aircraft->customMixerTable); + addWidget(m_aircraft->customThrottle2Curve); + addWidget(m_aircraft->customThrottle1Curve); + addWidget(m_aircraft->multiThrottleCurve); + addWidget(m_aircraft->fixedWingThrottle); + addWidget(m_aircraft->fixedWingType); + addWidget(m_aircraft->feedForwardSlider); + addWidget(m_aircraft->accelTime); + addWidget(m_aircraft->decelTime); + addWidget(m_aircraft->maxAccelSlider); + addWidget(m_aircraft->multirotorFrameType); + addWidget(m_aircraft->multiMotor1); + addWidget(m_aircraft->multiMotor2); + addWidget(m_aircraft->multiMotor3); + addWidget(m_aircraft->multiMotor4); + addWidget(m_aircraft->multiMotor5); + addWidget(m_aircraft->multiMotor6); + addWidget(m_aircraft->multiMotor7); + addWidget(m_aircraft->multiMotor8); + addWidget(m_aircraft->triYawChannel); + addUAVObject("SystemSettings"); + addUAVObject("MixerSettings"); + addUAVObject("ActuatorSettings"); + + ffTuningInProgress = false; ffTuningPhase = false; @@ -164,11 +190,6 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } - connect(m_aircraft->saveAircraftToSD, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->saveAircraftToRAM, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); - - connect(m_aircraft->ffSave, SIGNAL(clicked()), this, SLOT(saveAircraftUpdate())); - connect(m_aircraft->ffApply, SIGNAL(clicked()), this, SLOT(sendAircraftUpdate())); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -191,17 +212,8 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); enableControls(false); - refreshValues(); - connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); - connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect())); + refreshWidgetsValues(); - // Register for ManualControlSettings changes: - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues())); // Connect the help button connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); @@ -213,18 +225,6 @@ ConfigAirframeWidget::~ConfigAirframeWidget() // Do nothing } -/** - Enable or disable controls depending on whether we're ronnected or not - */ -void ConfigAirframeWidget::enableControls(bool enable) -{ - //m_aircraft->saveAircraftToRAM->setEnabled(enable); - m_aircraft->saveAircraftToSD->setEnabled(enable); - //m_aircraft->ffApply->setEnabled(enable); - m_aircraft->ffSave->setEnabled(enable); -} - - /** Slot for switching the airframe type. We do it explicitely rather than a signal in the UI, because we want to force a fitInView of the quad shapes. @@ -460,7 +460,7 @@ void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList list, d /** Refreshes the current value of the SystemSettings which holds the aircraft type */ -void ConfigAirframeWidget::refreshValues() +void ConfigAirframeWidget::refreshWidgetsValues() { // Get the Airframe type from the system settings: UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -665,10 +665,13 @@ void ConfigAirframeWidget::refreshValues() val = floor(-field->getDouble(i)/1.27); m_aircraft->mrYawMixLevel->setValue(val); eng = m_aircraft->multiMotor2->currentIndex()-1; - field = obj->getField(mixerVectors.at(eng)); - i = field->getElementNames().indexOf("Roll"); - val = floor(1-field->getDouble(i)/1.27); - m_aircraft->mrRollMixLevel->setValue(val); + if(eng>-1) + { + field = obj->getField(mixerVectors.at(eng)); + i = field->getElementNames().indexOf("Roll"); + val = floor(1-field->getDouble(i)/1.27); + m_aircraft->mrRollMixLevel->setValue(val); + } } } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW @@ -1817,8 +1820,9 @@ void ConfigAirframeWidget::updateCustomAirframeUI() we call additional methods for specific frames, so that we do not have a code that is too heavy. */ -void ConfigAirframeWidget::sendAircraftUpdate() +void ConfigAirframeWidget::updateObjectsFromWidgets() { + qDebug()<<"updateObjectsFromWidgets"; QString airframeType = "Custom"; if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { // Save the curve (common to all Fixed wing frames) @@ -2123,31 +2127,9 @@ void ConfigAirframeWidget::sendAircraftUpdate() } } - - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - obj->updated(); - obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); UAVObjectField* field = obj->getField(QString("AirframeType")); field->setValue(airframeType); - obj->updated(); -} - -/** - Send airframe type to the board and request saving to SD card - */ -void ConfigAirframeWidget::saveAircraftUpdate() -{ - // Send update so that the latest value is saved - sendAircraftUpdate(); - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(obj); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - saveObjectToSD(obj); - obj = dynamic_cast(getObjectManager()->getObject(QString("ActuatorSettings"))); - saveObjectToSD(obj); } diff --git a/ground/openpilotgcs/src/plugins/config/configairframewidget.h b/ground/openpilotgcs/src/plugins/config/configairframewidget.h index 5d9bfecc8..234a114c1 100644 --- a/ground/openpilotgcs/src/plugins/config/configairframewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configairframewidget.h @@ -58,7 +58,6 @@ private: void updateCustomAirframeUI(); bool setupMixer(double mixerFactors[8][3]); void setupMotors(QList motorList); - virtual void enableControls(bool enable); void resetField(UAVObjectField * field); void resetMixer (MixerCurveWidget *mixer, int numElements, double maxvalue); @@ -74,9 +73,9 @@ private: UAVObject::Metadata accInitialData; private slots: - virtual void refreshValues(); - void sendAircraftUpdate(); - void saveAircraftUpdate(); + virtual void refreshWidgetsValues(); + void updateObjectsFromWidgets(); + // void saveAircraftUpdate(); void setupAirframeUI(QString type); void toggleAileron2(int index); void toggleElevator2(int index); diff --git a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp index e0c0e7e45..80d36e46b 100644 --- a/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configinputwidget.cpp @@ -700,7 +700,7 @@ void ConfigInputWidget::receiverHelp() unassigned.append("FlightMode"); } if(unassigned.length()>0) - m_config->lblMissingInputs->setText(QString("Channels left to assign:")+unassigned); + m_config->lblMissingInputs->setText(QString("Channels left to assign: ")+unassigned); else m_config->lblMissingInputs->setText(""); } diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp index 15c79aa74..8fd35c596 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.cpp @@ -28,31 +28,69 @@ #include -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),smartsave(NULL),dirty(false) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect())); connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect())); } -void ConfigTaskWidget::addObjectToWidget(QString object, QString field, QWidget * widget) +void ConfigTaskWidget::addWidget(QWidget * widget) { - UAVObject *obj = objManager->getObject(QString(object)); + addUAVObjectToWidgetRelation("","",widget); +} +void ConfigTaskWidget::addUAVObject(QString objectName) +{ + addUAVObjectToWidgetRelation(objectName,"",NULL); +} +void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString field, QWidget * widget) +{ + UAVObject *obj=NULL; + UAVObjectField *_field=NULL; + if(!object.isEmpty()) + obj = objManager->getObject(QString(object)); connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); //smartsave->addObject(obj); - UAVObjectField *_field = obj->getField(QString(field)); + if(!field.isEmpty() && obj) + _field = obj->getField(QString(field)); objectToWidget * ow=new objectToWidget(); ow->field=_field; ow->object=obj; ow->widget=widget; objOfInterest.append(ow); - smartsave->addObject(obj); - if(QComboBox * cb=qobject_cast(widget)) + if(obj) + smartsave->addObject(obj); + if(widget==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(widget)) { connect(cb,SIGNAL(currentIndexChanged(int)),this,SLOT(widgetsContentsChanged())); } + else if(QSlider * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(sliderMoved(int)),this,SLOT(widgetsContentsChanged())); + } + else if(MixerCurveWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(curveUpdated(QList,double)),this,SLOT(widgetsContentsChanged())); + } + else if(QTableWidget * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(cellChanged(int,int)),this,SLOT(widgetsContentsChanged())); + } + else if(QSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(int)),this,SLOT(widgetsContentsChanged())); + } + else if(QDoubleSpinBox * cb=qobject_cast(widget)) + { + connect(cb,SIGNAL(valueChanged(double)),this,SLOT(widgetsContentsChanged())); + } } + ConfigTaskWidget::~ConfigTaskWidget() { delete smartsave; @@ -101,7 +139,11 @@ void ConfigTaskWidget::populateWidgets() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) + { + // do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) { cb->addItems(ow->field->getOptions()); cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); @@ -111,13 +153,18 @@ void ConfigTaskWidget::populateWidgets() cb->setText(ow->field->getValue().toString()); } } + dirty=false; } void ConfigTaskWidget::refreshWidgetsValues() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) + { + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) { cb->setCurrentIndex(cb->findText(ow->field->getValue().toString())); } @@ -132,9 +179,13 @@ void ConfigTaskWidget::updateObjectsFromWidgets() { foreach(objectToWidget * ow,objOfInterest) { - if(QComboBox * cb=qobject_cast(ow->widget)) + if(ow->object==NULL || ow->field==NULL) { - ow->field->setValue(cb->currentText()); + //do nothing + } + else if(QComboBox * cb=qobject_cast(ow->widget)) + { + ow->field->setValue(cb->currentText()); } else if(QLabel * cb=qobject_cast(ow->widget)) { @@ -147,6 +198,9 @@ void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save) { smartsave=new smartSaveButton(update,save); connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets())); + connect(smartsave,SIGNAL(saveSuccessfull()),this,SLOT(clearDirty())); + connect(smartsave,SIGNAL(beginOp()),this,SLOT(disableObjUpdates())); + connect(smartsave,SIGNAL(endOp()),this,SLOT(enableObjUpdates())); } void ConfigTaskWidget::enableControls(bool enable) @@ -157,8 +211,45 @@ void ConfigTaskWidget::enableControls(bool enable) void ConfigTaskWidget::widgetsContentsChanged() { + dirty=true; } +void ConfigTaskWidget::clearDirty() +{ + dirty=false; +} + +bool ConfigTaskWidget::isDirty() +{ + return dirty; +} + +void ConfigTaskWidget::refreshValues() +{ +} + +void ConfigTaskWidget::disableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + disconnect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + +void ConfigTaskWidget::enableObjUpdates() +{ + foreach(objectToWidget * obj,objOfInterest) + { + if(obj->object) + connect(obj->object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshWidgetsValues())); + } +} + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h index 0f439f3d1..bd293ce5f 100644 --- a/ground/openpilotgcs/src/plugins/config/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configtaskwidget.h @@ -37,6 +37,10 @@ #include #include #include "smartsavebutton.h" +#include "mixercurvewidget.h" +#include +#include +#include class ConfigTaskWidget: public QWidget { Q_OBJECT @@ -54,21 +58,28 @@ public: void saveObjectToSD(UAVObject *obj); UAVObjectManager* getObjectManager(); static double listMean(QList list); - void addObjectToWidget(QString object,QString field,QWidget * widget); + void addUAVObject(QString objectName); + void addWidget(QWidget * widget); + void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget); void setupButtons(QPushButton * update,QPushButton * save); + bool isDirty(); public slots: void onAutopilotDisconnect(); void onAutopilotConnect(); private slots: - virtual void refreshValues()=0; + virtual void refreshValues(); virtual void updateObjectsFromWidgets(); private: QList objOfInterest; ExtensionSystem::PluginManager *pm; UAVObjectManager *objManager; smartSaveButton *smartsave; + bool dirty; protected slots: + virtual void disableObjUpdates(); + virtual void enableObjUpdates(); + virtual void clearDirty(); virtual void widgetsContentsChanged(); virtual void populateWidgets(); virtual void refreshWidgetsValues(); diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp index f86c01b7e..720e06c15 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.cpp @@ -8,6 +8,7 @@ smartSaveButton::smartSaveButton(QPushButton * update, QPushButton * save):bupda } void smartSaveButton::processClick() { + emit beginOp(); bool save=false; QPushButton *button=bupdate; if(sender()==bsave) @@ -23,6 +24,7 @@ void smartSaveButton::processClick() bool error=false; ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectUtilManager* utilMngr = pm->getObject(); + qDebug()<<"smartbutton:save"; foreach(UAVObject * obj,objects) { up_result=false; @@ -73,11 +75,13 @@ void smartSaveButton::processClick() if(!error) { button->setIcon(QIcon(":/uploader/images/dialog-apply.svg")); + emit saveSuccessfull(); } else { button->setIcon(QIcon(":/uploader/images/process-stop.svg")); } + emit endOp(); } void smartSaveButton::setObjects(QList list) diff --git a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h index dd77967dd..d0238d034 100644 --- a/ground/openpilotgcs/src/plugins/config/smartsavebutton.h +++ b/ground/openpilotgcs/src/plugins/config/smartsavebutton.h @@ -10,6 +10,7 @@ #include #include "uavobjectutilmanager.h" #include +#include class smartSaveButton:public QObject { public: @@ -21,6 +22,9 @@ public: void clearObjects(); signals: void preProcessOperations(); + void saveSuccessfull(); + void beginOp(); + void endOp(); private slots: void processClick(); void transaction_finished(UAVObject* obj, bool result);