[companion] Adjust GVAR not possible in global functions (fix #5425)
[opentx.git] / companion / src / fwpreferencesdialog.cpp
blob945b086fd7164d1982bb48bc7f6e5e35c5fa2550
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 "eeprominterface.h"
25 #include "helpers.h"
26 #include "appdata.h"
27 #include <QDesktopServices>
28 #include <QtGui>
30 #define OPENTX_SDCARD_DOWNLOADS "https://downloads.open-tx.org/2.2/sdcard/"
31 #define OPENTX_NIGHT_SDCARD_DOWNLOADS "https://downloads.open-tx.org/2.2/nightlies/sdcard/"
33 FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget *parent) :
34 QDialog(parent),
35 ui(new Ui::FirmwarePreferencesDialog)
37 ui->setupUi(this);
38 setWindowIcon(CompanionIcon("fwpreferences.png"));
39 initSettings();
42 FirmwarePreferencesDialog::~FirmwarePreferencesDialog()
44 delete ui;
47 void FirmwarePreferencesDialog::initSettings()
49 ui->fwTypeLbl->setText(g.profile[g.id()].fwType());
50 int version = g.fwRev.get(g.profile[g.id()].fwType());
51 if (version > 0) {
52 ui->lastRevisionLbl->setText(index2version(version));
56 void FirmwarePreferencesDialog::on_checkFWUpdates_clicked()
58 MainWindow * mw = (MainWindow *)this->parent();
59 mw->checkForFirmwareUpdate();
60 initSettings();
63 void FirmwarePreferencesDialog::on_fw_dnld_clicked()
65 MainWindow * mw = (MainWindow *)this->parent();
66 mw->dowloadLastFirmwareUpdate();
67 initSettings();
70 void FirmwarePreferencesDialog::on_sd_dnld_clicked()
72 QString url = g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_SDCARD_DOWNLOADS : OPENTX_SDCARD_DOWNLOADS;
73 QString fwType = g.profile[g.id()].fwType();
74 QStringList list = fwType.split("-");
75 QString firmware = QString("%1-%2").arg(list[0]).arg(list[1]);
76 if (!g.useFirmwareNightlyBuilds()) {
77 url.append(QString("%1/").arg(firmware));
79 QDesktopServices::openUrl(url);