mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
OP-682 fixed regression that prevented uploading of valid fw + renamed
youdont check box to confirmCheckBox + minor cleanups
This commit is contained in:
parent
4350e48bfc
commit
1d9deae77d
@ -35,12 +35,12 @@ deviceWidget::deviceWidget(QWidget *parent) :
|
|||||||
// Initialization of the Device icon display
|
// Initialization of the Device icon display
|
||||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||||
myDevice->groupCustom->setVisible(false);
|
myDevice->groupCustom->setVisible(false);
|
||||||
myDevice->youdont->setVisible(false);
|
myDevice->confirmCheckBox->setVisible(false);
|
||||||
myDevice->gVDevice->setScene(new QGraphicsScene(this));
|
myDevice->gVDevice->setScene(new QGraphicsScene(this));
|
||||||
connect(myDevice->retrieveButton, SIGNAL(clicked()), this, SLOT(downloadFirmware()));
|
connect(myDevice->retrieveButton, SIGNAL(clicked()), this, SLOT(downloadFirmware()));
|
||||||
connect(myDevice->updateButton, SIGNAL(clicked()), this, SLOT(uploadFirmware()));
|
connect(myDevice->updateButton, SIGNAL(clicked()), this, SLOT(uploadFirmware()));
|
||||||
connect(myDevice->pbLoad, SIGNAL(clicked()), this, SLOT(loadFirmware()));
|
connect(myDevice->pbLoad, SIGNAL(clicked()), this, SLOT(loadFirmware()));
|
||||||
connect(myDevice->youdont, SIGNAL(stateChanged(int)), this, SLOT(confirmCB(int)));
|
connect(myDevice->confirmCheckBox, SIGNAL(stateChanged(int)), this, SLOT(confirmCB(int)));
|
||||||
QPixmap pix = QPixmap(QString(":uploader/images/view-refresh.svg"));
|
QPixmap pix = QPixmap(QString(":uploader/images/view-refresh.svg"));
|
||||||
myDevice->statusIcon->setPixmap(pix);
|
myDevice->statusIcon->setPixmap(pix);
|
||||||
|
|
||||||
@ -151,17 +151,17 @@ void deviceWidget::updateButtons(bool enabled)
|
|||||||
if (!enabled) {
|
if (!enabled) {
|
||||||
myDevice->description->setEnabled(false);
|
myDevice->description->setEnabled(false);
|
||||||
myDevice->pbLoad->setEnabled(false);
|
myDevice->pbLoad->setEnabled(false);
|
||||||
myDevice->youdont->setEnabled(false);
|
myDevice->confirmCheckBox->setEnabled(false);
|
||||||
myDevice->updateButton->setEnabled(false);
|
myDevice->updateButton->setEnabled(false);
|
||||||
myDevice->retrieveButton->setEnabled(false);
|
myDevice->retrieveButton->setEnabled(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
myDevice->description->setEnabled(true);
|
myDevice->description->setEnabled(true);
|
||||||
// Load button (i.e. chose file) is always enabled
|
// Load button (i.e. choose file) is always enabled
|
||||||
myDevice->pbLoad->setEnabled(true);
|
myDevice->pbLoad->setEnabled(true);
|
||||||
myDevice->youdont->setEnabled(true);
|
myDevice->confirmCheckBox->setEnabled(true);
|
||||||
// Update/Upload button is enabled if a file has be selected and the "You know what your doing" check box is checked
|
// Update/Upload button is enabled if the "I know what I'm doing!" check box is checked
|
||||||
myDevice->updateButton->setEnabled(myDevice->youdont->isVisible() && myDevice->youdont->checkState() == Qt::Checked);
|
myDevice->updateButton->setEnabled(myDevice->confirmCheckBox->checkState() == Qt::Checked);
|
||||||
// Retreive/Download button is always enabled
|
// Retreive/Download button is always enabled
|
||||||
myDevice->retrieveButton->setEnabled(true);
|
myDevice->retrieveButton->setEnabled(true);
|
||||||
}
|
}
|
||||||
@ -275,6 +275,9 @@ void deviceWidget::loadFirmware()
|
|||||||
|
|
||||||
filename = setOpenFileName();
|
filename = setOpenFileName();
|
||||||
|
|
||||||
|
myDevice->confirmCheckBox->setVisible(false);
|
||||||
|
myDevice->confirmCheckBox->setChecked(false);
|
||||||
|
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
status("Empty filename", STATUSICON_FAIL);
|
status("Empty filename", STATUSICON_FAIL);
|
||||||
return;
|
return;
|
||||||
@ -287,52 +290,42 @@ void deviceWidget::loadFirmware()
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadedFW = file.readAll();
|
loadedFW = file.readAll();
|
||||||
myDevice->youdont->setVisible(false);
|
|
||||||
myDevice->youdont->setChecked(false);
|
|
||||||
QByteArray desc = loadedFW.right(100);
|
QByteArray desc = loadedFW.right(100);
|
||||||
QPixmap px;
|
QPixmap px;
|
||||||
if(loadedFW.length()>m_dfu->devices[deviceID].SizeOfCode)
|
if (loadedFW.length()>m_dfu->devices[deviceID].SizeOfCode) {
|
||||||
myDevice->lblCRCL->setText(tr("Can't calculate, file too big for device"));
|
myDevice->lblCRCL->setText(tr("Can't calculate, file too big for device"));
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
myDevice->lblCRCL->setText( QString::number(DFUObject::CRCFromQBArray(loadedFW,m_dfu->devices[deviceID].SizeOfCode)));
|
myDevice->lblCRCL->setText( QString::number(DFUObject::CRCFromQBArray(loadedFW,m_dfu->devices[deviceID].SizeOfCode)));
|
||||||
|
}
|
||||||
//myDevice->lblFirmwareSizeL->setText(QString("Firmware size: ")+QVariant(loadedFW.length()).toString()+ QString(" bytes"));
|
//myDevice->lblFirmwareSizeL->setText(QString("Firmware size: ")+QVariant(loadedFW.length()).toString()+ QString(" bytes"));
|
||||||
if (populateLoadedStructuredDescription(desc))
|
if (populateLoadedStructuredDescription(desc))
|
||||||
{
|
{
|
||||||
myDevice->youdont->setChecked(true);
|
myDevice->confirmCheckBox->setChecked(true);
|
||||||
myDevice->verticalGroupBox_loaded->setVisible(true);
|
myDevice->verticalGroupBox_loaded->setVisible(true);
|
||||||
myDevice->groupCustom->setVisible(false);
|
myDevice->groupCustom->setVisible(false);
|
||||||
if(myDevice->lblCRC->text()==myDevice->lblCRCL->text())
|
if (myDevice->lblCRC->text() == myDevice->lblCRCL->text()) {
|
||||||
{
|
myDevice->statusLabel->setText(tr("The board has the same firmware as loaded. No need to update."));
|
||||||
myDevice->statusLabel->setText(tr("The board has the same firmware as loaded. No need to update"));
|
|
||||||
px.load(QString(":/uploader/images/warning.svg"));
|
px.load(QString(":/uploader/images/warning.svg"));
|
||||||
}
|
} else if (myDevice->lblDevName->text() != myDevice->lblBrdNameL->text()) {
|
||||||
else if(myDevice->lblDevName->text()!=myDevice->lblBrdNameL->text())
|
|
||||||
{
|
|
||||||
myDevice->statusLabel->setText(tr("WARNING: the loaded firmware is for different hardware. Do not update!"));
|
myDevice->statusLabel->setText(tr("WARNING: the loaded firmware is for different hardware. Do not update!"));
|
||||||
px.load(QString(":/uploader/images/error.svg"));
|
px.load(QString(":/uploader/images/error.svg"));
|
||||||
}
|
} else if (QDateTime::fromString(onBoardDescription.gitDate) > QDateTime::fromString(LoadedDescription.gitDate)) {
|
||||||
else if(QDateTime::fromString(onBoardDescription.gitDate)>QDateTime::fromString(LoadedDescription.gitDate))
|
|
||||||
{
|
|
||||||
myDevice->statusLabel->setText(tr("The board has newer firmware than loaded. Are you sure you want to update?"));
|
myDevice->statusLabel->setText(tr("The board has newer firmware than loaded. Are you sure you want to update?"));
|
||||||
px.load(QString(":/uploader/images/warning.svg"));
|
px.load(QString(":/uploader/images/warning.svg"));
|
||||||
}
|
} else if (!LoadedDescription.gitTag.startsWith("RELEASE", Qt::CaseSensitive)) {
|
||||||
else if(!LoadedDescription.gitTag.startsWith("RELEASE",Qt::CaseSensitive))
|
myDevice->statusLabel->setText(tr("The loaded firmware is untagged or custom build. Update only if it was received from a trusted source (official website or your own build)."));
|
||||||
{
|
|
||||||
myDevice->statusLabel->setText(tr("The loaded firmware is untagged or custom build. Update only if it was received from a trusted source (official website or your own build)"));
|
|
||||||
px.load(QString(":/uploader/images/warning.svg"));
|
px.load(QString(":/uploader/images/warning.svg"));
|
||||||
}
|
} else {
|
||||||
else
|
myDevice->statusLabel->setText(tr("This is the tagged officially released OpenPilot firmware."));
|
||||||
{
|
|
||||||
myDevice->statusLabel->setText(tr("This is the tagged officially released OpenPilot firmware"));
|
|
||||||
px.load(QString(":/uploader/images/gtk-info.svg"));
|
px.load(QString(":/uploader/images/gtk-info.svg"));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
myDevice->statusLabel->setText(tr("WARNING: the loaded firmware was not packaged with the OpenPilot format. Do not update unless you know what you are doing."));
|
||||||
{
|
|
||||||
myDevice->statusLabel->setText(tr("WARNING: the loaded firmware was not packaged with the OpenPilot format. Do not update unless you know what you are doing"));
|
|
||||||
px.load(QString(":/uploader/images/error.svg"));
|
px.load(QString(":/uploader/images/error.svg"));
|
||||||
myDevice->youdont->setChecked(false);
|
myDevice->confirmCheckBox->setChecked(false);
|
||||||
myDevice->youdont->setVisible(true);
|
myDevice->confirmCheckBox->setVisible(true);
|
||||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||||
myDevice->groupCustom->setVisible(true);
|
myDevice->groupCustom->setVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class UPLOADER_EXPORT deviceWidget : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
deviceWidget( QWidget *parent = 0);
|
deviceWidget(QWidget *parent = 0);
|
||||||
void setDeviceID(int devID);
|
void setDeviceID(int devID);
|
||||||
void setDfu(DFUObject* dfu);
|
void setDfu(DFUObject* dfu);
|
||||||
void populate();
|
void populate();
|
||||||
@ -57,6 +57,7 @@ public:
|
|||||||
typedef enum { STATUSICON_OK, STATUSICON_RUNNING, STATUSICON_FAIL, STATUSICON_INFO} StatusIcon;
|
typedef enum { STATUSICON_OK, STATUSICON_RUNNING, STATUSICON_FAIL, STATUSICON_INFO} StatusIcon;
|
||||||
QString setOpenFileName();
|
QString setOpenFileName();
|
||||||
QString setSaveFileName();
|
QString setSaveFileName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
deviceDescriptorStruct onBoardDescription;
|
deviceDescriptorStruct onBoardDescription;
|
||||||
deviceDescriptorStruct LoadedDescription;
|
deviceDescriptorStruct LoadedDescription;
|
||||||
@ -78,6 +79,7 @@ signals:
|
|||||||
void uploadEnded(bool success);
|
void uploadEnded(bool success);
|
||||||
void downloadStarted();
|
void downloadStarted();
|
||||||
void downloadEnded(bool success);
|
void downloadEnded(bool success);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void uploadFirmware();
|
void uploadFirmware();
|
||||||
void loadFirmware();
|
void loadFirmware();
|
||||||
|
@ -101,9 +101,9 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="youdont">
|
<widget class="QCheckBox" name="confirmCheckBox">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>I know what I'm doing</string>
|
<string>I know what I'm doing!</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="checked">
|
<property name="checked">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user