diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 96f5268c3..17787f9c0 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -60,13 +60,22 @@ void appPreferencesDialog::writeValues() g.profile[g.id()].defaultMode(ui->stickmodeCB->currentIndex()); g.profile[g.id()].renameFwFiles(ui->renameFirmware->isChecked()); g.profile[g.id()].burnFirmware(ui->burnFirmware->isChecked()); - g.profile[g.id()].name(ui->profileNameLE->text()); g.profile[g.id()].sdPath(ui->sdPath->text()); g.profile[g.id()].splashFile(ui->SplashFileName->text()); - g.profile[g.id()].fwName(ui->fwNameLE->text()); - g.profile[g.id()].fwType(ui->fwTypeLE->text()); - - saveProfile(); + + // The profile name may NEVER be empty + if (ui->profileNameLE->text().isEmpty()) + g.profile[g.id()].name(tr("My Radio")); + else + g.profile[g.id()].name(ui->profileNameLE->text()); + + // If a new radio type has been choosen, several things need to change + if ( initialRadioType != ui->radioCB->currentIndex()) + { + g.profile[g.id()].fwName(""); + g.profile[g.id()].fwType(getDefaultFwType(ui->radioCB->currentIndex())); + current_firmware_variant = GetFirmwareVariant(g.profile[g.id()].fwType()); + } } void appPreferencesDialog::on_snapshotPathButton_clicked() @@ -146,10 +155,11 @@ void appPreferencesDialog::initSettings() ui->renameFirmware->setChecked(g.profile[g.id()].renameFwFiles()); ui->sdPath->setText(g.profile[g.id()].sdPath()); ui->profileNameLE->setText(g.profile[g.id()].name()); - ui->fwNameLE->setText(g.profile[g.id()].fwName()); - ui->fwTypeLE->setText(g.profile[g.id()].fwType()); ui->SplashFileName->setText(g.profile[g.id()].splashFile()); + initialRadioType = getRadioType(g.profile[g.id()].fwType()); + ui->radioCB->setCurrentIndex(initialRadioType); + displayImage( g.profile[g.id()].splashFile() ); } @@ -237,23 +247,6 @@ void appPreferencesDialog::on_sdPathButton_clicked() } } -void appPreferencesDialog::saveProfile() -{ - // The profile name may NEVER be empty - if (ui->profileNameLE->text().isEmpty()) - ui->profileNameLE->setText("----"); - - g.profile[g.id()].name( ui->profileNameLE->text() ); - g.profile[g.id()].channelOrder( ui->channelorderCB->currentIndex()); - g.profile[g.id()].defaultMode( ui->stickmodeCB->currentIndex()); - g.profile[g.id()].burnFirmware( ui->burnFirmware->isChecked()); - g.profile[g.id()].renameFwFiles( ui->renameFirmware->isChecked()); - g.profile[g.id()].sdPath( ui->sdPath->text()); - g.profile[g.id()].splashFile( ui->SplashFileName->text()); - g.profile[g.id()].fwName( ui->fwNameLE->text()); - g.profile[g.id()].fwType( ui->fwTypeLE->text()); -} - void appPreferencesDialog::on_removeProfileButton_clicked() { if ( g.id() == 0 ) @@ -266,6 +259,7 @@ void appPreferencesDialog::on_removeProfileButton_clicked() } } + bool appPreferencesDialog::displayImage( QString fileName ) { // Start by clearing the pixmap @@ -310,3 +304,4 @@ void appPreferencesDialog::on_clearImageButton_clicked() { + diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index 18ce2f1e3..46bdf3156 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -21,10 +21,10 @@ public: Joystick *joystick; private: + int initialRadioType; Ui::appPreferencesDialog *ui; void initSettings(); bool displayImage( QString fileName ); - void saveProfile(); void loadProfileString(QString profile, QString label); void loadFromProfile(); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index bdaaff9d4..f5d4b9deb 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 685 - 442 + 462 @@ -26,21 +26,12 @@ Edit Settings - - 6 - - - 6 - - - 6 - - - 6 - 2 + + 6 + @@ -502,7 +493,7 @@ Radio Settings Profile - + @@ -556,7 +547,7 @@ Mode 4: - + @@ -706,7 +697,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -726,7 +717,7 @@ This is used by the templated to determine which channel goes to what number out - + Qt::Vertical @@ -739,7 +730,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -752,7 +743,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -768,14 +759,14 @@ This is used by the templated to determine which channel goes to what number out - + Append version number to FW file name - + @@ -791,7 +782,7 @@ This is used by the templated to determine which channel goes to what number out - + true @@ -813,7 +804,7 @@ This is used by the templated to determine which channel goes to what number out - + Qt::Horizontal @@ -826,35 +817,35 @@ This is used by the templated to determine which channel goes to what number out - + Offer to write FW to Tx after download - + Remove Profile - + Open Folder - + Qt::Horizontal - + true @@ -876,46 +867,34 @@ This is used by the templated to determine which channel goes to what number out - - - - Firmware Variant - - - - - - - false - - - - 350 - 0 - - - - - 350 - 16777215 - - - - - + Select Image - + + + + Radio Type + + + + Clear Image + + + + Qt::Horizontal + + + @@ -932,7 +911,7 @@ This is used by the templated to determine which channel goes to what number out - + @@ -969,37 +948,43 @@ This is used by the templated to determine which channel goes to what number out - - - - Qt::Horizontal - - - - - - - Firmware File - - - - - - - false - - - - 350 - 0 - - - - - 350 - 16777215 - - + + + + + 9X + + + + + 9X with m128 + + + + + 9XR + + + + + 9XR with m128 + + + + + Gruvin9x Board + + + + + Sky9x Board + + + + + Taranis + + diff --git a/companion/src/fwpreferencesdialog.ui b/companion/src/fwpreferencesdialog.ui index 28585c2ac..d095e2cb7 100644 --- a/companion/src/fwpreferencesdialog.ui +++ b/companion/src/fwpreferencesdialog.ui @@ -157,7 +157,11 @@ - + + + false + + diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index e0cd7b91c..17d908ecc 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -969,3 +969,27 @@ QPixmap makePixMap( QImage image, QString firmwareType ) } return(QPixmap::fromImage(image)); } + +int getRadioType(QString firmwareType) +{ + if (firmwareType.contains( "taranis" )) return 6; + if (firmwareType.contains( "sky9x" )) return 5; + if (firmwareType.contains( "gruvin9x")) return 4; + if (firmwareType.contains( "9xr128" )) return 3; + if (firmwareType.contains( "9xr" )) return 2; + if (firmwareType.contains( "9x128" )) return 1; + return 0; // 9x +} + +QString getDefaultFwType( int radioType ) +{ + switch (radioType){ + case 6: return "opentx-taranis-en"; + case 5: return "opentx-sky9x-en"; + case 4: return "opentx-gruvin9x-en"; + case 3: return "opentx-9xr128-en"; + case 2: return "opentx-9xr-en"; + case 1: return "opentx-9x128-en"; + default: return "opentx-9x-en"; + } +} diff --git a/companion/src/helpers.h b/companion/src/helpers.h index 5d667e5d8..857d66749 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -128,6 +128,13 @@ QString getFrSkySrc(int index); void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx); +// Format a pixmap to fit on the radio using a specific firmware QPixmap makePixMap( QImage image, QString firmwareType ); +// Return a radio type derived from a firmware type string +int getRadioType(QString firmwareType); + +// Return the default firmware string for a specified radio +QString getDefaultFwType( int radioType ); + #endif // HELPERS_H