1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

LP-245 config: fixed spurious unsaved data prompts in GCS config gadget

This commit is contained in:
Philippe Renon 2016-09-01 23:15:10 +02:00
parent 78b8580613
commit c9d7761f0e
23 changed files with 122 additions and 66 deletions

View File

@ -120,9 +120,9 @@ QString VehicleConfig::updateConfigObjectsFromWidgets()
return NULL;
}
void VehicleConfig::refreshWidgetsValues(UAVObject *o)
void VehicleConfig::refreshWidgetsValues(UAVObject *obj)
{
Q_UNUSED(o);
Q_UNUSED(obj);
}
void VehicleConfig::updateObjectsFromWidgets()

View File

@ -245,7 +245,7 @@ protected:
double getCurveMax(QList<double> *curve);
protected slots:
virtual void refreshWidgetsValues(UAVObject *o = NULL);
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private:

View File

@ -148,19 +148,25 @@ void ConfigAutotuneWidget::recomputeStabilization()
m_autotune->pitchAttitudeKp->setText(QString().number(stabSettings.PitchPI[StabilizationSettings::PITCHPI_KP]));
m_autotune->pitchAttitudeKi->setText(QString().number(stabSettings.PitchPI[StabilizationSettings::PITCHPI_KI]));
}
void ConfigAutotuneWidget::refreshWidgetsValues(UAVObject *obj)
{
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
if (obj == hwSettings) {
bool dirtyBack = isDirty();
HwSettings::DataFields hwSettingsData = hwSettings->getData();
m_autotune->enableAutoTune->setChecked(
hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_AUTOTUNE] == HwSettings::OPTIONALMODULES_ENABLED);
setDirty(dirtyBack);
}
ConfigTaskWidget::refreshWidgetsValues(obj);
setRefreshing(false);
}
void ConfigAutotuneWidget::updateObjectsFromWidgets()
{
HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());

View File

@ -52,9 +52,10 @@ private:
signals:
public slots:
void refreshWidgetsValues(UAVObject *obj);
void updateObjectsFromWidgets();
protected slots:
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void recomputeStabilization();
void saveStabilization();

View File

