diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index db50261df..d49f7a5af 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -735,6 +735,9 @@ AppData::AppData() getset( _backupOnFlash, "backupOnFlash" ,true ); getset( _checkHardwareCompatibility, "checkHardwareCompatibility" ,true ); + getset( _useCompanionNightlyBuilds, "useCompanionNightlyBuilds" ,false ); + getset( _useFirmwareNightlyBuilds, "useFirmwareNightlyBuilds" ,false ); + getset( _jsSupport, "js_support" ,false ); getset( _maximized, "maximized" ,false ); getset( _showSplash, "show_splash" ,true ); diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 27d019779..abb2b7eab 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -216,6 +216,8 @@ class AppData: protected CompStoreObj BOOL_PROPERTY(outputDisplayDetails, false) BOOL_PROPERTY(backupOnFlash, true) BOOL_PROPERTY(checkHardwareCompatibility, true) + BOOL_PROPERTY(useCompanionNightlyBuilds, false) + BOOL_PROPERTY(useFirmwareNightlyBuilds, false) // All the global variables public: diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index d84b092e3..84616e7f4 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -41,8 +41,10 @@ AppPreferencesDialog::~AppPreferencesDialog() void AppPreferencesDialog::writeValues() { - g.autoCheckApp(ui->startupCheck_companion9x->isChecked()); - g.autoCheckFw(ui->startupCheck_fw->isChecked()); + g.useCompanionNightlyBuilds(ui->useCompanionNightlyBuilds->isChecked()); + g.autoCheckApp(ui->autoCheckCompanion->isChecked()); + g.useFirmwareNightlyBuilds(ui->useFirmwareNightlyBuilds->isChecked()); + g.autoCheckFw(ui->autoCheckFirmware->isChecked()); g.showSplash(ui->showSplash->isChecked()); g.simuSW(ui->simuSW->isChecked()); g.useWizard(ui->modelWizard_CB->isChecked()); @@ -107,8 +109,10 @@ void AppPreferencesDialog::initSettings() ui->snapshotPath->setDisabled(true); ui->snapshotPathButton->setDisabled(true); } - ui->startupCheck_companion9x->setChecked(g.autoCheckApp()); - ui->startupCheck_fw->setChecked(g.autoCheckFw()); + ui->useCompanionNightlyBuilds->setChecked(g.useCompanionNightlyBuilds()); + ui->autoCheckCompanion->setChecked(g.autoCheckApp()); + ui->useFirmwareNightlyBuilds->setChecked(g.useFirmwareNightlyBuilds()); + ui->autoCheckFirmware->setChecked(g.autoCheckFw()); ui->showSplash->setChecked(g.showSplash()); ui->historySize->setValue(g.historySize()); ui->backLightColor->setCurrentIndex(g.backLight()); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index 2b68b6c6c..dae216aca 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -39,7 +39,7 @@ - 0 + 1 @@ -645,8 +645,8 @@ Mode 4: Application Settings - - + + Automatic check for Companion updates @@ -665,7 +665,7 @@ Mode 4: - + Enable automatic backup before writing firmware @@ -679,24 +679,7 @@ Mode 4: - - - - Qt::Horizontal - - - - - - - Automatic check for OpenTX firmware updates - - - true - - - - + Qt::Vertical @@ -709,7 +692,24 @@ Mode 4: - + + + + Qt::Horizontal + + + + + + + Automatic check for OpenTX firmware updates + + + true + + + + @@ -749,7 +749,7 @@ Mode 4: - + @@ -784,14 +784,14 @@ Mode 4: - + Automatic Backup Folder - + Qt::Horizontal @@ -805,7 +805,7 @@ Mode 4: - + true @@ -815,7 +815,7 @@ Mode 4: - + @@ -835,7 +835,7 @@ Mode 4: - + @@ -848,7 +848,7 @@ Mode 4: - + Open Folder @@ -875,13 +875,33 @@ Mode 4: - + Open Folder + + + + Use OpenTX firmware nightly builds + + + false + + + + + + + Use Companion nightly builds + + + false + + + @@ -1112,8 +1132,8 @@ Mode 4: historySize showSplash modelWizard_CB - startupCheck_fw - startupCheck_companion9x + autoCheckFirmware + autoCheckCompanion backupPath backupPathButton backupEnable diff --git a/companion/src/firmwares/opentx/opentxinterface.cpp b/companion/src/firmwares/opentx/opentxinterface.cpp index 5913a5446..744223f65 100644 --- a/companion/src/firmwares/opentx/opentxinterface.cpp +++ b/companion/src/firmwares/opentx/opentxinterface.cpp @@ -1048,7 +1048,7 @@ bool OpenTxEepromInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, in QString OpenTxFirmware::getFirmwareUrl() { - QString url = OPENTX_FIRMWARE_DOWNLOADS; + QString url = (g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_FIRMWARE_DOWNLOADS : OPENTX_FIRMWARE_DOWNLOADS); switch (board) { case BOARD_STOCK: case BOARD_M128: @@ -1072,16 +1072,16 @@ QString OpenTxFirmware::getFirmwareUrl() QString OpenTxFirmware::getReleaseNotesUrl() { - QString url = OPENTX_FIRMWARE_DOWNLOADS; + QString url = (g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_FIRMWARE_DOWNLOADS : OPENTX_FIRMWARE_DOWNLOADS); url.append("/releasenotes.txt"); return url; } QString OpenTxFirmware::getStampUrl() { - QString url = OPENTX_FIRMWARE_DOWNLOADS; - url.append("/stamp-opentx.txt"); - return url; + QString url = (g.useFirmwareNightlyBuilds() ? OPENTX_NIGHT_FIRMWARE_DOWNLOADS : OPENTX_FIRMWARE_DOWNLOADS); + url.append("/stamp-opentx.txt"); + return url; } void addOpenTxCommonOptions(OpenTxFirmware * firmware) diff --git a/companion/src/firmwares/opentx/opentxinterface.h b/companion/src/firmwares/opentx/opentxinterface.h index aa2a2e512..e43d7cbcb 100644 --- a/companion/src/firmwares/opentx/opentxinterface.h +++ b/companion/src/firmwares/opentx/opentxinterface.h @@ -19,7 +19,8 @@ #include "eeprominterface.h" -#define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-21.open-tx.org/firmware" +#define OPENTX_FIRMWARE_DOWNLOADS "http://downloads-21.open-tx.org/firmware" +#define OPENTX_NIGHT_FIRMWARE_DOWNLOADS "http://downloads-21.open-tx.org/nightly/firmware" class RleFile; diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 754d849a0..49b2ed865 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -1017,27 +1017,36 @@ QPixmap makePixMap( QImage image, QString firmwareType ) return(QPixmap::fromImage(image)); } -int version2index(QString version) +int version2index(const QString & version) { - QStringList parts = version.split('.'); - int result = 0; - if (parts.size() > 2) - result = parts[2].toInt(); + int result = 999; + QStringList parts = version.split(":n"); if (parts.size() > 1) - result += 100 * parts[1].toInt(); + result = parts[1].toInt(); // nightly build + parts = parts[0].split('.'); + if (parts.size() > 2) + result += 1000 * parts[2].toInt(); + if (parts.size() > 1) + result += 100000 * parts[1].toInt(); if (parts.size() > 0) - result += 10000 * parts[0].toInt(); + result += 10000000 * parts[0].toInt(); return result; } QString index2version(int index) { - if (index >= 19900) { + if (index >= 19900000) { + int nightly = index % 1000; + index /= 1000; int revision = index % 100; index /= 100; int minor = index % 100; int major = index / 100; - return QString("%1.%2.%3").arg(major).arg(minor).arg(revision); + QString result = QString("%1.%2.%3").arg(major).arg(minor).arg(revision); + if (nightly > 0 && nightly < 999) { + result += QString(":n%1").arg(nightly); + } + return result; } else { return QString(); diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 69d5d56c6..5e3c40503 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -162,7 +162,7 @@ QVector findWidgets(QObject * object, const QString & name) // Format a pixmap to fit on the radio using a specific firmware QPixmap makePixMap( QImage image, QString firmwareType ); -int version2index(QString version); +int version2index(const QString & version); QString index2version(int index); class QTimeS : public QTime diff --git a/companion/src/mainwindow.cpp b/companion/src/mainwindow.cpp index 8231c3ba7..6688efbe7 100644 --- a/companion/src/mainwindow.cpp +++ b/companion/src/mainwindow.cpp @@ -70,15 +70,16 @@ #include "radiointerface.h" #include "progressdialog.h" -#define OPENTX_COMPANION_DOWNLOADS "http://downloads-21.open-tx.org/companion" -#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" +#define OPENTX_COMPANION_DOWNLOADS "http://downloads-21.open-tx.org/companion" +#define OPENTX_NIGHT_COMPANION_DOWNLOADS "http://downloads-21.open-tx.org/nightly/companion" +#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2" #ifdef __APPLE__ - #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-macosx.stamp" - #define C9X_INSTALLER "/companion-macosx-%1.dmg" + #define COMPANION_STAMP "companion-macosx.stamp" + #define COMPANION_INSTALLER "companion-macosx-%1.dmg" #else - #define C9X_STAMP OPENTX_COMPANION_DOWNLOADS "/companion-windows.stamp" - #define C9X_INSTALLER "/companion-windows-%1.exe" + #define COMPANION_STAMP "companion-windows.stamp" + #define COMPANION_INSTALLER "companion-windows-%1.exe" #endif #if defined WIN32 || !defined __GNUC__ @@ -228,7 +229,7 @@ void MainWindow::checkForUpdates() // TODO why create each time a network manager? networkManager = new QNetworkAccessManager(this); connect(networkManager, SIGNAL(finished(QNetworkReply*)),this, SLOT(checkForCompanionUpdateFinished(QNetworkReply*))); - QNetworkRequest request(QUrl(C9X_STAMP)); + QNetworkRequest request(QUrl(QString("%1/%2").arg(g.useCompanionNightlyBuilds() ? OPENTX_NIGHT_COMPANION_DOWNLOADS : OPENTX_COMPANION_DOWNLOADS).arg(COMPANION_STAMP))); request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); networkManager->get(request); } @@ -289,13 +290,13 @@ void MainWindow::checkForCompanionUpdateFinished(QNetworkReply * reply) if (ret == QMessageBox::Yes) { #if defined __APPLE__ - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(C9X_INSTALLER).arg(version)); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(COMPANION_INSTALLER).arg(version)); #else - QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(C9X_INSTALLER).arg(version), tr("Executable (*.exe)")); + QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), g.updatesDir() + QString(COMPANION_INSTALLER).arg(version), tr("Executable (*.exe)")); #endif if (!fileName.isEmpty()) { g.updatesDir(QFileInfo(fileName).dir().absolutePath()); - downloadDialog * dd = new downloadDialog(this, QString(OPENTX_COMPANION_DOWNLOADS C9X_INSTALLER).arg(version), fileName); + downloadDialog * dd = new downloadDialog(this, QString("%1/%2").arg(g.useCompanionNightlyBuilds() ? OPENTX_NIGHT_COMPANION_DOWNLOADS : OPENTX_COMPANION_DOWNLOADS).arg(QString(COMPANION_INSTALLER).arg(version)), fileName); installer_fileName = fileName; connect(dd, SIGNAL(accepted()), this, SLOT(updateDownloaded())); dd->exec();