mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Move OSTC firmware check around a bit
This rearranges the code so we can call it from the download dialog and tell the user if there is a newer version of the firmware available. This needs a proper dialog and needs to be hooked up so that the user can accept the suggestion and go directly to the firmware update code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9f95f3ce18
commit
52084c80f7
4 changed files with 51 additions and 16 deletions
|
@ -187,16 +187,32 @@ ConfigureDiveComputerDialog::ConfigureDiveComputerDialog(QWidget *parent) :
|
|||
}
|
||||
settings.endGroup();
|
||||
settings.endGroup();
|
||||
|
||||
hwVersionPage.mainFrame()->load(QUrl("http://www.heinrichsweikamp.com/?id=162"));
|
||||
connect(&hwVersionPage, SIGNAL(loadFinished(bool)), this, SLOT(findVersion()));
|
||||
}
|
||||
|
||||
void ConfigureDiveComputerDialog::findVersion()
|
||||
OstcFirmwareCheck::OstcFirmwareCheck()
|
||||
{
|
||||
hwVersionPage.mainFrame()->load(QUrl("http://www.heinrichsweikamp.com/?id=162"));
|
||||
connect(&hwVersionPage, SIGNAL(loadFinished(bool)), this, SLOT(parseOstcFwVersion()));
|
||||
}
|
||||
|
||||
void OstcFirmwareCheck::parseOstcFwVersion()
|
||||
{
|
||||
QWebElement parse = hwVersionPage.mainFrame()->documentElement();
|
||||
QWebElement result = parse.findFirst("div[id=content_firmware_headline_typ0]");
|
||||
qDebug() << "Version" << result.toPlainText();
|
||||
latestFirmwareAvailable = result.toPlainText().trimmed();
|
||||
qDebug() << "Latest OSTC 3 Version" << latestFirmwareAvailable;
|
||||
}
|
||||
|
||||
void OstcFirmwareCheck::checkLatest(uint32_t firmwareOnDevice)
|
||||
{
|
||||
// for now libdivecomputer gives us the firmware on device undecoded as integer
|
||||
// for the OSTC that means highbyte.lowbyte is the version number
|
||||
QString firmware;
|
||||
firmware = QString("%1.%2").arg(firmwareOnDevice / 256). arg(firmwareOnDevice % 256);
|
||||
if (!latestFirmwareAvailable.isEmpty() && latestFirmwareAvailable != firmware) {
|
||||
qDebug() << "you should update your firmware: you have" << firmware <<
|
||||
"but the latest stable version is" << latestFirmwareAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
ConfigureDiveComputerDialog::~ConfigureDiveComputerDialog()
|
||||
|
|
|
@ -74,8 +74,6 @@ private slots:
|
|||
void on_updateFirmwareButton_clicked();
|
||||
|
||||
void on_DiveComputerList_currentRowChanged(int currentRow);
|
||||
void findVersion();
|
||||
|
||||
|
||||
private:
|
||||
Ui::ConfigureDiveComputerDialog ui;
|
||||
|
@ -102,8 +100,20 @@ private:
|
|||
|
||||
QString selected_vendor;
|
||||
QString selected_product;
|
||||
QWebPage hwVersionPage;
|
||||
};
|
||||
|
||||
class OstcFirmwareCheck : QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit OstcFirmwareCheck();
|
||||
void checkLatest(uint32_t firmwareOnDevice);
|
||||
public
|
||||
slots:
|
||||
void parseOstcFwVersion();
|
||||
private:
|
||||
QWebPage hwVersionPage;
|
||||
QString latestFirmwareAvailable;
|
||||
};
|
||||
|
||||
#endif // CONFIGUREDIVECOMPUTERDIALOG_H
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
#include "downloadfromdivecomputer.h"
|
||||
#include "../divecomputer.h"
|
||||
#include "../libdivecomputer.h"
|
||||
#include "../helpers.h"
|
||||
#include "../display.h"
|
||||
#include "../divelist.h"
|
||||
|
||||
#include "divecomputer.h"
|
||||
#include "libdivecomputer.h"
|
||||
#include "helpers.h"
|
||||
#include "display.h"
|
||||
#include "divelist.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
|
@ -46,7 +46,8 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
|
|||
productModel(0),
|
||||
timer(new QTimer(this)),
|
||||
dumpWarningShown(false),
|
||||
currentState(INITIAL)
|
||||
currentState(INITIAL),
|
||||
ostcFirmwareCheck(0)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
ui.progressBar->hide();
|
||||
|
@ -302,6 +303,9 @@ void DownloadFromDCWidget::on_ok_clicked()
|
|||
previousLast = dive_table.nr;
|
||||
|
||||
thread->start();
|
||||
|
||||
if (ui.product->currentText() == "OSTC 3" || ui.product->currentText() == "OSTC sport")
|
||||
ostcFirmwareCheck = new OstcFirmwareCheck();
|
||||
}
|
||||
|
||||
bool DownloadFromDCWidget::preferDownloaded()
|
||||
|
@ -397,6 +401,9 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
|
|||
// (but not visible as selected)
|
||||
MainWindow::instance()->dive_list()->unselectDives();
|
||||
MainWindow::instance()->dive_list()->selectDive(idx, true);
|
||||
QString dcName = data.devname;
|
||||
if (ostcFirmwareCheck)
|
||||
ostcFirmwareCheck->checkLatest(data.libdc_firmware);
|
||||
}
|
||||
} else if (currentState == CANCELLING || currentState == CANCELLED) {
|
||||
if (import_thread_cancelled) {
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
#include <QHash>
|
||||
#include <QMap>
|
||||
|
||||
#include "../libdivecomputer.h"
|
||||
#include "libdivecomputer.h"
|
||||
#include "configuredivecomputerdialog.h"
|
||||
#include "ui_downloadfromdivecomputer.h"
|
||||
|
||||
class QStringListModel;
|
||||
|
@ -75,6 +76,7 @@ private:
|
|||
QString dumpFile;
|
||||
QTimer *timer;
|
||||
bool dumpWarningShown;
|
||||
OstcFirmwareCheck *ostcFirmwareCheck;
|
||||
|
||||
public:
|
||||
bool preferDownloaded();
|
||||
|
|
Loading…
Reference in a new issue