@ -119,7 +119,10 @@ ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget()
*/
void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj)
{
bool dirty = isDirty();
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
// Set module enable checkbox from OptionalModules UAVObject item.
// It needs special processing because ConfigTaskWidget uses TRUE/FALSE
@ -169,9 +172,7 @@ void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj)
}
}
setDirty(dirty);
ConfigTaskWidget::refreshWidgetsValues(obj);
setRefreshing(false);
}
/*

View File

@ -45,8 +45,10 @@ public:
private:
Ui_CameraStabilizationWidget *ui;
void refreshWidgetsValues(UAVObject *obj);
void updateObjectsFromWidgets();
protected slots:
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void defaultRequestedSlot(int group);

View File

@ -144,7 +144,8 @@ void ConfigCCAttitudeWidget::sensorsUpdated(UAVObject *obj)
attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_TRUE;
AttitudeSettings::GetInstance(getObjectManager())->setData(attitudeSettingsData);
AccelGyroSettings::GetInstance(getObjectManager())->setData(accelGyroSettingsData);
this->setDirty(true);
setDirty(true);
// reenable controls
enableControls(true);

View File

@ -316,10 +316,11 @@ void ConfigOutputWidget::setColor(QWidget *widget, const QColor color)
*/
void ConfigOutputWidget::refreshWidgetsValues(UAVObject *obj)
{
bool dirty = isDirty();
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
// Get Actuator Settings
ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager());
@ -423,7 +424,7 @@ void ConfigOutputWidget::refreshWidgetsValues(UAVObject *obj)
updateSpinStabilizeCheckComboBoxes();
setDirty(dirty);
setRefreshing(false);
}
/**

View File

@ -102,13 +102,15 @@ private:
void setColor(QWidget *widget, const QColor color);
void sendAllChannelTests();
protected slots:
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void updateWarnings(UAVObject *);
void updateSpinStabilizeCheckComboBoxes();
void updateAlwaysStabilizeStatus();
void stopTests();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
void updateObjectsFromWidgets();
void runChannelTests(bool state);
void sendChannelTest(int index, int value);
void openHelp();

View File

@ -40,7 +40,7 @@
#include <QUrl>
#include <QMessageBox>
ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(parent), m_refreshing(true)
ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_ui = new Ui_RevoHWWidget();
m_ui->setupUi(this);
@ -82,7 +82,6 @@ ConfigRevoHWWidget::ConfigRevoHWWidget(QWidget *parent) : ConfigTaskWidget(paren
populateWidgets();
refreshWidgetsValues();
forceConnectedState();
m_refreshing = false;
}
ConfigRevoHWWidget::~ConfigRevoHWWidget()
@ -106,14 +105,17 @@ void ConfigRevoHWWidget::setupCustomCombos()
void ConfigRevoHWWidget::refreshWidgetsValues(UAVObject *obj)
{
m_refreshing = true;
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
usbVCPPortChanged(0);
mainPortChanged(0);
flexiPortChanged(0);
rcvrPortChanged(0);
m_refreshing = false;
setRefreshing(false);
}
void ConfigRevoHWWidget::updateObjectsFromWidgets()

View File

@ -44,12 +44,12 @@ public:
private:
Ui_RevoHWWidget *m_ui;
bool m_refreshing;
void setupCustomCombos();
protected slots:
void refreshWidgetsValues(UAVObject *obj = NULL);
void updateObjectsFromWidgets();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void usbVCPPortChanged(int index);

View File

@ -40,7 +40,7 @@
#include <QUrl>
#include <QMessageBox>
ConfigRevoNanoHWWidget::ConfigRevoNanoHWWidget(QWidget *parent) : ConfigTaskWidget(parent), m_refreshing(true)
ConfigRevoNanoHWWidget::ConfigRevoNanoHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_ui = new Ui_RevoNanoHWWidget();
m_ui->setupUi(this);
@ -79,7 +79,6 @@ ConfigRevoNanoHWWidget::ConfigRevoNanoHWWidget(QWidget *parent) : ConfigTaskWidg
populateWidgets();
refreshWidgetsValues();
setDirty(false);
m_refreshing = false;
}
ConfigRevoNanoHWWidget::~ConfigRevoNanoHWWidget()
@ -99,14 +98,17 @@ void ConfigRevoNanoHWWidget::setupCustomCombos()
void ConfigRevoNanoHWWidget::refreshWidgetsValues(UAVObject *obj)
{
m_refreshing = true;
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
usbVCPPortChanged(0);
mainPortChanged(0);
flexiPortChanged(0);
rcvrPortChanged(0);
m_refreshing = false;
setRefreshing(false);
}
void ConfigRevoNanoHWWidget::updateObjectsFromWidgets()

View File

@ -44,12 +44,11 @@ public:
private:
Ui_RevoNanoHWWidget *m_ui;
bool m_refreshing;
void setupCustomCombos();
protected slots:
void refreshWidgetsValues(UAVObject *obj = NULL);
void updateObjectsFromWidgets();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void usbVCPPortChanged(int index);

View File

@ -414,9 +414,12 @@ void ConfigRevoWidget::displayTemperatureRange(float temperatureRange)
* Called by the ConfigTaskWidget parent when RevoCalibration is updated
* to update the UI
*/
void ConfigRevoWidget::refreshWidgetsValues(UAVObject *object)
void ConfigRevoWidget::refreshWidgetsValues(UAVObject *obj)
{
ConfigTaskWidget::refreshWidgetsValues(object);
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
m_ui->isSetCheckBox->setEnabled(false);
@ -429,6 +432,8 @@ void ConfigRevoWidget::refreshWidgetsValues(UAVObject *object)
updateMagBeVector();
onBoardAuxMagError();
setRefreshing(false);
}
void ConfigRevoWidget::updateObjectsFromWidgets()

View File

@ -73,6 +73,10 @@ private:
int auxMagWarningCount;
int auxMagErrorCount;
protected slots:
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void storeAndClearBoardRotation();
void recallBoardRotation();
@ -83,10 +87,6 @@ private slots:
void displayTemperatureGradient(float temparetureGradient);
void displayTemperatureRange(float temparetureRange);
// ! Overriden method from the configTaskWidget to update UI
virtual void refreshWidgetsValues(UAVObject *object = NULL);
virtual void updateObjectsFromWidgets();
// Slot for clearing home location
void clearHomeLocation();

