From d5e3fabf03ebbf274cf81a21e01bb2727e5c868b Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 29 Jan 2017 09:59:58 +0100 Subject: [PATCH] Read/write backup fixes: (#4327) * Read/write backup fixes: * radio not found was show behind all windows (missing parent) * bad behavior on write when radio not found * Disable model backup read/write for Horus (needs implementation) --- companion/src/flasheepromdialog.cpp | 15 ++++++++++----- companion/src/flasheepromdialog.h | 1 + companion/src/mainwindow.cpp | 10 ++++++++++ companion/src/radiointerface.cpp | 4 ++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/companion/src/flasheepromdialog.cpp b/companion/src/flasheepromdialog.cpp index 7f65224c8..70482d971 100644 --- a/companion/src/flasheepromdialog.cpp +++ b/companion/src/flasheepromdialog.cpp @@ -48,7 +48,6 @@ radioData(new RadioData()) if (backupPath.isEmpty() || !QDir(backupPath).exists()) { ui->backupBeforeWrite->setEnabled(false); } - updateUI(); } FlashEEpromDialog::~FlashEEpromDialog() @@ -56,11 +55,16 @@ FlashEEpromDialog::~FlashEEpromDialog() delete ui; } +void FlashEEpromDialog::showEvent(QShowEvent *) +{ + updateUI(); +} + void FlashEEpromDialog::updateUI() { // ui->burnButton->setEnabled(true); ui->eepromFilename->setText(eepromFilename); - if (getEEpromVersion(eepromFilename) >= 0) { + if (!eepromFilename.isEmpty() && getEEpromVersion(eepromFilename) >= 0) { ui->profileLabel->show(); ui->patchCalibration->show(); ui->patchHardwareSettings->show(); @@ -290,9 +294,10 @@ void FlashEEpromDialog::on_burnButton_clicked() } // and write... - writeEeprom(filename, progressDialog.progress()); - - progressDialog.exec(); + bool result = writeEeprom(filename, progressDialog.progress()); + if (!result && !progressDialog.isEmpty()) { + progressDialog.exec(); + } } void FlashEEpromDialog::on_cancelButton_clicked() diff --git a/companion/src/flasheepromdialog.h b/companion/src/flasheepromdialog.h index e244f4747..0cb2ae1d0 100644 --- a/companion/src/flasheepromdialog.h +++ b/companion/src/flasheepromdialog.h @@ -54,6 +54,7 @@ protected: int getEEpromVersion(const QString &filename); bool patchCalibration(); bool patchHardwareSettings(); + virtual void showEvent(QShowEvent *); private: Ui::FlashEEpromDialog *ui; diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index f521b8f2b..3258e689b 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -777,6 +777,11 @@ bool MainWindow::readEepromFromRadio(const QString & filename) void MainWindow::writeBackup() { + if (IS_HORUS(getCurrentBoard())) { + QMessageBox::information(this, "Companion", tr("This function is not yet implemented")); + return; + // TODO implementation + } FlashEEpromDialog *cd = new FlashEEpromDialog(this); cd->exec(); } @@ -789,6 +794,11 @@ void MainWindow::writeFlash(QString fileToFlash) void MainWindow::readBackup() { + if (IS_HORUS(getCurrentBoard())) { + QMessageBox::information(this, "Companion", tr("This function is not yet implemented")); + return; + // TODO implementation + } QString fileName = QFileDialog::getSaveFileName(this, tr("Save Radio Backup to File"), g.eepromDir(), tr(EXTERNAL_EEPROM_FILES_FILTER)); if (!fileName.isEmpty()) { if (!readEepromFromRadio(fileName)) diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp index dc59e6e11..58654e673 100644 --- a/companion/src/radiointerface.cpp +++ b/companion/src/radiointerface.cpp @@ -351,7 +351,7 @@ bool readEeprom(const QString & filename, ProgressWidget * progress) path = findMassstoragePath("ERSKY9X.BIN"); } if (path.isEmpty()) { - RadioNotFoundDialog dialog; + RadioNotFoundDialog dialog(progress); dialog.exec(); return false; } @@ -398,7 +398,7 @@ bool writeEeprom(const QString & filename, ProgressWidget * progress) } if (IS_ARM(board)) { - RadioNotFoundDialog dialog; + RadioNotFoundDialog dialog(progress); dialog.exec(); }