Use PROTOCOL_TELEMETRY_MULTIMODULE for internal multi when available (#7147)
[opentx.git] / companion / src / fwpreferencesdialog.cpp
blobeaee4a7ddd755fc08f8868d014275e6d3695abb7
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #include "fwpreferencesdialog.h"
22 #include "ui_fwpreferencesdialog.h"
23 #include "mainwindow.h"
24 #include "helpers.h"
25 #include "appdata.h"
27 FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget * parent) :
28 QDialog(parent),
29 ui(new Ui::FirmwarePreferencesDialog)
31 ui->setupUi(this);
32 setWindowIcon(CompanionIcon("fwpreferences.png"));
33 initSettings();
34 MainWindow * mw = qobject_cast<MainWindow *>(this->parent());
35 if (mw)
36 connect(mw, &MainWindow::firmwareDownloadCompleted, this, &FirmwarePreferencesDialog::initSettings);
39 FirmwarePreferencesDialog::~FirmwarePreferencesDialog()
41 delete ui;
44 void FirmwarePreferencesDialog::initSettings()
46 ui->fwTypeLbl->setText(g.currentProfile().fwType());
47 int version = g.fwRev.get(g.currentProfile().fwType());
48 if (version > 0)
49 ui->lastRevisionLbl->setText(index2version(version));
50 else
51 ui->lastRevisionLbl->setText(tr("Unknown"));
54 void FirmwarePreferencesDialog::on_checkFWUpdates_clicked()
56 MainWindow * mw = qobject_cast<MainWindow *>(this->parent());
57 if (mw)
58 mw->checkForFirmwareUpdate();
61 void FirmwarePreferencesDialog::on_fw_dnld_clicked()
63 MainWindow * mw = qobject_cast<MainWindow *>(this->parent());
64 if (mw)
65 mw->dowloadLastFirmwareUpdate();
68 void FirmwarePreferencesDialog::on_sd_dnld_clicked()
70 QString url = g.openTxCurrentDownloadBranchUrl() % QStringLiteral("sdcard/");
71 QString fwType = g.profile[g.id()].fwType();
72 QStringList list = fwType.split("-");
73 QString firmware = QString("%1-%2").arg(list[0]).arg(list[1]);
74 if (g.boundedOpenTxBranch() != AppData::BRANCH_NIGHTLY_UNSTABLE) {
75 url.append(QString("%1/").arg(firmware));
77 QDesktopServices::openUrl(url);