diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index b4332cfa3..32666bbd6 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -295,8 +295,10 @@ QString Profile::fwName() const { return _fwName; } QString Profile::fwType() const { return _fwType; } QString Profile::name() const { return _name; } QString Profile::sdPath() const { return _sdPath; } +QString Profile::pBackupDir() const { return _pBackupDir; } QString Profile::splashFile() const { return _splashFile; } bool Profile::burnFirmware() const { return _burnFirmware; } +bool Profile::penableBackup() const { return _penableBackup; } bool Profile::renameFwFiles() const { return _renameFwFiles; } int Profile::channelOrder() const { return _channelOrder; } int Profile::defaultMode() const { return _defaultMode; } @@ -322,9 +324,11 @@ void Profile::name (const QString x) { store(x, _name, "Name" void Profile::fwName (const QString x) { store(x, _fwName, "fwName" ,"Profiles", QString("profile%1").arg(index));} void Profile::fwType (const QString x) { store(x, _fwType, "fwType" ,"Profiles", QString("profile%1").arg(index));} void Profile::sdPath (const QString x) { store(x, _sdPath, "sdPath" ,"Profiles", QString("profile%1").arg(index));} +void Profile::pBackupDir (const QString x) { store(x, _pBackupDir, "pBackupDir" ,"Profiles", QString("profile%1").arg(index));} void Profile::splashFile (const QString x) { store(x, _splashFile, "SplashFileName" ,"Profiles", QString("profile%1").arg(index));} void Profile::burnFirmware (const bool x) { store(x, _burnFirmware, "burnFirmware" ,"Profiles", QString("profile%1").arg(index));} void Profile::renameFwFiles (const bool x) { store(x, _renameFwFiles, "rename_firmware_files" ,"Profiles", QString("profile%1").arg(index));} +void Profile::penableBackup (const bool x) { store(x, _penableBackup, "penableBackup" ,"Profiles", QString("profile%1").arg(index));} void Profile::channelOrder (const int x) { store(x, _channelOrder, "default_channel_order" ,"Profiles", QString("profile%1").arg(index));} void Profile::defaultMode (const int x) { store(x, _defaultMode, "default_mode" ,"Profiles", QString("profile%1").arg(index));} @@ -357,9 +361,11 @@ Profile& Profile::operator=(const Profile& rhs) fwName ( rhs.fwName() ); fwType ( rhs.fwType() ); sdPath ( rhs.sdPath() ); + pBackupDir ( rhs.pBackupDir() ); splashFile ( rhs.splashFile() ); burnFirmware ( rhs.burnFirmware() ); renameFwFiles( rhs.renameFwFiles() ); + penableBackup( rhs.penableBackup() ); channelOrder ( rhs.channelOrder() ); defaultMode ( rhs.defaultMode() ); beeper ( rhs.beeper() ); @@ -432,9 +438,11 @@ void Profile::init(int newIndex) _fwType = ""; _name = ""; _sdPath = ""; + _pBackupDir = ""; _splashFile = ""; _burnFirmware = false; _renameFwFiles = false; + _penableBackup = false; _channelOrder = 0; _defaultMode = 1; @@ -454,8 +462,10 @@ void Profile::flush() getset( _fwType, "fwType" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _name, "Name" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _sdPath, "sdPath" ,"" ,"Profiles", QString("profile%1").arg(index)); + getset( _pBackupDir, "pBackupDir" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _splashFile, "SplashFileName" ,"" ,"Profiles", QString("profile%1").arg(index)); getset( _burnFirmware, "burnFirmware" ,false ,"Profiles", QString("profile%1").arg(index)); + getset( _penableBackup, "penableBackup" ,false ,"Profiles", QString("profile%1").arg(index)); getset( _renameFwFiles, "rename_firmware_files" ,false ,"Profiles", QString("profile%1").arg(index)); getset( _channelOrder, "default_channel_order" ,0 ,"Profiles", QString("profile%1").arg(index)); getset( _defaultMode, "default_mode" ,1 ,"Profiles", QString("profile%1").arg(index)); diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 4d6b451f3..0671b60c3 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -107,8 +107,10 @@ class Profile: protected CompStoreObj QString _fwType; QString _name; QString _sdPath; + QString _pBackupDir; QString _splashFile; bool _burnFirmware; + bool _penableBackup; bool _renameFwFiles; int _channelOrder; int _defaultMode; @@ -136,9 +138,11 @@ class Profile: protected CompStoreObj QString fwType() const; QString name() const; QString sdPath() const; + QString pBackupDir() const; QString splashFile() const; bool burnFirmware() const; bool renameFwFiles() const; + bool penableBackup() const; int channelOrder() const; int defaultMode() const; @@ -163,9 +167,11 @@ class Profile: protected CompStoreObj void fwName (const QString); void fwType (const QString); void sdPath (const QString); + void pBackupDir (const QString); void splashFile (const QString); void burnFirmware (const bool); void renameFwFiles (const bool); + void penableBackup (const bool); void channelOrder (const int); void defaultMode (const int); diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index 0232c787c..efac55a3f 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -18,6 +18,10 @@ AppPreferencesDialog::AppPreferencesDialog(QWidget *parent) : ui->setupUi(this); updateLock=false; setWindowIcon(CompanionIcon("apppreferences.png")); + ui->backupPathClear->setIcon(CompanionIcon("clear.png")); + ui->pBackupPathClear->setIcon(CompanionIcon("clear.png")); + ui->libraryPathClear->setIcon(CompanionIcon("clear.png")); + ui->sdPathClear->setIcon(CompanionIcon("clear.png")); initSettings(); connect(ui->downloadVerCB, SIGNAL(currentIndexChanged(int)), this, SLOT(baseFirmwareChanged())); @@ -66,6 +70,8 @@ void AppPreferencesDialog::writeValues() g.profile[g.id()].renameFwFiles(ui->renameFirmware->isChecked()); g.profile[g.id()].burnFirmware(ui->burnFirmware->isChecked()); g.profile[g.id()].sdPath(ui->sdPath->text()); + g.profile[g.id()].pBackupDir(ui->profilebackupPath->text()); + g.profile[g.id()].penableBackup(ui->pbackupEnable->isChecked()); g.profile[g.id()].splashFile(ui->SplashFileName->text()); // The profile name may NEVER be empty @@ -164,6 +170,19 @@ void AppPreferencesDialog::initSettings() ui->stickmodeCB->setCurrentIndex(g.profile[g.id()].defaultMode()); ui->renameFirmware->setChecked(g.profile[g.id()].renameFwFiles()); ui->sdPath->setText(g.profile[g.id()].sdPath()); + ui->profilebackupPath->setText(g.profile[g.id()].pBackupDir()); + if (!g.profile[g.id()].pBackupDir().isEmpty()) { + if (QDir(g.profile[g.id()].pBackupDir()).exists()) { + ui->profilebackupPath->setText(g.backupDir()); + ui->pbackupEnable->setEnabled(true); + ui->pbackupEnable->setChecked(g.profile[g.id()].penableBackup()); + } else { + ui->pbackupEnable->setDisabled(true); + } + } else { + ui->pbackupEnable->setDisabled(true); + } + ui->profileNameLE->setText(g.profile[g.id()].name()); ui->SplashFileName->setText(g.profile[g.id()].splashFile()); @@ -224,8 +243,43 @@ void AppPreferencesDialog::on_backupPathButton_clicked() if (!fileName.isEmpty()) { g.backupDir(fileName); ui->backupPath->setText(fileName); + ui->backupEnable->setEnabled(true); } - ui->backupEnable->setEnabled(true); +} + +void AppPreferencesDialog::on_ProfilebackupPathButton_clicked() +{ + QString fileName = QFileDialog::getExistingDirectory(this,tr("Select your Models and Settings backup folder"), g.backupDir()); + if (!fileName.isEmpty()) { + ui->profilebackupPath->setText(fileName); + ui->pbackupEnable->setEnabled(true); + } +} + +void AppPreferencesDialog::on_sdPathClear_clicked() +{ + g.profile[g.id()].sdPath(""); + ui->sdPath->clear(); +} + +void AppPreferencesDialog::on_pBackupPathClear_clicked() +{ + g.profile[g.id()].pBackupDir(""); + ui->profilebackupPath->clear(); + ui->pbackupEnable->setDisabled(true); +} + +void AppPreferencesDialog::on_backupPathClear_clicked() +{ + g.backupDir(""); + ui->backupPath->clear(); + ui->backupEnable->setDisabled(true); +} + +void AppPreferencesDialog::on_libraryPathClear_clicked() +{ + g.libDir(""); + ui->libraryPath->clear(); } void AppPreferencesDialog::on_ge_pathButton_clicked() diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h index 2e5a3641f..f2e8bd172 100644 --- a/companion/src/apppreferencesdialog.h +++ b/companion/src/apppreferencesdialog.h @@ -47,8 +47,13 @@ class AppPreferencesDialog : public QDialog void on_snapshotPathButton_clicked(); void on_snapshotClipboardCKB_clicked(); void on_backupPathButton_clicked(); + void on_ProfilebackupPathButton_clicked(); void on_ge_pathButton_clicked(); - + void on_sdPathClear_clicked(); + void on_pBackupPathClear_clicked(); + void on_backupPathClear_clicked(); + void on_libraryPathClear_clicked(); + void on_sdPathButton_clicked(); void on_removeProfileButton_clicked(); void on_SplashSelect_clicked(); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index bbbfc8174..e5e531b76 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -6,7 +6,7 @@ 0 0 - 685 + 686 550 @@ -26,13 +26,7 @@ Edit Settings - - 2 - - - 6 - - + Qt::Horizontal @@ -42,7 +36,7 @@ - + 0 @@ -51,110 +45,8 @@ Radio Profile - - - - - Open Folder - - - - - - - - 0 - 0 - - - - Default Channel Order - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Build Options - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Menu Language - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - Default Stick Mode - - - - - - - Select Image - - - - - - - true - - - General Settings Label - - - - - - - Qt::Horizontal - - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Splash Screen - - - - + + @@ -167,51 +59,17 @@ - - - - Clear Image + + + + + + + Qt::Horizontal - - - - - 0 - 0 - - - - - 128 - 64 - - - - - 212 - 64 - - - - QFrame::Panel - - - QFrame::Plain - - - 1 - - - - - - true - - - - + @@ -234,57 +92,24 @@ - - - - Qt::Horizontal + + + + true - - - - Qt::Horizontal - - - - - - - - 75 - true - - + + - Other Settings - - - - - - - General Settings - - - - - - - - 0 - 0 - - - - SD Structure path + Menu Language Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + QLayout::SetDefaultConstraint @@ -338,14 +163,46 @@ May be different from firmware language - - - - true + + + + Build Options + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + + + + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Splash Screen + + + + true @@ -355,7 +212,80 @@ May be different from firmware language - + + + + + 0 + 0 + + + + + 128 + 64 + + + + + 212 + 64 + + + + QFrame::Panel + + + QFrame::Plain + + + 1 + + + + + + true + + + + + + + Qt::Horizontal + + + + + + + + 75 + true + + + + Other Settings + + + + + + + + 0 + 0 + + + + SD Structure path + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + true @@ -365,7 +295,130 @@ May be different from firmware language - + + + + + 0 + 0 + + + + + 16 + 16 + + + + + + + + :/themes/classic/16/clear.png:/themes/classic/16/clear.png + + + + + + + Open Folder + + + + + + + The profile specific folder, if set, will override general Backup folder + + + Backup folder + + + + + + + If set it will override the application general setting + + + true + + + + + + + + 16 + 16 + + + + + 16 + 16 + + + + + + + + :/themes/classic/16/clear.png:/themes/classic/16/clear.png + + + + + + + The profile specific folder, if set, will override general Backup folder + + + Open Folder + + + + + + + if set, will override general backup enable + + + Enable automatic backup before writing firmware + + + + + + + General Settings + + + + + + + true + + + General Settings Label + + + + + + + + 0 + 0 + + + + Default Stick Mode + + + + @@ -419,7 +472,23 @@ Mode 4: - + + + + + 0 + 0 + + + + Default Channel Order + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + @@ -567,31 +636,21 @@ Mode 4: - - - - - - - Remove Profile - - - - + Append version number to FW file name - + Offer to write FW to Tx after download - + Qt::Vertical @@ -604,6 +663,27 @@ Mode 4: + + + + Clear Image + + + + + + + Select Image + + + + + + + Remove Profile + + + @@ -611,17 +691,7 @@ Mode 4: Application Settings - - - - Show splash screen when Companion starts - - - true - - - - + Automatic check for Companion updates @@ -631,28 +701,38 @@ Mode 4: - + + + + Show splash screen when Companion starts + + + true + + + + Enable automatic backup before writing firmware - + Qt::Horizontal - + Qt::Horizontal - + Automatic check for OpenTX firmware updates @@ -672,19 +752,6 @@ Mode 4: - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -698,7 +765,7 @@ Mode 4: - + Open Folder @@ -731,21 +798,21 @@ Mode 4: - + Find Executable - + Qt::Horizontal - + Open Folder @@ -772,26 +839,6 @@ Mode 4: - - - - - 0 - 0 - - - - - Only show user splash images - - - - - Show user and companion splash images - - - - @@ -834,20 +881,55 @@ Mode 4: - - + + Qt::Horizontal - + + + + + + Use model wizard when creating a new model + + + + + + - 40 - 20 + 16 + 16 - + + + + + + :/themes/classic/16/clear.png:/themes/classic/16/clear.png + + - + + + + + 16 + 16 + + + + + + + + :/themes/classic/16/clear.png:/themes/classic/16/clear.png + + + + @@ -860,18 +942,24 @@ Mode 4: - - - - Qt::Horizontal - - - - - - - Use model wizard when creating a new model + + + + + 0 + 0 + + + + Only show user splash images + + + + + Show user and companion splash images + + @@ -1050,7 +1138,6 @@ Mode 4: tabWidget - profileNameLE removeProfileButton downloadVerCB langCombo