Add support to reset OSTC3 settings to default

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Anton Lundin 2014-10-18 00:33:47 +02:00 committed by Dirk Hohndel
parent d63a3ce420
commit 74f27a0a39
7 changed files with 97 additions and 1 deletions

View file

@ -12,7 +12,8 @@
ConfigureDiveComputer::ConfigureDiveComputer(QObject *parent) :
QObject(parent),
readThread(0),
writeThread(0)
writeThread(0),
resetThread(0)
{
setState(INITIAL);
}
@ -514,6 +515,21 @@ void ConfigureDiveComputer::startFirmwareUpdate(QString fileName, device_data_t
}
void ConfigureDiveComputer::resetSettings(device_data_t *data)
{
setState(RESETTING);
if (resetThread)
resetThread->deleteLater();
resetThread = new ResetSettingsThread(this, data);
connect(resetThread, SIGNAL(finished()),
this, SLOT(resetThreadFinished()), Qt::QueuedConnection);
connect(resetThread, SIGNAL(error(QString)), this, SLOT(setError(QString)));
resetThread->start();
}
void ConfigureDiveComputer::setState(ConfigureDiveComputer::states newState)
{
currentState = newState;
@ -540,3 +556,12 @@ void ConfigureDiveComputer::writeThreadFinished()
emit message(tr("Setting successfully written to device"));
}
}
void ConfigureDiveComputer::resetThreadFinished()
{
setState(DONE);
if (resetThread->lastError.isEmpty()) {
//No error
emit message(tr("Device settings successfully resetted"));
}
}