mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
LP-467 config: refresh widgets upon successful save
fixed an issue with custom mixer table not set to editable when saving as Custom frame type
This commit is contained in:
parent
ad59634b4f
commit
b13807b2b6
@ -283,7 +283,7 @@ void ConfigGadgetWidget::tabAboutToChange(int index, bool *proceed)
|
||||
if (ans == QMessageBox::No) {
|
||||
*proceed = false;
|
||||
} else {
|
||||
wid->setDirty(false);
|
||||
wid->clearDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,10 +64,10 @@ ConfigTaskWidget::ConfigTaskWidget(QWidget *parent, ConfigTaskType configType) :
|
||||
connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(invalidateObjects()));
|
||||
|
||||
m_saveButton = new SmartSaveButton(this);
|
||||
connect(m_saveButton, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets()));
|
||||
connect(m_saveButton, SIGNAL(saveSuccessfull()), this, SLOT(clearDirty()));
|
||||
connect(m_saveButton, SIGNAL(beginOp()), this, SLOT(disableObjectUpdates()));
|
||||
connect(m_saveButton, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets()));
|
||||
connect(m_saveButton, SIGNAL(endOp()), this, SLOT(enableObjectUpdates()));
|
||||
connect(m_saveButton, SIGNAL(saveSuccessful()), this, SLOT(saveSuccessful()));
|
||||
}
|
||||
|
||||
switch (m_configType) {
|
||||
@ -424,6 +424,14 @@ void ConfigTaskWidget::updateObjectsFromWidgets()
|
||||
updateObjectsFromWidgetsImpl();
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::saveSuccessful()
|
||||
{
|
||||
// refresh values to reflect saved values
|
||||
refreshWidgetsValues(NULL);
|
||||
clearDirty();
|
||||
// in case of failure to save we do nothing, config stays "dirty" (unsaved changes are kept)
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::helpButtonPressed()
|
||||
{
|
||||
QString url = m_helpButtons.value((QPushButton *)sender(), QString());
|
||||
@ -526,9 +534,9 @@ void ConfigTaskWidget::widgetsContentsChanged()
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::clearDirty()
|
||||
bool ConfigTaskWidget::isDirty()
|
||||
{
|
||||
m_isDirty = false;
|
||||
return m_isConnected ? m_isDirty : false;
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::setDirty(bool value)
|
||||
@ -539,9 +547,9 @@ void ConfigTaskWidget::setDirty(bool value)
|
||||
m_isDirty = value;
|
||||
}
|
||||
|
||||
bool ConfigTaskWidget::isDirty()
|
||||
void ConfigTaskWidget::clearDirty()
|
||||
{
|
||||
return m_isConnected ? m_isDirty : false;
|
||||
m_isDirty = false;
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::disableObjectUpdates()
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
|
||||
bool isDirty();
|
||||
void setDirty(bool value);
|
||||
void clearDirty();
|
||||
|
||||
virtual bool shouldObjectBeSaved(UAVObject *object);
|
||||
|
||||
@ -192,7 +193,6 @@ protected:
|
||||
protected slots:
|
||||
void setWidgetBindingObjectEnabled(QString objectName, bool enabled);
|
||||
|
||||
void clearDirty();
|
||||
virtual void widgetsContentsChanged();
|
||||
void refreshWidgetsValues(UAVObject *obj = NULL);
|
||||
void updateObjectsFromWidgets();
|
||||
@ -206,6 +206,8 @@ private slots:
|
||||
void objectUpdated(UAVObject *object);
|
||||
void invalidateObjects();
|
||||
|
||||
void saveSuccessful();
|
||||
|
||||
void defaultButtonClicked();
|
||||
void reloadButtonClicked();
|
||||
void helpButtonPressed();
|
||||
|
@ -139,20 +139,18 @@ void SmartSaveButton::processOperation(QPushButton *button, bool save)
|
||||
}
|
||||
}
|
||||
}
|
||||
emit endOp();
|
||||
if (!error) {
|
||||
emit saveSuccessful();
|
||||
}
|
||||
if (button) {
|
||||
button->setEnabled(true);
|
||||
}
|
||||
if (!error) {
|
||||
if (button) {
|
||||
if (!error) {
|
||||
button->setIcon(QIcon(":/uploader/images/dialog-apply.svg"));
|
||||
}
|
||||
emit saveSuccessfull();
|
||||
} else {
|
||||
if (button) {
|
||||
} else {
|
||||
button->setIcon(QIcon(":/uploader/images/process-stop.svg"));
|
||||
}
|
||||
}
|
||||
emit endOp();
|
||||
}
|
||||
|
||||
void SmartSaveButton::setObjects(QList<UAVDataObject *> list)
|
||||
|
@ -57,7 +57,7 @@ public:
|
||||
|
||||
signals:
|
||||
void preProcessOperations();
|
||||
void saveSuccessfull();
|
||||
void saveSuccessful();
|
||||
void beginOp();
|
||||
void endOp();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user