Files
edgetx-gx12/companion/src/updates/updatefirmware.cpp
T
ulfhedlundandGitHub e4fc166e77 feat: Updated all Swedish Companion translations, minor changes to radio translations 🇸🇪 (#2321)
* New translations for download and update functionality (#2148)

* Minor changes only

* Added translations for setName

* Regenerated translation file using QT Linguist tool "lupdate", now complete to >99%

Regenerated Swedish translation file for Companion, using "lupdate" tool as described here: https://doc.qt.io/qt-5/qtlinguist-index.html.

The result:
Updating 'companion/src/translations/companion_sv.ts'...
    Found 2833 source text(s) (185 new and 2648 already existing)
    Removed 529 obsolete entries
    Number heuristic provided 3 translation(s)
    Same-text heuristic provided 29 translation(s)

Then reviewed and added all missing translations.

* Changes after PR review by @pfeerick

* fix: Re-add missing `TR_SF_SET_SCREEN`
2022-09-18 20:17:03 +10:00

104 lines
3.2 KiB
C++

/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "updatefirmware.h"
#include "appdata.h"
#include "flashfirmwaredialog.h"
UpdateFirmware::UpdateFirmware(QWidget * parent) :
UpdateInterface(parent)
{
setName(tr("Firmware"));
setRepo(QString(GH_REPOS_EDGETX).append("/edgetx"));
setReleasesNightlyName("nightly");
dfltParams->data.flags = UPDFLG_Common | UPDFLG_Locked | UPDFLG_AsyncInstall;
UpdateParameters::AssetParams &ap = dfltParams->addAsset();
ap.filterType = UpdateParameters::UFT_Startswith;
ap.filter = "edgetx-firmware";
ap.maxExpected = 1;
ap.flags = dfltParams->data.flags | UPDFLG_CopyFiles;
ap.destSubDir = "FIRMWARE";
ap.copyFilterType = UpdateParameters::UFT_Expression;
ap.copyFilter = QString("^%FWFLAVOUR%-.*\\.bin$");
}
bool UpdateFirmware::asyncInstall()
{
//reportProgress(tr("Write firmware to radio: %1").arg(g.currentProfile().burnFirmware() ? tr("true") : tr("false")), QtDebugMsg);
if (!g.currentProfile().burnFirmware())
return true;
progressMessage(tr("Install"));
assets->setFilterFlags(UPDFLG_AsyncInstall);
//reportProgress(tr("Asset filter applied: %1 Assets found: %2").arg(updateFlagsToString(UPDFLG_AsyncInstall)).arg(assets->count()), QtDebugMsg);
if (assets->count() != 1) {
reportProgress(tr("Expected 1 asset for install but none found"), QtCriticalMsg);
return false;
}
QString destPath = updateDir;
if (!assets->subDirectory().isEmpty())
destPath.append("/" % assets->subDirectory());
const UpdateParameters::AssetParams &ap = runParams->data.assets.at(0);
QString pattern(runParams->buildFilterPattern(ap.copyFilterType, ap.copyFilter));
QRegularExpression filter(pattern, QRegularExpression::CaseInsensitiveOption);
QDirIterator it(destPath);
bool found = false;
while (it.hasNext())
{
QFileInfo file(it.next());
if ((!filter.pattern().isEmpty()) && (!file.fileName().contains(filter)))
continue;
destPath.append("/" % file.fileName());
found = true;
break;
}
if (!found) {
reportProgress(tr("Firmware not found in %1 using filter %2").arg(destPath).arg(filter.pattern()), QtCriticalMsg);
return false;
}
g.currentProfile().fwName(destPath);
int ret = QMessageBox::question(this, CPN_STR_APP_NAME, tr("Write the updated firmware to the radio now ?"), QMessageBox::Yes | QMessageBox::No);
if (ret == QMessageBox::Yes) {
FlashFirmwareDialog *dlg = new FlashFirmwareDialog(this);
dlg->exec();
dlg->deleteLater();
}
return true;
}