diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp
index b4332cfa3..3a4de77f1 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));
@@ -682,8 +692,8 @@ AppData::AppData()
settings.remove("compilation-server");
// Load and store all variables. Use default values if setting values are missing
- QString _tempString; // Do not touch. Do not change the settings version before a new verson update!
- getset( _tempString, "settings_version" ,"20" ); // This is a version marker. Will be used to upgrade the settings later on.
+ QString _tempString; // Do not touch. Do not change the settings version before a new verson update!
+ getset( _tempString, "settings_version" ,"210" ); // This is a version marker. Will be used to upgrade the settings later on.
getset( _recentFiles, "recentFileList" ,"" );
getset( _mainWinGeo, "mainWindowGeometry" ,"" );
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..0e6830dc4 100644
--- a/companion/src/apppreferencesdialog.cpp
+++ b/companion/src/apppreferencesdialog.cpp
@@ -66,6 +66,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 +166,18 @@ 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());
+ if (!g.profile[g.id()].pBackupDir().isEmpty()) {
+ if (QDir(g.profile[g.id()].pBackupDir()).exists()) {
+ ui->profilebackupPath->setText(g.profile[g.id()].pBackupDir());
+ 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 +238,17 @@ void AppPreferencesDialog::on_backupPathButton_clicked()
if (!fileName.isEmpty()) {
g.backupDir(fileName);
ui->backupPath->setText(fileName);
+ 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);
}
- ui->backupEnable->setEnabled(true);
}
void AppPreferencesDialog::on_ge_pathButton_clicked()
diff --git a/companion/src/apppreferencesdialog.h b/companion/src/apppreferencesdialog.h
index 2e5a3641f..bace7c642 100644
--- a/companion/src/apppreferencesdialog.h
+++ b/companion/src/apppreferencesdialog.h
@@ -47,8 +47,9 @@ 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_sdPathButton_clicked();
void on_removeProfileButton_clicked();
void on_SplashSelect_clicked();
diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui
index bbbfc8174..bb814f702 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,17 +212,150 @@ 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
- true
+ false
- -
+
-
+
+
+ The profile specific folder, if set, will override general Backup folder
+
+
+ Backup folder
+
+
+
+ -
+
+
+ If set it will override the application general setting
+
+
+ false
+
+
+
+ -
+
+
+ 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 +409,23 @@ Mode 4:
- -
+
-
+
+
+
+ 0
+ 0
+
+
+
+ Default Channel Order
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+
+ -
@@ -567,31 +573,21 @@ Mode 4:
- -
-
-
- -
-
-
- Remove Profile
-
-
-
- -
+
-
Append version number to FW file name
- -
+
-
Offer to write FW to Tx after download
- -
+
-
Qt::Vertical
@@ -604,6 +600,44 @@ Mode 4:
+ -
+
+
+ Clear Image
+
+
+
+ -
+
+
+ Select Image
+
+
+
+ -
+
+
+ Remove Profile
+
+
+
+ -
+
+
+ Open Folder
+
+
+
+ -
+
+
+ The profile specific folder, if set, will override general Backup folder
+
+
+ Open Folder
+
+
+
@@ -611,17 +645,7 @@ Mode 4:
Application Settings
- -
-
-
- Show splash screen when Companion starts
-
-
- true
-
-
-
- -
+
-
Automatic check for Companion updates
@@ -631,28 +655,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
@@ -662,29 +696,6 @@ Mode 4:
- -
-
-
- true
-
-
- true
-
-
-
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
@@ -698,13 +709,6 @@ Mode 4:
- -
-
-
- Open Folder
-
-
-
-
@@ -731,40 +735,13 @@ Mode 4:
- -
-
-
- Find Executable
-
-
-
- -
+
-
Qt::Horizontal
- -
-
-
- Open Folder
-
-
-
- -
-
-
-
- 350
- 0
-
-
-
- true
-
-
-
-
@@ -772,26 +749,6 @@ Mode 4:
- -
-
-
-
- 0
- 0
-
-
-
-
-
- Only show user splash images
-
-
- -
-
- Show user and companion splash images
-
-
-
-
-
@@ -834,18 +791,69 @@ Mode 4:
- -
-
+
-
+
Qt::Horizontal
-
+
+
+ -
+
+
+ Use model wizard when creating a new model
+
+
+
+ -
+
+
+ true
+
+
+ false
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
-
+
+ Only show user splash images
+
+
+ -
+
+ Show user and companion splash images
+
+
+
+
+ -
+
+
- 40
- 20
+ 350
+ 0
-
+
+ false
+
+
+
+ -
+
+
+ Open Folder
+
+
-
@@ -860,17 +868,17 @@ Mode 4:
- -
-
-
- Qt::Horizontal
+
-
+
+
+ Find Executable
- -
-
+
-
+
- Use model wizard when creating a new model
+ Open Folder
@@ -1050,7 +1058,6 @@ Mode 4:
tabWidget
- profileNameLE
removeProfileButton
downloadVerCB
langCombo
diff --git a/companion/src/flasheepromdialog.cpp b/companion/src/flasheepromdialog.cpp
index 14dfdb8bd..a31206d35 100755
--- a/companion/src/flasheepromdialog.cpp
+++ b/companion/src/flasheepromdialog.cpp
@@ -22,7 +22,11 @@ radioData(new RadioData())
ui->eepromFilename->hide();
ui->eepromLoad->hide();
}
- QString backupPath = g.backupDir();
+ QString backupPath = g.profile[g.id()].pBackupDir();
+ if (backupPath.isEmpty()) {
+ backupPath=g.backupDir();
+ ui->backupBeforeWrite->setChecked(g.enableBackup() || g.profile[g.id()].penableBackup());
+ }
if (backupPath.isEmpty() || !QDir(backupPath).exists()) {
ui->backupBeforeWrite->setEnabled(false);
}
@@ -292,8 +296,13 @@ void FlashEEpromDialog::on_burnButton_clicked()
// backup previous EEPROM if requested
QString backupFilename;
+ QString backupPath;
if (ui->backupBeforeWrite->isChecked()) {
- backupFilename = g.backupDir() + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin";
+ backupPath = g.profile[g.id()].pBackupDir();
+ if (backupPath.isEmpty()) {
+ backupPath=g.backupDir();
+ }
+ backupFilename = backupPath + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin";
}
else if (ui->checkFirmwareCompatibility->isChecked()) {
backupFilename = generateProcessUniqueTempFileName("eeprom.bin");
diff --git a/companion/src/flashfirmwaredialog.cpp b/companion/src/flashfirmwaredialog.cpp
index fd6effe1c..1e8dd4e8d 100755
--- a/companion/src/flashfirmwaredialog.cpp
+++ b/companion/src/flashfirmwaredialog.cpp
@@ -46,7 +46,10 @@ fwName(g.profile[g.id()].fwName())
ui->backupEEprom->setCheckState(g.backupOnFlash() ? Qt::Checked : Qt::Unchecked);
}
- QString backupPath = g.backupDir();
+ QString backupPath = g.profile[g.id()].pBackupDir();
+ if (backupPath.isEmpty()) {
+ backupPath=g.backupDir();
+ }
if (backupPath.isEmpty() || !QDir(backupPath).exists()) {
ui->backupEEprom->setEnabled(false);
}
@@ -278,8 +281,13 @@ void FlashFirmwareDialog::startFlash(const QString &filename)
// backup if requested
bool result = true;
QString backupFilename;
+ QString backupPath;
if (backup) {
- backupFilename = g.backupDir() + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin";
+ backupPath = g.profile[g.id()].pBackupDir();
+ if (backupPath.isEmpty()) {
+ backupPath=g.backupDir();
+ }
+ backupFilename = backupPath + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin";
result = readEeprom(backupFilename, progressDialog.progress());
sleep(2);
}
diff --git a/companion/src/radiointerface.cpp b/companion/src/radiointerface.cpp
index de78c4152..0cba6edb6 100755
--- a/companion/src/radiointerface.cpp
+++ b/companion/src/radiointerface.cpp
@@ -361,12 +361,31 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress)
return false;
}
+#if defined WIN32 || !defined __GNUC__
+bool isRemovableMedia(const QString &vol )
+{
+ char szDosDeviceName[MAX_PATH];
+ QString volume;
+ volume.append(vol);
+ UINT DriveType = GetDriveType( volume.replace("/","\\").toLatin1() );
+ if ( DriveType != DRIVE_REMOVABLE )
+ return false;
+ QueryDosDevice( volume.replace("/","").toLatin1(), szDosDeviceName, MAX_PATH );
+ if ( strstr( szDosDeviceName,"\\Floppy") != NULL ) { // its a floppy
+ return false;
+ }
+ return true;
+}
+#endif
+
QString findMassstoragePath(const QString &filename)
{
QString temppath;
QStringList drives;
QString eepromfile;
QString fsname;
+ static QStringList blacklist;
+
#if defined WIN32 || !defined __GNUC__
foreach(QFileInfo drive, QDir::drives()) {
WCHAR szVolumeName[256] ;
@@ -374,14 +393,20 @@ QString findMassstoragePath(const QString &filename)
DWORD dwSerialNumber = 0;
DWORD dwMaxFileNameLength=256;
DWORD dwFileSystemFlags=0;
- bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
- if (ret) {
- QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
- temppath = drive.absolutePath();
- eepromfile = temppath;
- eepromfile.append("/" + filename);
- if (QFile::exists(eepromfile)) {
- return eepromfile;
+ if (!blacklist.contains(drive.absolutePath())) {
+ if (!isRemovableMedia( drive.absolutePath() )) {
+ blacklist.append(drive.absolutePath());
+ } else {
+ bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
+ if (ret) {
+ QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
+ temppath = drive.absolutePath();
+ eepromfile = temppath;
+ eepromfile.append("/" + filename);
+ if (QFile::exists(eepromfile)) {
+ return eepromfile;
+ }
+ }
}
}
}