Fixes for "Read Models and Settings from the radio": (#4291)
* show errors * close dialog in nothing in progress widget
This commit is contained in:
committed by
Bertrand Songis
parent
1202fa84fa
commit
8102f870fe
@@ -754,7 +754,7 @@ bool MainWindow::readFirmwareFromRadio(const QString & filename)
|
|||||||
{
|
{
|
||||||
ProgressDialog progressDialog(this, tr("Read Firmware from Radio"), CompanionIcon("read_flash.png"));
|
ProgressDialog progressDialog(this, tr("Read Firmware from Radio"), CompanionIcon("read_flash.png"));
|
||||||
bool result = readFirmware(filename, progressDialog.progress());
|
bool result = readFirmware(filename, progressDialog.progress());
|
||||||
if (!result) {
|
if (!result && !progressDialog.isEmpty()) {
|
||||||
progressDialog.exec();
|
progressDialog.exec();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -765,7 +765,12 @@ bool MainWindow::readEepromFromRadio(const QString & filename)
|
|||||||
ProgressDialog progressDialog(this, tr("Read Models and Settings from Radio"), CompanionIcon("read_eeprom.png"));
|
ProgressDialog progressDialog(this, tr("Read Models and Settings from Radio"), CompanionIcon("read_eeprom.png"));
|
||||||
bool result = ::readEeprom(filename, progressDialog.progress());
|
bool result = ::readEeprom(filename, progressDialog.progress());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
progressDialog.exec();
|
if (!progressDialog.isEmpty()) {
|
||||||
|
progressDialog.exec();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusBar()->showMessage(tr("Models and Settings read"), 2000);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "progresswidget.h"
|
||||||
#include "progressdialog.h"
|
#include "progressdialog.h"
|
||||||
#include "ui_progressdialog.h"
|
#include "ui_progressdialog.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
@@ -71,3 +72,8 @@ void ProgressDialog::shrink()
|
|||||||
{
|
{
|
||||||
resize(0, 0);
|
resize(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProgressDialog::isEmpty() const
|
||||||
|
{
|
||||||
|
return ui->outputProgress->isEmpty();
|
||||||
|
}
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
~ProgressDialog();
|
~ProgressDialog();
|
||||||
|
|
||||||
ProgressWidget * progress();
|
ProgressWidget * progress();
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_closeButton_clicked();
|
void on_closeButton_clicked();
|
||||||
|
|||||||
@@ -108,6 +108,11 @@ QString ProgressWidget::getText()
|
|||||||
return ui->textEdit->toPlainText();
|
return ui->textEdit->toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProgressWidget::isEmpty() const
|
||||||
|
{
|
||||||
|
return ui->textEdit->toPlainText().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
void ProgressWidget::setProgressColor(const QColor &color)
|
void ProgressWidget::setProgressColor(const QColor &color)
|
||||||
{
|
{
|
||||||
ui->progressBar->setStyleSheet(QString("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: %1; text-align:center;}:").arg(color.name()));
|
ui->progressBar->setStyleSheet(QString("QProgressBar {text-align: center;} QProgressBar::chunk { background-color: %1; text-align:center;}:").arg(color.name()));
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class ProgressWidget : public QWidget
|
|||||||
void addSeparator();
|
void addSeparator();
|
||||||
void forceOpen();
|
void forceOpen();
|
||||||
void stop();
|
void stop();
|
||||||
|
bool isEmpty() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void detailsToggled();
|
void detailsToggled();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "mountlist.h"
|
#include "mountlist.h"
|
||||||
#include "process_copy.h"
|
#include "process_copy.h"
|
||||||
#include "storage.h"
|
#include "storage.h"
|
||||||
|
#include "progresswidget.h"
|
||||||
|
|
||||||
#if defined WIN32 || !defined __GNUC__
|
#if defined WIN32 || !defined __GNUC__
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -323,15 +324,18 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
|||||||
QString radioPath = findMassstoragePath("RADIO", true);
|
QString radioPath = findMassstoragePath("RADIO", true);
|
||||||
qDebug() << "Searching for SD card, found" << radioPath;
|
qDebug() << "Searching for SD card, found" << radioPath;
|
||||||
if (radioPath.isEmpty()) {
|
if (radioPath.isEmpty()) {
|
||||||
|
QMessageBox::critical(progress, QObject::tr("Error"), QObject::tr("Unable to find Horus radio SD card!"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
RadioData radioData;
|
RadioData radioData;
|
||||||
Storage inputStorage(radioPath);
|
Storage inputStorage(radioPath);
|
||||||
if (!inputStorage.load(radioData)) {
|
if (!inputStorage.load(radioData)) {
|
||||||
|
QMessageBox::critical(progress, QObject::tr("Error"), inputStorage.error());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Storage outputStorage(filename);
|
Storage outputStorage(filename);
|
||||||
if (!outputStorage.write(radioData)) {
|
if (!outputStorage.write(radioData)) {
|
||||||
|
QMessageBox::critical(progress, QObject::tr("Error"), outputStorage.error());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -347,6 +351,8 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
|||||||
path = findMassstoragePath("ERSKY9X.BIN");
|
path = findMassstoragePath("ERSKY9X.BIN");
|
||||||
}
|
}
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
|
RadioNotFoundDialog dialog;
|
||||||
|
dialog.exec();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CopyProcess copyProcess(path, filename, progress);
|
CopyProcess copyProcess(path, filename, progress);
|
||||||
@@ -361,11 +367,6 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ARM(board)) {
|
|
||||||
RadioNotFoundDialog dialog;
|
|
||||||
dialog.exec();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return QFileInfo(filename).exists();
|
return QFileInfo(filename).exists();
|
||||||
|
|||||||
Reference in New Issue
Block a user