mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Added "changes not saved" message warning to config gadget
This commit is contained in:
parent
cdf4d112ce
commit
1b34376797
@ -92,7 +92,7 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p
|
||||
m_aircraft->setupUi(this);
|
||||
|
||||
setupButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
|
||||
addToDirtyMonitor();
|
||||
|
||||
addUAVObject("SystemSettings");
|
||||
addUAVObject("MixerSettings");
|
||||
addUAVObject("ActuatorSettings");
|
||||
@ -198,7 +198,7 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p
|
||||
|
||||
// Connect the help button
|
||||
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
|
||||
addToDirtyMonitor();
|
||||
}
|
||||
|
||||
ConfigAirframeWidget::~ConfigAirframeWidget()
|
||||
@ -443,6 +443,7 @@ void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList<double> list, d
|
||||
*/
|
||||
void ConfigAirframeWidget::refreshWidgetsValues()
|
||||
{
|
||||
bool dirty=isDirty();
|
||||
// Get the Airframe type from the system settings:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(obj);
|
||||
@ -894,6 +895,7 @@ void ConfigAirframeWidget::refreshWidgetsValues()
|
||||
}
|
||||
|
||||
updateCustomAirframeUI();
|
||||
setDirty(dirty);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -902,6 +904,7 @@ void ConfigAirframeWidget::refreshWidgetsValues()
|
||||
*/
|
||||
void ConfigAirframeWidget::setupAirframeUI(QString frameType)
|
||||
{
|
||||
bool dirty=isDirty();
|
||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
|
||||
// Setup the UI
|
||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||
@ -1099,6 +1102,7 @@ void ConfigAirframeWidget::setupAirframeUI(QString frameType)
|
||||
}
|
||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||
setDirty(dirty);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -40,22 +40,21 @@ ConfigCCAttitudeWidget::ConfigCCAttitudeWidget(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->zeroBias,SIGNAL(clicked()),this,SLOT(startAccelCalibration()));
|
||||
connect(ui->saveButton,SIGNAL(clicked()),this,SLOT(saveAttitudeSettings()));
|
||||
connect(ui->applyButton,SIGNAL(clicked()),this,SLOT(applyAttitudeSettings()));
|
||||
|
||||
// Make it smart:
|
||||
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect()));
|
||||
connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()));
|
||||
|
||||
enableControls(true);
|
||||
refreshValues(); // The 1st time this panel is instanciated, the autopilot is already connected.
|
||||
setupButtons(ui->applyButton,ui->saveButton);
|
||||
addUAVObject("AttitudeSettings");
|
||||
|
||||
refreshWidgetsValues(); // The 1st time this panel is instanciated, the autopilot is already connected.
|
||||
UAVObject * settings = AttitudeSettings::GetInstance(getObjectManager());
|
||||
connect(settings,SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues()));
|
||||
|
||||
// Connect the help button
|
||||
connect(ui->ccAttitudeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
|
||||
|
||||
addWidget(ui->rollBias);
|
||||
addWidget(ui->pitchBias);
|
||||
addWidget(ui->yawBias);
|
||||
addWidget(ui->zeroBias);
|
||||
addWidget(ui->zeroGyroBiasOnArming);
|
||||
}
|
||||
|
||||
ConfigCCAttitudeWidget::~ConfigCCAttitudeWidget()
|
||||
@ -63,12 +62,6 @@ ConfigCCAttitudeWidget::~ConfigCCAttitudeWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::enableControls(bool enable)
|
||||
{
|
||||
//ui->applyButton->setEnabled(enable);
|
||||
ui->saveButton->setEnabled(enable);
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::attitudeRawUpdated(UAVObject * obj) {
|
||||
QMutexLocker locker(&startStop);
|
||||
|
||||
@ -130,7 +123,7 @@ void ConfigCCAttitudeWidget::timeout() {
|
||||
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::applyAttitudeSettings() {
|
||||
void ConfigCCAttitudeWidget::updateObjectsFromWidgets() {
|
||||
AttitudeSettings::DataFields attitudeSettingsData = AttitudeSettings::GetInstance(getObjectManager())->getData();
|
||||
attitudeSettingsData.BoardRotation[AttitudeSettings::BOARDROTATION_ROLL] = ui->rollBias->value();
|
||||
attitudeSettingsData.BoardRotation[AttitudeSettings::BOARDROTATION_PITCH] = ui->pitchBias->value();
|
||||
@ -140,14 +133,15 @@ void ConfigCCAttitudeWidget::applyAttitudeSettings() {
|
||||
AttitudeSettings::GetInstance(getObjectManager())->setData(attitudeSettingsData);
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::refreshValues() {
|
||||
void ConfigCCAttitudeWidget::refreshWidgetsValues() {
|
||||
bool dirty=isDirty();
|
||||
AttitudeSettings::DataFields attitudeSettingsData = AttitudeSettings::GetInstance(getObjectManager())->getData();
|
||||
|
||||
ui->rollBias->setValue(attitudeSettingsData.BoardRotation[0]);
|
||||
ui->pitchBias->setValue(attitudeSettingsData.BoardRotation[1]);
|
||||
ui->yawBias->setValue(attitudeSettingsData.BoardRotation[2]);
|
||||
ui->zeroGyroBiasOnArming->setChecked(attitudeSettingsData.ZeroDuringArming == AttitudeSettings::ZERODURINGARMING_TRUE);
|
||||
|
||||
setDirty(dirty);
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::startAccelCalibration() {
|
||||
@ -184,13 +178,6 @@ void ConfigCCAttitudeWidget::startAccelCalibration() {
|
||||
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::saveAttitudeSettings() {
|
||||
applyAttitudeSettings();
|
||||
|
||||
UAVDataObject * obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("AttitudeSettings")));
|
||||
saveObjectToSD(obj);
|
||||
}
|
||||
|
||||
void ConfigCCAttitudeWidget::openHelp()
|
||||
{
|
||||
|
||||
|
@ -50,9 +50,8 @@ private slots:
|
||||
void attitudeRawUpdated(UAVObject * obj);
|
||||
void timeout();
|
||||
void startAccelCalibration();
|
||||
void saveAttitudeSettings();
|
||||
void applyAttitudeSettings();
|
||||
virtual void refreshValues();
|
||||
void updateObjectsFromWidgets();
|
||||
virtual void refreshWidgetsValues();
|
||||
void openHelp();
|
||||
|
||||
private:
|
||||
@ -69,7 +68,6 @@ private:
|
||||
|
||||
static const int NUM_ACCEL_UPDATES = 60;
|
||||
static const float ACCEL_SCALE = 0.004f * 9.81f;
|
||||
virtual void enableControls(bool enable);
|
||||
|
||||
};
|
||||
|
||||
|
@ -99,6 +99,8 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
onAutopilotConnect();
|
||||
|
||||
help = 0;
|
||||
connect(ftw->m_tabBar,SIGNAL(aboutToChange(bool*)),this,SLOT(tabAboutToChange(bool*)));//,Qt::BlockingQueuedConnection);
|
||||
|
||||
}
|
||||
|
||||
ConfigGadgetWidget::~ConfigGadgetWidget()
|
||||
@ -153,5 +155,23 @@ void ConfigGadgetWidget::onAutopilotConnect() {
|
||||
emit autopilotConnected();
|
||||
}
|
||||
|
||||
void ConfigGadgetWidget::tabAboutToChange(bool * proceed)
|
||||
{
|
||||
*proceed=true;
|
||||
ConfigTaskWidget * wid=qobject_cast<ConfigTaskWidget *>(ftw->currentWidget());
|
||||
if(!wid)
|
||||
return;
|
||||
if(wid->isDirty())
|
||||
{
|
||||
int ans=QMessageBox::warning(this,tr("Unsaved changes"),tr("The tab you are leaving has unsaved changes,"
|
||||
"if you proceed they will be lost."
|
||||
"Do you still want to proceed?"),QMessageBox::Yes,QMessageBox::No);
|
||||
if(ans==QMessageBox::No)
|
||||
*proceed=false;
|
||||
else
|
||||
wid->setDirty(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -37,9 +37,9 @@
|
||||
//#include <QtWebKit/QWebView>
|
||||
#include <QTextBrowser>
|
||||
#include "utils/pathutils.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include "fancytabwidget.h"
|
||||
|
||||
#include "configtaskwidget.h"
|
||||
|
||||
class ConfigGadgetWidget: public QWidget
|
||||
{
|
||||
@ -54,6 +54,7 @@ public:
|
||||
public slots:
|
||||
void onAutopilotConnect();
|
||||
void onAutopilotDisconnect();
|
||||
void tabAboutToChange(bool *);
|
||||
|
||||
signals:
|
||||
void autopilotConnected();
|
||||
|
@ -46,6 +46,8 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
setupButtons(m_config->saveRCOutputToRAM,m_config->saveRCOutputToSD);
|
||||
addUAVObject("ActuatorSettings");
|
||||
|
||||
// First of all, put all the channel widgets into lists, so that we can
|
||||
// manipulate those:
|
||||
@ -106,10 +108,7 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
<< m_config->ch7Link;
|
||||
|
||||
// Register for ActuatorSettings changes:
|
||||
UAVDataObject * obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings")));
|
||||
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues()));
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
connect(outMin[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange()));
|
||||
connect(outMax[i], SIGNAL(editingFinished()), this, SLOT(setChOutRange()));
|
||||
connect(reversals[i], SIGNAL(toggled(bool)), this, SLOT(reverseChannel(bool)));
|
||||
@ -124,13 +123,8 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
for (int i = 0; i < links.count(); i++)
|
||||
connect(links[i], SIGNAL(toggled(bool)), this, SLOT(linkToggled(bool)));
|
||||
|
||||
connect(m_config->saveRCOutputToSD, SIGNAL(clicked()), this, SLOT(saveRCOutputObject()));
|
||||
connect(m_config->saveRCOutputToRAM, SIGNAL(clicked()), this, SLOT(sendRCOutputUpdate()));
|
||||
|
||||
enableControls(false);
|
||||
refreshValues();
|
||||
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect()));
|
||||
connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()));
|
||||
refreshWidgetsValues();
|
||||
|
||||
firstUpdate = true;
|
||||
|
||||
@ -138,6 +132,43 @@ ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(paren
|
||||
|
||||
// Connect the help button
|
||||
connect(m_config->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
addWidget(m_config->outputRate3);
|
||||
addWidget(m_config->outputRate2);
|
||||
addWidget(m_config->outputRate1);
|
||||
addWidget(m_config->ch0OutMin);
|
||||
addWidget(m_config->ch0OutSlider);
|
||||
addWidget(m_config->ch0OutMax);
|
||||
addWidget(m_config->ch0Rev);
|
||||
addWidget(m_config->ch0Link);
|
||||
addWidget(m_config->ch1OutMin);
|
||||
addWidget(m_config->ch1OutSlider);
|
||||
addWidget(m_config->ch1OutMax);
|
||||
addWidget(m_config->ch1Rev);
|
||||
addWidget(m_config->ch2OutMin);
|
||||
addWidget(m_config->ch2OutSlider);
|
||||
addWidget(m_config->ch2OutMax);
|
||||
addWidget(m_config->ch2Rev);
|
||||
addWidget(m_config->ch3OutMin);
|
||||
addWidget(m_config->ch3OutSlider);
|
||||
addWidget(m_config->ch3OutMax);
|
||||
addWidget(m_config->ch3Rev);
|
||||
addWidget(m_config->ch4OutMin);
|
||||
addWidget(m_config->ch4OutSlider);
|
||||
addWidget(m_config->ch4OutMax);
|
||||
addWidget(m_config->ch4Rev);
|
||||
addWidget(m_config->ch5OutMin);
|
||||
addWidget(m_config->ch5OutSlider);
|
||||
addWidget(m_config->ch5OutMax);
|
||||
addWidget(m_config->ch5Rev);
|
||||
addWidget(m_config->ch6OutMin);
|
||||
addWidget(m_config->ch6OutSlider);
|
||||
addWidget(m_config->ch6OutMax);
|
||||
addWidget(m_config->ch6Rev);
|
||||
addWidget(m_config->ch7OutMin);
|
||||
addWidget(m_config->ch7OutSlider);
|
||||
addWidget(m_config->ch7OutMax);
|
||||
addWidget(m_config->ch7Rev);
|
||||
addWidget(m_config->spinningArmed);
|
||||
}
|
||||
|
||||
ConfigOutputWidget::~ConfigOutputWidget()
|
||||
@ -146,14 +177,6 @@ ConfigOutputWidget::~ConfigOutputWidget()
|
||||
}
|
||||
|
||||
|
||||
// ************************************
|
||||
|
||||
void ConfigOutputWidget::enableControls(bool enable)
|
||||
{
|
||||
m_config->saveRCOutputToSD->setEnabled(enable);
|
||||
//m_config->saveRCOutputToRAM->setEnabled(enable);
|
||||
}
|
||||
|
||||
// ************************************
|
||||
|
||||
/**
|
||||
@ -355,8 +378,9 @@ void ConfigOutputWidget::sendChannelTest(int value)
|
||||
/**
|
||||
Request the current config from the board (RC Output)
|
||||
*/
|
||||
void ConfigOutputWidget::refreshValues()
|
||||
void ConfigOutputWidget::refreshWidgetsValues()
|
||||
{
|
||||
bool dirty=isDirty();
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
@ -444,14 +468,14 @@ void ConfigOutputWidget::refreshValues()
|
||||
outSliders[i]->setValue(value);
|
||||
outLabels[i]->setText(QString::number(value));
|
||||
}
|
||||
|
||||
setDirty(dirty);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the config to the board, without saving to the SD card (RC Output)
|
||||
*/
|
||||
void ConfigOutputWidget::sendRCOutputUpdate()
|
||||
void ConfigOutputWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
@ -479,27 +503,8 @@ void ConfigOutputWidget::sendRCOutputUpdate()
|
||||
field->setValue(m_config->outputRate2->value(),1);
|
||||
field->setValue(m_config->outputRate3->value(),2);
|
||||
field->setValue(m_config->outputRate4->value(),3);
|
||||
|
||||
// ... and send to the OP Board
|
||||
obj->updated();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sends the config to the board and request saving into the SD card (RC Output)
|
||||
*/
|
||||
void ConfigOutputWidget::saveRCOutputObject()
|
||||
{
|
||||
// Send update so that the latest value is saved
|
||||
sendRCOutputUpdate();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||
Q_ASSERT(obj);
|
||||
saveObjectToSD(obj);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sets the minimum/maximum value of the channel 0 to seven output sliders.
|
||||
Have to do it here because setMinimum is not a slot.
|
||||
|
@ -69,12 +69,10 @@ private:
|
||||
|
||||
bool firstUpdate;
|
||||
|
||||
virtual void enableControls(bool enable);
|
||||
|
||||
private slots:
|
||||
virtual void refreshValues();
|
||||
void sendRCOutputUpdate();
|
||||
void saveRCOutputObject();
|
||||
virtual void refreshWidgetsValues();
|
||||
void updateObjectsFromWidgets();
|
||||
void runChannelTests(bool state);
|
||||
void sendChannelTest(int value);
|
||||
void setChOutRange();
|
||||
|
@ -43,21 +43,15 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa
|
||||
m_stabilization->setupUi(this);
|
||||
|
||||
|
||||
connect(m_stabilization->saveStabilizationToSD, SIGNAL(clicked()), this, SLOT(saveStabilizationUpdate()));
|
||||
connect(m_stabilization->saveStabilizationToRAM, SIGNAL(clicked()), this, SLOT(sendStabilizationUpdate()));
|
||||
setupButtons(m_stabilization->saveStabilizationToRAM,m_stabilization->saveStabilizationToSD);
|
||||
|
||||
enableControls(false);
|
||||
refreshValues();
|
||||
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect()));
|
||||
connect(parent, SIGNAL(autopilotDisconnected()),this, SLOT(onAutopilotDisconnect()));
|
||||
addUAVObject("StabilizationSettings");
|
||||
|
||||
// Now connect the widget to the StabilizationSettings object
|
||||
UAVObject *obj = getObjectManager()->getObject(QString("StabilizationSettings"));
|
||||
connect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(refreshValues()));
|
||||
refreshWidgetsValues();
|
||||
|
||||
// Create a timer to regularly send the object update in case
|
||||
// we want realtime updates.
|
||||
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(sendStabilizationUpdate()));
|
||||
connect(&updateTimer, SIGNAL(timeout()), this, SLOT(updateObjectsFromWidgets()));
|
||||
connect(m_stabilization->realTimeUpdates, SIGNAL(toggled(bool)), this, SLOT(realtimeUpdateToggle(bool)));
|
||||
|
||||
// Connect the updates of the stab values
|
||||
@ -79,6 +73,33 @@ ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTa
|
||||
|
||||
// Connect the help button
|
||||
connect(m_stabilization->stabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||
addWidget(m_stabilization->rateRollKp);
|
||||
addWidget(m_stabilization->rateRollKi);
|
||||
addWidget(m_stabilization->rateRollILimit);
|
||||
addWidget(m_stabilization->ratePitchKp);
|
||||
addWidget(m_stabilization->ratePitchKi);
|
||||
addWidget(m_stabilization->ratePitchILimit);
|
||||
addWidget(m_stabilization->rateYawKp);
|
||||
addWidget(m_stabilization->rateYawKi);
|
||||
addWidget(m_stabilization->rateYawILimit);
|
||||
addWidget(m_stabilization->rollKp);
|
||||
addWidget(m_stabilization->rollKi);
|
||||
addWidget(m_stabilization->rollILimit);
|
||||
addWidget(m_stabilization->yawILimit);
|
||||
addWidget(m_stabilization->yawKi);
|
||||
addWidget(m_stabilization->yawKp);
|
||||
addWidget(m_stabilization->pitchKp);
|
||||
addWidget(m_stabilization->pitchKi);
|
||||
addWidget(m_stabilization->pitchILimit);
|
||||
addWidget(m_stabilization->rollMax);
|
||||
addWidget(m_stabilization->pitchMax);
|
||||
addWidget(m_stabilization->yawMax);
|
||||
addWidget(m_stabilization->manualRoll);
|
||||
addWidget(m_stabilization->manualPitch);
|
||||
addWidget(m_stabilization->manualYaw);
|
||||
addWidget(m_stabilization->maximumRoll);
|
||||
addWidget(m_stabilization->maximumPitch);
|
||||
addWidget(m_stabilization->maximumYaw);
|
||||
}
|
||||
|
||||
ConfigStabilizationWidget::~ConfigStabilizationWidget()
|
||||
@ -187,8 +208,9 @@ void ConfigStabilizationWidget::updatePitchILimit(double val)
|
||||
/**
|
||||
Request stabilization settings from the board
|
||||
*/
|
||||
void ConfigStabilizationWidget::refreshValues()
|
||||
void ConfigStabilizationWidget::refreshWidgetsValues()
|
||||
{
|
||||
bool dirty=isDirty();
|
||||
// Not needed anymore as this slot is only called whenever we get
|
||||
// a signal that the object was just updated
|
||||
// stabSettings->requestUpdate();
|
||||
@ -229,7 +251,7 @@ void ConfigStabilizationWidget::refreshValues()
|
||||
m_stabilization->maximumRoll->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_ROLL]);
|
||||
m_stabilization->maximumPitch->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_PITCH]);
|
||||
m_stabilization->maximumYaw->setValue(stabData.MaximumRate[StabilizationSettings::MAXIMUMRATE_YAW]);
|
||||
|
||||
setDirty(dirty);
|
||||
}
|
||||
|
||||
|
||||
@ -237,7 +259,7 @@ void ConfigStabilizationWidget::refreshValues()
|
||||
Send telemetry settings to the board
|
||||
*/
|
||||
|
||||
void ConfigStabilizationWidget::sendStabilizationUpdate()
|
||||
void ConfigStabilizationWidget::updateObjectsFromWidgets()
|
||||
{
|
||||
StabilizationSettings::DataFields stabData = stabSettings->getData();
|
||||
|
||||
@ -280,21 +302,6 @@ void ConfigStabilizationWidget::sendStabilizationUpdate()
|
||||
stabSettings->setData(stabData); // this is atomic
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send telemetry settings to the board and request saving to SD card
|
||||
*/
|
||||
|
||||
void ConfigStabilizationWidget::saveStabilizationUpdate()
|
||||
{
|
||||
// Send update so that the latest value is saved
|
||||
sendStabilizationUpdate();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("StabilizationSettings")));
|
||||
Q_ASSERT(obj);
|
||||
saveObjectToSD(obj);
|
||||
}
|
||||
|
||||
|
||||
void ConfigStabilizationWidget::realtimeUpdateToggle(bool state)
|
||||
{
|
||||
if (state) {
|
||||
|
@ -52,9 +52,8 @@ private:
|
||||
virtual void enableControls(bool enable);
|
||||
|
||||
private slots:
|
||||
virtual void refreshValues();
|
||||
void sendStabilizationUpdate();
|
||||
void saveStabilizationUpdate();
|
||||
virtual void refreshWidgetsValues();
|
||||
void updateObjectsFromWidgets();
|
||||
void realtimeUpdateToggle(bool);
|
||||
void openHelp();
|
||||
|
||||
|
@ -88,6 +88,15 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel
|
||||
{
|
||||
connect(cb,SIGNAL(valueChanged(double)),this,SLOT(widgetsContentsChanged()));
|
||||
}
|
||||
else if(QCheckBox * cb=qobject_cast<QCheckBox *>(widget))
|
||||
{
|
||||
connect(cb,SIGNAL(clicked()),this,SLOT(widgetsContentsChanged()));
|
||||
}
|
||||
else if(QPushButton * cb=qobject_cast<QPushButton *>(widget))
|
||||
{
|
||||
connect(cb,SIGNAL(clicked()),this,SLOT(widgetsContentsChanged()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -137,6 +146,7 @@ void ConfigTaskWidget::onAutopilotConnect()
|
||||
|
||||
void ConfigTaskWidget::populateWidgets()
|
||||
{
|
||||
bool dirtyBack=dirty;
|
||||
foreach(objectToWidget * ow,objOfInterest)
|
||||
{
|
||||
if(ow->object==NULL || ow->field==NULL)
|
||||
@ -153,11 +163,12 @@ void ConfigTaskWidget::populateWidgets()
|
||||
cb->setText(ow->field->getValue().toString());
|
||||
}
|
||||
}
|
||||
dirty=false;
|
||||
setDirty(dirtyBack);
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::refreshWidgetsValues()
|
||||
{
|
||||
bool dirtyBack=dirty;
|
||||
foreach(objectToWidget * ow,objOfInterest)
|
||||
{
|
||||
if(ow->object==NULL || ow->field==NULL)
|
||||
@ -173,6 +184,7 @@ void ConfigTaskWidget::refreshWidgetsValues()
|
||||
cb->setText(ow->field->getValue().toString());
|
||||
}
|
||||
}
|
||||
setDirty(dirtyBack);
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::updateObjectsFromWidgets()
|
||||
@ -197,7 +209,7 @@ void ConfigTaskWidget::updateObjectsFromWidgets()
|
||||
void ConfigTaskWidget::setupButtons(QPushButton *update, QPushButton *save)
|
||||
{
|
||||
smartsave=new smartSaveButton(update,save);
|
||||
connect(smartsave, SIGNAL(preProcessOperations()), this, SLOT(updateObjectsFromWidgets()));
|
||||
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()));
|
||||
@ -211,15 +223,18 @@ void ConfigTaskWidget::enableControls(bool enable)
|
||||
|
||||
void ConfigTaskWidget::widgetsContentsChanged()
|
||||
{
|
||||
qDebug()<<"dirty!!!";
|
||||
dirty=true;
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
void ConfigTaskWidget::clearDirty()
|
||||
{
|
||||
dirty=false;
|
||||
setDirty(false);
|
||||
}
|
||||
void ConfigTaskWidget::setDirty(bool value)
|
||||
{
|
||||
qDebug()<<"dirty="<<value;
|
||||
dirty=value;
|
||||
}
|
||||
|
||||
bool ConfigTaskWidget::isDirty()
|
||||
{
|
||||
return dirty;
|
||||
|
@ -41,6 +41,9 @@
|
||||
#include <QTableWidget>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
|
||||
class ConfigTaskWidget: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -63,6 +66,7 @@ public:
|
||||
void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget);
|
||||
void setupButtons(QPushButton * update,QPushButton * save);
|
||||
bool isDirty();
|
||||
void setDirty(bool value);
|
||||
public slots:
|
||||
void onAutopilotDisconnect();
|
||||
void onAutopilotConnect();
|
||||
|
@ -284,6 +284,10 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index) {
|
||||
bool proceed=true;
|
||||
emit aboutToChange(&proceed);
|
||||
if(!proceed)
|
||||
return;
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(index);
|
||||
@ -319,7 +323,6 @@ FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this, isVertical);
|
||||
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QBoxLayout *selectionLayout;
|
||||
if (isVertical) {
|
||||
@ -477,3 +480,7 @@ void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
||||
{
|
||||
m_tabBar->setTabToolTip(index, toolTip);
|
||||
}
|
||||
QWidget * FancyTabWidget::currentWidget()
|
||||
{
|
||||
return m_modesStack->currentWidget();
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ public:
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
void aboutToChange(bool *);
|
||||
|
||||
public slots:
|
||||
void updateHover();
|
||||
@ -116,7 +117,7 @@ class FancyTabWidget : public QWidget
|
||||
|
||||
public:
|
||||
FancyTabWidget(QWidget *parent = 0, bool isVertical = false);
|
||||
|
||||
FancyTabBar *m_tabBar;
|
||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||
void removeTab(int index);
|
||||
void setBackgroundBrush(const QBrush &brush);
|
||||
@ -132,6 +133,7 @@ public:
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
QWidget * currentWidget();
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
@ -143,7 +145,6 @@ private slots:
|
||||
void showWidget(int index);
|
||||
|
||||
private:
|
||||
FancyTabBar *m_tabBar;
|
||||
QWidget *m_cornerWidgetContainer;
|
||||
QStackedLayout *m_modesStack;
|
||||
QWidget *m_selectionWidget;
|
||||
|
@ -111,6 +111,7 @@ void smartSaveButton::saving_finished(int id, bool result)
|
||||
if(id==current_objectID)
|
||||
{
|
||||
sv_result=result;
|
||||
qDebug()<<"saving_finished result="<<result;
|
||||
loop.quit();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user