View File

@ -40,7 +40,7 @@
#include <QUrl>
#include <QMessageBox>
ConfigSparky2HWWidget::ConfigSparky2HWWidget(QWidget *parent) : ConfigTaskWidget(parent), m_refreshing(true)
ConfigSparky2HWWidget::ConfigSparky2HWWidget(QWidget *parent) : ConfigTaskWidget(parent)
{
m_ui = new Ui_Sparky2HWWidget();
m_ui->setupUi(this);
@ -79,7 +79,6 @@ ConfigSparky2HWWidget::ConfigSparky2HWWidget(QWidget *parent) : ConfigTaskWidget
populateWidgets();
refreshWidgetsValues();
forceConnectedState();
m_refreshing = false;
}
ConfigSparky2HWWidget::~ConfigSparky2HWWidget()
@ -102,13 +101,16 @@ void ConfigSparky2HWWidget::setupCustomCombos()
void ConfigSparky2HWWidget::refreshWidgetsValues(UAVObject *obj)
{
m_refreshing = true;
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
usbVCPPortChanged(0);
mainPortChanged(0);
flexiPortChanged(0);
m_refreshing = false;
setRefreshing(false);
}
void ConfigSparky2HWWidget::updateObjectsFromWidgets()

View File

@ -45,12 +45,12 @@ public:
private:
Ui_Sparky2HWWidget *m_ui;
bool m_refreshing;
void setupCustomCombos();
protected slots:
void refreshWidgetsValues(UAVObject *obj = NULL);
void updateObjectsFromWidgets();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void usbVCPPortChanged(int index);

View File

@ -247,9 +247,12 @@ ConfigStabilizationWidget::~ConfigStabilizationWidget()
// Do nothing
}
void ConfigStabilizationWidget::refreshWidgetsValues(UAVObject *o)
void ConfigStabilizationWidget::refreshWidgetsValues(UAVObject *obj)
{
ConfigTaskWidget::refreshWidgetsValues(o);
ConfigTaskWidget::refreshWidgetsValues(obj);
// make sure to unset at the end
setRefreshing(true);
updateThrottleCurveFromObject();
@ -267,6 +270,8 @@ void ConfigStabilizationWidget::refreshWidgetsValues(UAVObject *o)
ui->advancedResponsivenessCheckBox->setChecked(true);
}
}
setRefreshing(false);
}
void ConfigStabilizationWidget::updateObjectsFromWidgets()

View File

@ -90,8 +90,8 @@ protected:
QString mapObjectName(const QString objectName);
protected slots:
void refreshWidgetsValues(UAVObject *o = NULL);
void updateObjectsFromWidgets();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private slots:
void realtimeUpdatesSlot(bool value);

View File

