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"));
|
||||
bool result = readFirmware(filename, progressDialog.progress());
|
||||
if (!result) {
|
||||
if (!result && !progressDialog.isEmpty()) {
|
||||
progressDialog.exec();
|
||||
}
|
||||
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"));
|
||||
bool result = ::readEeprom(filename, progressDialog.progress());
|
||||
if (!result) {
|
||||
progressDialog.exec();
|
||||
if (!progressDialog.isEmpty()) {
|
||||
progressDialog.exec();
|
||||
}
|
||||
}
|
||||
else {
|
||||
statusBar()->showMessage(tr("Models and Settings read"), 2000);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "progresswidget.h"
|
||||
#include "progressdialog.h"
|
||||
#include "ui_progressdialog.h"
|
||||
#include "appdata.h"
|
||||
@@ -71,3 +72,8 @@ void ProgressDialog::shrink()
|
||||
{
|
||||
resize(0, 0);
|
||||
}
|
||||
|
||||
bool ProgressDialog::isEmpty() const
|
||||
{
|
||||
return ui->outputProgress->isEmpty();
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
~ProgressDialog();
|
||||
|
||||
ProgressWidget * progress();
|
||||
bool isEmpty() const;
|
||||
|
||||
private slots:
|
||||
void on_closeButton_clicked();
|
||||
|
||||
@@ -108,6 +108,11 @@ QString ProgressWidget::getText()
|
||||
return ui->textEdit->toPlainText();
|
||||
}
|
||||
|
||||
bool ProgressWidget::isEmpty() const
|
||||
{
|
||||
return ui->textEdit->toPlainText().isEmpty();
|
||||
}
|
||||
|
||||
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()));
|
||||
|
||||
@@ -45,6 +45,7 @@ class ProgressWidget : public QWidget
|
||||
void addSeparator();
|
||||
void forceOpen();
|
||||
void stop();
|
||||
bool isEmpty() const;
|
||||
|
||||
signals:
|
||||
void detailsToggled();
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "mountlist.h"
|
||||
#include "process_copy.h"
|
||||
#include "storage.h"
|
||||
#include "progresswidget.h"
|
||||
|
||||
#if defined WIN32 || !defined __GNUC__
|
||||
#include <windows.h>
|
||||
@@ -323,15 +324,18 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
||||
QString radioPath = findMassstoragePath("RADIO", true);
|
||||
qDebug() << "Searching for SD card, found" << radioPath;
|
||||
if (radioPath.isEmpty()) {
|
||||
QMessageBox::critical(progress, QObject::tr("Error"), QObject::tr("Unable to find Horus radio SD card!"));
|
||||
return false;
|
||||
}
|
||||
RadioData radioData;
|
||||
Storage inputStorage(radioPath);
|
||||
if (!inputStorage.load(radioData)) {
|
||||
QMessageBox::critical(progress, QObject::tr("Error"), inputStorage.error());
|
||||
return false;
|
||||
}
|
||||
Storage outputStorage(filename);
|
||||
if (!outputStorage.write(radioData)) {
|
||||
QMessageBox::critical(progress, QObject::tr("Error"), outputStorage.error());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -347,6 +351,8 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
||||
path = findMassstoragePath("ERSKY9X.BIN");
|
||||
}
|
||||
if (path.isEmpty()) {
|
||||
RadioNotFoundDialog dialog;
|
||||
dialog.exec();
|
||||
return false;
|
||||
}
|
||||
CopyProcess copyProcess(path, filename, progress);
|
||||
@@ -361,11 +367,6 @@ bool readEeprom(const QString & filename, ProgressWidget * progress)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (IS_ARM(board)) {
|
||||
RadioNotFoundDialog dialog;
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
|
||||
return QFileInfo(filename).exists();
|
||||
|
||||
Reference in New Issue
Block a user