void Dialog::onDownloadFinished() { QNetworkReply *reply = qobject_cast<QNetworkReply*>(QObject::sender()); if (!reply) { // bail out, nothing to do ui->upgradeLog->appendPlainText("Download failed, invalid context"); return; } if (loading) { onCancelButtonClicked(); ui->upgradeLog->appendPlainText(tr("Still flashing. Waiting for firmware flashing to complete..")); } else { // Reset progress ui->upgradeProgressBar->setValue(0); // Pick file QString fileName = lastFilename; qDebug() << "Handling filename:" << fileName; // Store file in download location QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { ui->upgradeLog->appendPlainText(tr("Could not open %s for writing: %s\n").arg(fileName).arg(file.errorString())); return; } file.write(reply->readAll()); file.close(); if (lastFilename.contains("px4io")) { // Done, bail out return; } if (fileName.length() > 0) { // Got a filename, upload onLoadStart(); lastFilename = fileName; worker = QGCFirmwareUpgradeWorker::putWorkerInThread(fileName); // Hook up status from worker to progress bar connect(worker, SIGNAL(upgradeProgressChanged(int)), ui->upgradeProgressBar, SLOT(setValue(int))); // Hook up text from worker to label connect(worker, SIGNAL(upgradeStatusChanged(QString)), ui->upgradeLog, SLOT(appendPlainText(QString))); // Hook up error handling //connect(worker, SIGNAL(error(QString)), ui->upgradeLog, SLOT(appendPlainText(QString))); // Hook up status from worker to this class connect(worker, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool))); // Make sure user gets the board going now //QMessageBox msgBox; //msgBox.setText(" Please unplug your PX4 board now and plug it back in"); //msgBox.exec(); } }
void load( const std::string& url, const Callback& callback, const std::string& texturePath ) { onLoadStart(); loadJSON( *this, url, callback, texturePath ); }