diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 1d8bf7b3b..6cdd9deda 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -23,13 +23,10 @@ #include "mainwindow.h" #include "appdata.h" #include "helpers.h" -#include "firmwareinterface.h" -#ifdef JOYSTICKS +#if defined(JOYSTICKS) #include "joystick.h" #include "joystickdialog.h" #endif -#include -#include AppPreferencesDialog::AppPreferencesDialog(QWidget * parent) : QDialog(parent), @@ -63,10 +60,10 @@ AppPreferencesDialog::~AppPreferencesDialog() void AppPreferencesDialog::writeValues() { - g.useCompanionNightlyBuilds(ui->useCompanionNightlyBuilds->isChecked()); g.autoCheckApp(ui->autoCheckCompanion->isChecked()); - g.useFirmwareNightlyBuilds(ui->useFirmwareNightlyBuilds->isChecked()); + g.companionBranch(DownloadBranchType(ui->companionBranch->currentIndex())); g.autoCheckFw(ui->autoCheckFirmware->isChecked()); + g.firmwareBranch(DownloadBranchType(ui->firmwareBranch->currentIndex())); g.showSplash(ui->showSplash->isChecked()); g.simuSW(ui->simuSW->isChecked()); g.removeModelSlots(ui->opt_removeBlankSlots->isChecked()); @@ -137,13 +134,11 @@ void AppPreferencesDialog::initSettings() ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); } -#if defined(ALLOW_NIGHTLY_BUILDS) - ui->useCompanionNightlyBuilds->setChecked(g.useCompanionNightlyBuilds()); - ui->useFirmwareNightlyBuilds->setChecked(g.useFirmwareNightlyBuilds()); -#else - ui->useCompanionNightlyBuilds->hide(); - ui->useFirmwareNightlyBuilds->hide(); +#if !defined(ALLOW_NIGHTLY_BUILDS) + // TODO should we gray out nightly builds here? #endif + ui->firmwareBranch->setCurrentIndex(g.firmwareBranch()); + ui->companionBranch->setCurrentIndex(g.companionBranch()); ui->autoCheckCompanion->setChecked(g.autoCheckApp()); ui->autoCheckFirmware->setChecked(g.autoCheckFw()); ui->showSplash->setChecked(g.showSplash()); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index b0978aab2..a2f06ac00 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -6,8 +6,8 @@ 0 0 - 703 - 534 + 859 + 673 @@ -45,7 +45,7 @@ - 0 + 1 @@ -72,16 +72,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -733,24 +724,15 @@ Mode 4: - - 0 - - - 0 - - - 0 - - - 0 - 5 4 + + 0 + @@ -768,26 +750,6 @@ Mode 4: - - - - Use Companion nightly builds - - - false - - - - - - - Use firmware nightly builds - - - false - - - @@ -808,6 +770,56 @@ Mode 4: + + + + + 0 + 0 + + + + + Use firmware releases (stable) + + + + + Use firmware releases and release candidates (testing) + + + + + Use firmware nightly builds (unstable) + + + + + + + + + 0 + 0 + + + + + Use Companion releases (stable) + + + + + Use Companion release and release candidates (testing) + + + + + Use Companion nightly builds (unstable) + + + + diff --git a/companion/src/constants.h b/companion/src/constants.h index 6b8eac456..096acf0b5 100644 --- a/companion/src/constants.h +++ b/companion/src/constants.h @@ -68,4 +68,12 @@ #define CPN_STR_SW_INDICATOR_NEUT QCoreApplication::translate("RawSwitch", "-") // Switch neutral (middle) position indicator. #define CPN_STR_SW_INDICATOR_REV QCoreApplication::translate("RawSwitch", "!") // Switch reversed logic (NOT) indicator. +enum DownloadBranchType { + BRANCH_RELEASE_STABLE, + BRANCH_RC_TESTING, + BRANCH_NIGHTLY_UNSTABLE +}; + +Q_DECLARE_METATYPE(DownloadBranchType) + #endif // _CONSTANTS_H_ diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 2544aa1ec..0019ac61c 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -30,8 +30,11 @@ using namespace Board; -#define OPENTX_FIRMWARE_DOWNLOADS "https://downloads-22.open-tx.org/firmware" -#define OPENTX_NIGHT_FIRMWARE_DOWNLOADS "https://downloads-22.open-tx.org/nightlies/firmware" +const char * const OPENTX_FIRMWARE_DOWNLOAD_URL[] = { + "https://downloads.open-tx.org/2.2/release/firmware", + "https://downloads.open-tx.org/2.2/rc/firmware", + "https://downloads.open-tx.org/2.2/nightlies/firmware" +}; #define FILE_TYP_GENERAL 1 #define FILE_TYP_MODEL 2 @@ -1077,11 +1080,7 @@ unsigned long OpenTxEepromInterface::loadBackup(RadioData &radioData, const uint QString OpenTxFirmware::getFirmwareBaseUrl() { -#if defined(ALLOW_NIGHTLY_BUILDS) - return (g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_FIRMWARE_DOWNLOADS : OPENTX_FIRMWARE_DOWNLOADS); -#else - return OPENTX_FIRMWARE_DOWNLOADS; -#endif + return OPENTX_FIRMWARE_DOWNLOAD_URL[g.boundedFirmwareBranch()]; } QString OpenTxFirmware::getFirmwareUrl() diff --git a/companion/src/fwpreferencesdialog.cpp b/companion/src/fwpreferencesdialog.cpp index 945b086fd..ac4b59838 100644 --- a/companion/src/fwpreferencesdialog.cpp +++ b/companion/src/fwpreferencesdialog.cpp @@ -21,16 +21,16 @@ #include "fwpreferencesdialog.h" #include "ui_fwpreferencesdialog.h" #include "mainwindow.h" -#include "eeprominterface.h" #include "helpers.h" #include "appdata.h" -#include -#include -#define OPENTX_SDCARD_DOWNLOADS "https://downloads.open-tx.org/2.2/sdcard/" -#define OPENTX_NIGHT_SDCARD_DOWNLOADS "https://downloads.open-tx.org/2.2/nightlies/sdcard/" +const char * const OPENTX_SDCARD_DOWNLOAD_URL[] = { + "https://downloads.open-tx.org/2.2/release/sdcard/", + "https://downloads.open-tx.org/2.2/rc/sdcard/", + "https://downloads.open-tx.org/2.2/nightlies/sdcard/" +}; -FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget *parent) : +FirmwarePreferencesDialog::FirmwarePreferencesDialog(QWidget * parent) : QDialog(parent), ui(new Ui::FirmwarePreferencesDialog) { @@ -55,25 +55,25 @@ void FirmwarePreferencesDialog::initSettings() void FirmwarePreferencesDialog::on_checkFWUpdates_clicked() { - MainWindow * mw = (MainWindow *)this->parent(); + MainWindow * mw = qobject_cast(this->parent()); mw->checkForFirmwareUpdate(); initSettings(); } void FirmwarePreferencesDialog::on_fw_dnld_clicked() { - MainWindow * mw = (MainWindow *)this->parent(); + MainWindow * mw = qobject_cast(this->parent()); mw->dowloadLastFirmwareUpdate(); initSettings(); } void FirmwarePreferencesDialog::on_sd_dnld_clicked() { - QString url = g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_SDCARD_DOWNLOADS : OPENTX_SDCARD_DOWNLOADS; + QString url = OPENTX_SDCARD_DOWNLOAD_URL[g.boundedFirmwareBranch()]; QString fwType = g.profile[g.id()].fwType(); QStringList list = fwType.split("-"); QString firmware = QString("%1-%2").arg(list[0]).arg(list[1]); - if (!g.useFirmwareNightlyBuilds()) { + if (g.boundedFirmwareBranch() != BRANCH_NIGHTLY_UNSTABLE) { url.append(QString("%1/").arg(firmware)); } QDesktopServices::openUrl(url); diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 7cb68bf98..db89b2a71 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -54,7 +54,6 @@ #include #define OPENTX_DOWNLOADS_PAGE_URL "http://www.open-tx.org/downloads" -#define OPENTX_COMPANION_DOWNLOADS "https://downloads-22.open-tx.org/companion" #define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" #ifdef __APPLE__ @@ -69,12 +68,16 @@ #define COMPANION_INSTALL_QUESTION tr("Would you like to launch the installer?") #else #define COMPANION_STAMP "companion-linux.stamp" - #define COMPANION_INSTALLER "" // no automatated updates for linux + #define COMPANION_INSTALLER "" // no automated updates for linux #define COMPANION_FILEMASK "*.*" #define COMPANION_INSTALL_QUESTION tr("Would you like to launch the installer?") #endif -#define OPENTX_NIGHT_COMPANION_DOWNLOADS "https://downloads-22.open-tx.org/nightlies/companion" +const char * const OPENTX_COMPANION_DOWNLOAD_URL[] = { + "https://downloads.open-tx.org/2.2/release/companion", + "https://downloads.open-tx.org/2.2/rc/companion", + "https://downloads.open-tx.org/2.2/nightlies/companion" +}; MainWindow::MainWindow(): downloadDialog_forWait(NULL), @@ -241,11 +244,7 @@ void MainWindow::dowloadLastFirmwareUpdate() QString MainWindow::getCompanionUpdateBaseUrl() { -#if defined(ALLOW_NIGHTLY_BUILDS) - return g.useCompanionNightlyBuilds() ? OPENTX_NIGHT_COMPANION_DOWNLOADS : OPENTX_COMPANION_DOWNLOADS; -#else - return OPENTX_COMPANION_DOWNLOADS; -#endif + return OPENTX_COMPANION_DOWNLOAD_URL[g.boundedCompanionBranch()]; } void MainWindow::checkForUpdates() diff --git a/companion/src/storage/appdata.cpp b/companion/src/storage/appdata.cpp index a50f9fde4..301c9c4d2 100644 --- a/companion/src/storage/appdata.cpp +++ b/companion/src/storage/appdata.cpp @@ -588,15 +588,15 @@ void AppData::init() getset( _libDir, "libraryPath" ,"" ); getset( _snapshotDir, "snapshotpath" ,"" ); getset( _updatesDir, "lastUpdatesDir" ,"" ); - appLogsDir_init(); - // booleans + getset( _firmwareBranch, "firmwareBranch", BRANCH_RELEASE_STABLE); + getset( _companionBranch, "companionBranch", BRANCH_RELEASE_STABLE); + + appLogsDir_init(); enableBackup_init(); backupOnFlash_init(); outputDisplayDetails_init(); checkHardwareCompatibility_init(); - useCompanionNightlyBuilds_init(); - useFirmwareNightlyBuilds_init(); removeModelSlots_init(); maximized_init(); simuSW_init(); diff --git a/companion/src/storage/appdata.h b/companion/src/storage/appdata.h index 0c8df68a8..71b8eda98 100644 --- a/companion/src/storage/appdata.h +++ b/companion/src/storage/appdata.h @@ -25,12 +25,14 @@ #ifndef _APPDATA_H_ #define _APPDATA_H_ + #include #include #include #include #include +#include "constants.h" #include "simulator.h" #define COMPANY "OpenTX" @@ -244,8 +246,6 @@ class AppData: protected CompStoreObj PROPERTY(bool, backupOnFlash, true) PROPERTY(bool, outputDisplayDetails, false) PROPERTY(bool, checkHardwareCompatibility, true) - PROPERTY(bool, useCompanionNightlyBuilds, false) - PROPERTY(bool, useFirmwareNightlyBuilds, false) PROPERTY(bool, removeModelSlots, true) PROPERTY(bool, maximized, false) PROPERTY(bool, simuSW, false) @@ -253,6 +253,9 @@ class AppData: protected CompStoreObj PROPERTY(bool, appDebugLog, false) PROPERTY(bool, fwTraceLog, false) + PROPERTY(unsigned, firmwareBranch, BRANCH_RELEASE_STABLE); + PROPERTY(unsigned, companionBranch, BRANCH_RELEASE_STABLE); + PROPERTY4(bool, jsSupport, js_support ,false) PROPERTY4(bool, showSplash, show_splash ,true) PROPERTY4(bool, snapToClpbrd, snapshot_to_clipboard ,false) @@ -423,6 +426,22 @@ class AppData: protected CompStoreObj bool findPreviousVersionSettings(QString * version); bool importSettings(QString fromVersion); + inline DownloadBranchType boundedFirmwareBranch() { +#if defined(ALLOW_NIGHTLY_BUILDS) + return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(firmwareBranch()), BRANCH_NIGHTLY_UNSTABLE); +#else + return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(firmwareBranch()), BRANCH_RC_TESTING); +#endif + } + + inline DownloadBranchType boundedCompanionBranch() { +#if defined(ALLOW_NIGHTLY_BUILDS) + return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(companionBranch()), BRANCH_NIGHTLY_UNSTABLE); +#else + return qBound(BRANCH_RELEASE_STABLE, DownloadBranchType(companionBranch()), BRANCH_RC_TESTING); +#endif + } + protected: void convertSettings(QSettings & settings);