diff --git a/companion/src/downloaddialog.cpp b/companion/src/downloaddialog.cpp index 7b2f9ffbd..3f70e6529 100644 --- a/companion/src/downloaddialog.cpp +++ b/companion/src/downloaddialog.cpp @@ -25,9 +25,9 @@ #include -downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt): +DownloadDialog::DownloadDialog(QWidget *parent, QString src, QString tgt): QDialog(parent), - ui(new Ui::downloadDialog), + ui(new Ui::DownloadDialog), reply(nullptr), file(nullptr), aborted(false) @@ -58,13 +58,13 @@ downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt): } } -downloadDialog::~downloadDialog() +DownloadDialog::~DownloadDialog() { delete ui; delete file; } -void downloadDialog::reject() +void DownloadDialog::reject() { if (reply && reply->isRunning()) { aborted = true; @@ -75,7 +75,7 @@ void downloadDialog::reject() QDialog::reject(); } -void downloadDialog::httpFinished() +void DownloadDialog::httpFinished() { file->flush(); file->close(); @@ -98,20 +98,20 @@ void downloadDialog::httpFinished() reject(); } -void downloadDialog::httpReadyRead() +void DownloadDialog::httpReadyRead() { if (file) { file->write(reply->readAll()); } } -void downloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes) +void DownloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes) { ui->progressBar->setMaximum(totalBytes); ui->progressBar->setValue(bytesRead); } -void downloadDialog::fileError() +void DownloadDialog::fileError() { delete file; file = NULL; @@ -119,7 +119,7 @@ void downloadDialog::fileError() } #if 0 -void downloadDialog::closeEvent( QCloseEvent * event) +void DownloadDialog::closeEvent( QCloseEvent * event) { // Delay closing 2 seconds to avoid unpleasant flashing download dialogs QTime closeTime= QTime::currentTime().addSecs(2); diff --git a/companion/src/downloaddialog.h b/companion/src/downloaddialog.h index 90b94b52a..11c4485fb 100644 --- a/companion/src/downloaddialog.h +++ b/companion/src/downloaddialog.h @@ -28,31 +28,37 @@ #include namespace Ui { - class downloadDialog; + class DownloadDialog; } -class downloadDialog : public QDialog +class DownloadDialog : public QDialog { - Q_OBJECT + Q_OBJECT -public: - explicit downloadDialog(QWidget *parent = 0, QString src = "", QString tgt = ""); - ~downloadDialog(); + public: + explicit DownloadDialog(QWidget *parent = 0, QString src = "", QString tgt = ""); + + ~DownloadDialog(); public slots: + virtual void reject() override; -private slots: + private slots: + void fileError(); + void httpFinished(); + void httpReadyRead(); + void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes); -private: + private: #if 0 - void closeEvent( QCloseEvent * event); + void closeEvent(QCloseEvent * event); #endif - Ui::downloadDialog *ui; + Ui::DownloadDialog *ui; QNetworkAccessManager qnam; QNetworkReply *reply; diff --git a/companion/src/downloaddialog.ui b/companion/src/downloaddialog.ui index f51dfd085..280611d75 100644 --- a/companion/src/downloaddialog.ui +++ b/companion/src/downloaddialog.ui @@ -1,7 +1,7 @@ - downloadDialog - + DownloadDialog + 0 @@ -53,7 +53,7 @@ buttonBox accepted() - downloadDialog + DownloadDialog accept() @@ -69,7 +69,7 @@ buttonBox rejected() - downloadDialog + DownloadDialog reject() diff --git a/companion/src/flashfirmwaredialog.cpp b/companion/src/flashfirmwaredialog.cpp index 441a1b7c4..9a2b688ab 100644 --- a/companion/src/flashfirmwaredialog.cpp +++ b/companion/src/flashfirmwaredialog.cpp @@ -36,10 +36,10 @@ #include #endif -FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent): -QDialog(parent), -ui(new Ui::FlashFirmwareDialog), -fwName(g.profile[g.id()].fwName()) +FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::FlashFirmwareDialog), + fwName(g.profile[g.id()].fwName()) { ui->setupUi(this); diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index ca66a845f..07b5c367e 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -184,7 +184,7 @@ MainWindow::~MainWindow() { if (windowsListActions) { delete windowsListActions; - windowsListActions = NULL; + windowsListActions = nullptr; } } @@ -293,7 +293,7 @@ void MainWindow::checkForUpdates() request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); QNetworkReply * repl = networkManager->get(request); if (downloadDialog_forWait) - connect(downloadDialog_forWait, &downloadDialog::rejected, repl, &QNetworkReply::abort); + connect(downloadDialog_forWait, &DownloadDialog::rejected, repl, &QNetworkReply::abort); } void MainWindow::onUpdatesError(const QString &err) @@ -305,7 +305,7 @@ void MainWindow::onUpdatesError(const QString &err) void MainWindow::openUpdatesWaitDialog() { if (!downloadDialog_forWait) { - downloadDialog_forWait = new downloadDialog(NULL, tr("Checking for updates")); + downloadDialog_forWait = new DownloadDialog(nullptr, tr("Checking for updates")); downloadDialog_forWait->show(); } } @@ -315,7 +315,7 @@ void MainWindow::closeUpdatesWaitDialog() if (downloadDialog_forWait) { downloadDialog_forWait->close(); delete downloadDialog_forWait; - downloadDialog_forWait = NULL; + downloadDialog_forWait = nullptr; } } @@ -479,7 +479,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply) if (currentVersion == 0) { QString rn = getCurrentFirmware()->getReleaseNotesUrl(); - QAbstractButton *rnButton = NULL; + QAbstractButton *rnButton = nullptr; msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nVersion %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.") .arg(Firmware::getCurrentVariant()->getId()).arg(fullVersionString)); QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); @@ -508,7 +508,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply) } else if (version > currentVersion) { QString rn = getCurrentFirmware()->getReleaseNotesUrl(); - QAbstractButton *rnButton = NULL; + QAbstractButton *rnButton = nullptr; msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.") .arg(Firmware::getCurrentVariant()->getId()).arg(currentVersionString).arg(fullVersionString)); QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole); @@ -574,7 +574,7 @@ void MainWindow::startFirmwareDownload() if (!filename.isEmpty()) { g.profile[g.id()].fwName(filename); g.flashDir(QFileInfo(filename).dir().absolutePath()); - downloadDialog * dd = new downloadDialog(this, url, filename); + DownloadDialog * dd = new DownloadDialog(this, url, filename); connect(dd, SIGNAL(accepted()), this, SLOT(firmwareDownloadAccepted())); dd->exec(); } @@ -1576,7 +1576,7 @@ void MainWindow::updateWindowActionTitle(const QMdiSubWindow * win, QAction * ac void MainWindow::onSubwindowTitleChanged() { - QMdiSubWindow * win = NULL; + QMdiSubWindow * win = nullptr; if ((win = qobject_cast(sender()->parent()))) updateWindowActionTitle(win); } @@ -1591,7 +1591,7 @@ void MainWindow::onChangeWindowAction(QAction * act) if (!act->isChecked()) return; - QMdiSubWindow * win = NULL; + QMdiSubWindow * win = nullptr; if (act->property("window_ptr").canConvert()) win = act->property("window_ptr").value(); if (win) diff --git a/companion/src/mainwindow.h b/companion/src/mainwindow.h index 542515fb0..222c047e0 100644 --- a/companion/src/mainwindow.h +++ b/companion/src/mainwindow.h @@ -34,7 +34,6 @@ class QAction; class QMenu; class QMdiArea; class QMdiSubWindow; -class QSignalMapper; QT_END_NAMESPACE class MainWindow : public QMainWindow @@ -164,10 +163,9 @@ class MainWindow : public QMainWindow bool checkProfileRadioExists(int profId); QMdiArea *mdiArea; - QSignalMapper *windowMapper; QString installer_fileName; - downloadDialog * downloadDialog_forWait; + DownloadDialog * downloadDialog_forWait; unsigned int checkForUpdatesState; QString firmwareVersionString; diff --git a/companion/src/process_flash.cpp b/companion/src/process_flash.cpp index 6dbcb4525..599d7e653 100644 --- a/companion/src/process_flash.cpp +++ b/companion/src/process_flash.cpp @@ -36,18 +36,18 @@ #include #endif -FlashProcess::FlashProcess(const QString &cmd, const QStringList &args, ProgressWidget *progress): -progress(progress), -cmd(cmd), -args(args), -process(new QProcess(this)), -hasErrors(false), -lfuse(0), -hfuse(0), -efuse(0), -flashPhase(READING) +FlashProcess::FlashProcess(const QString & cmd, const QStringList & args, ProgressWidget * progress): + progress(progress), + cmd(cmd), + args(args), + process(new QProcess(this)), + hasErrors(false), + lfuse(0), + hfuse(0), + efuse(0), + flashPhase(READING) #if !__GNUC__ -, killTimer(NULL) + , killTimer(nullptr) #endif { connect(process, SIGNAL(started()),this, SLOT(onStarted())); @@ -66,7 +66,7 @@ FlashProcess::~FlashProcess() bool FlashProcess::run() { if (!QFile::exists(cmd)) { - QMessageBox::critical(NULL, CPN_STR_APP_NAME, tr("Executable %1 not found").arg(cmd)); + QMessageBox::critical(nullptr, CPN_STR_APP_NAME, tr("Executable %1 not found").arg(cmd)); return false; } @@ -162,7 +162,7 @@ void FlashProcess::analyseStandardOutput(const QString &text) if (text.contains("Complete ")) { #if !__GNUC__ delete killTimer; - killTimer = NULL; + killTimer = nullptr; #endif int start = text.indexOf("Complete "); int end = text.indexOf("%"); @@ -187,6 +187,10 @@ void FlashProcess::analyseStandardOutput(const QString &text) if (text.contains("-E-")) { hasErrors = true; } + + if (text.contains("Cannot open device")) { + hasErrors = true; + } } void FlashProcess::analyseStandardError(const QString &text) @@ -274,15 +278,15 @@ void FlashProcess::errorWizard() } } if (fwexist==false) { - QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr)); + QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr)); } else { Firmware *firmware = getCurrentFirmware(); - QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->getName())); + QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->getName())); } } else if (output.contains("No DFU capable USB device found")){ - QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio does not seem connected to USB or the driver is not initialized!!!.")); + QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio does not seem connected to USB or the driver is not initialized!!!.")); } } diff --git a/companion/src/translations/companion_fr.ts b/companion/src/translations/companion_fr.ts index 337d9cd47..acc370293 100644 --- a/companion/src/translations/companion_fr.ts +++ b/companion/src/translations/companion_fr.ts @@ -3294,7 +3294,7 @@ Si vide, la ligne est toujours active. Flashing done - Programmation Terminé + Programmation terminée