@ -178,15 +178,16 @@ void ConfigVehicleTypeWidget::switchAirframeType(int index)
Note: The default behavior of ConfigTaskWidget is bypassed.
Therefore no automatic synchronization of UAV Objects to UI is done.
*/
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *object)
void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *obj)
{
ConfigTaskWidget::refreshWidgetsValues(object);
ConfigTaskWidget::refreshWidgetsValues(obj);
if (!allObjectsUpdated()) {
return;
}
bool dirty = isDirty();
// make sure to unset at the end
setRefreshing(true);
// Get the Airframe type from the system settings:
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
@ -234,7 +235,7 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *object)
}
m_aircraft->nameEdit->setText(name);
setDirty(dirty);
setRefreshing(false);
}
/**

View File

@ -65,7 +65,7 @@ public:
~ConfigVehicleTypeWidget();
protected slots:
virtual void refreshWidgetsValues(UAVObject *object = NULL);
virtual void refreshWidgetsValues(UAVObject *obj = NULL);
virtual void updateObjectsFromWidgets();
private:

View File

@ -46,8 +46,8 @@
#include <QUrl>
#include <QWidget>
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), m_currentBoardId(-1), m_isConnected(false), m_isWidgetUpdatesAllowed(true), m_wikiURL("Welcome"),
m_saveButton(NULL), m_isDirty(false), m_outOfLimitsStyle("background-color: rgb(255, 0, 0);"), m_realtimeUpdateTimer(NULL)
ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent), m_currentBoardId(-1), m_isConnected(false), m_isWidgetUpdatesAllowed(true), m_isDirty(false), m_refreshing(false),
m_wikiURL("Welcome"), m_saveButton(NULL), m_outOfLimitsStyle("background-color: rgb(255, 0, 0);"), m_realtimeUpdateTimer(NULL)
{
m_pluginManager = ExtensionSystem::PluginManager::instance();
TelemetryManager *telMngr = m_pluginManager->getObject<TelemetryManager>();
@ -190,7 +190,8 @@ void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool en
Q_ASSERT(object);
bool dirtyBack = isDirty();
// make sure to unset at the end
setRefreshing(true);
foreach(WidgetBinding * binding, m_widgetBindingsPerObject.values(object)) {
binding->setIsEnabled(enabled);
@ -202,7 +203,8 @@ void ConfigTaskWidget::setWidgetBindingObjectEnabled(QString objectName, bool en
}
}
}
setDirty(dirtyBack);
setRefreshing(false);
}
ConfigTaskWidget::~ConfigTaskWidget()
@ -325,7 +327,8 @@ void ConfigTaskWidget::onAutopilotConnect()
void ConfigTaskWidget::populateWidgets()
{
bool dirtyBack = isDirty();
setRefreshing(true);
emit populateWidgetsRequested();
foreach(WidgetBinding * binding, m_widgetBindingsPerObject) {
@ -333,7 +336,8 @@ void ConfigTaskWidget::populateWidgets()
setWidgetFromField(binding->widget(), binding->field(), binding);
}
}
setDirty(dirtyBack);
setRefreshing(false);
}
void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
@ -342,7 +346,9 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
return;
}
bool dirtyBack = isDirty();
// make sure to unset at the end
setRefreshing(true);
emit refreshWidgetsValuesRequested();
QList<WidgetBinding *> bindings = obj == NULL ? m_widgetBindingsPerObject.values() : m_widgetBindingsPerObject.values(obj);
foreach(WidgetBinding * binding, bindings) {
@ -354,7 +360,8 @@ void ConfigTaskWidget::refreshWidgetsValues(UAVObject *obj)
}
}
}
setDirty(dirtyBack);
setRefreshing(false);
}
void ConfigTaskWidget::updateObjectsFromWidgets()
@ -510,6 +517,9 @@ void ConfigTaskWidget::clearDirty()
void ConfigTaskWidget::setDirty(bool value)
{
if (isRefreshing()) {
return;
}
m_isDirty = value;
}
@ -542,6 +552,16 @@ void ConfigTaskWidget::enableObjectUpdates()
}
}
bool ConfigTaskWidget::isRefreshing()
{
return m_refreshing;
}
void ConfigTaskWidget::setRefreshing(bool refreshing)
{
m_refreshing = refreshing;
}
void ConfigTaskWidget::objectUpdated(UAVObject *object)
{
m_updatedObjects[object] = true;

View File

@ -211,8 +211,12 @@ private:
};
int m_currentBoardId;
bool m_isConnected;
bool m_isWidgetUpdatesAllowed;
bool m_isDirty;
bool m_refreshing;
QStringList m_objects;
QString m_wikiURL; // Wiki address for help button
// Concatenated with WIKI_URL_ROOT
@ -227,7 +231,7 @@ private:
QHash<UAVObject *, bool> m_updatedObjects;
QHash<QPushButton *, QString> m_helpButtons;
QList<QPushButton *> m_reloadButtons;
bool m_isDirty;
QString m_outOfLimitsStyle;
QTimer *m_realtimeUpdateTimer;
@ -250,6 +254,8 @@ protected slots:
virtual void disableObjectUpdates();
virtual void enableObjectUpdates();
virtual void clearDirty();
bool isRefreshing();
void setRefreshing(bool refreshing);
virtual void widgetsContentsChanged();
virtual void populateWidgets();
virtual void refreshWidgetsValues(UAVObject *obj = NULL);