From 84fe232b0c1072b3a8b0190a7a425b603fb331ca Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 19 Jul 2015 14:54:33 +0200 Subject: [PATCH] Re #2503: Standalone simulator now remembers which radio was simulated in previous session --- companion/src/appdata.cpp | 3 +++ companion/src/appdata.h | 3 +++ companion/src/simulator.cpp | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/companion/src/appdata.cpp b/companion/src/appdata.cpp index b68ff8c72..db50261df 100644 --- a/companion/src/appdata.cpp +++ b/companion/src/appdata.cpp @@ -512,6 +512,7 @@ QString AppData::mcu() { return _mcu; } QString AppData::programmer() { return _programmer; } QString AppData::sambaLocation() { return _sambaLocation; } QString AppData::sambaPort() { return _sambaPort; } +QString AppData::lastSimulator() { return _lastSimulator; } QString AppData::backupDir() { return _backupDir; } QString AppData::gePath() { return _gePath; } @@ -560,6 +561,7 @@ void AppData::mcu (const QString x) { store(x, _mcu, void AppData::programmer (const QString x) { store(x, _programmer, "programmer" );} void AppData::sambaLocation (const QString x) { store(x, _sambaLocation, "samba_location" );} void AppData::sambaPort (const QString x) { store(x, _sambaPort, "samba_port" );} +void AppData::lastSimulator (const QString x) { store(x, _lastSimulator, "last_simulator" );} void AppData::backupDir (const QString x) { store(x, _backupDir, "backupPath" );} void AppData::gePath (const QString x) { store(x, _gePath, "gePath" );} @@ -716,6 +718,7 @@ AppData::AppData() getset( _programmer, "programmer" ,"usbasp" ); getset( _sambaLocation, "samba_location" ,"" ); getset( _sambaPort, "samba_port" ,"\\USBserial\\COM23" ); + getset( _lastSimulator, "last_simulator" ,"" ); getset( _backupDir, "backupPath" ,"" ); getset( _gePath, "gePath" ,"" ); diff --git a/companion/src/appdata.h b/companion/src/appdata.h index 970712376..27d019779 100644 --- a/companion/src/appdata.h +++ b/companion/src/appdata.h @@ -240,6 +240,7 @@ class AppData: protected CompStoreObj QString _programmer; QString _sambaLocation; QString _sambaPort; + QString _lastSimulator; QString _backupDir; QString _gePath; @@ -290,6 +291,7 @@ class AppData: protected CompStoreObj QString programmer(); QString sambaLocation(); QString sambaPort(); + QString lastSimulator(); QString backupDir(); QString gePath(); @@ -339,6 +341,7 @@ class AppData: protected CompStoreObj void programmer (const QString); void sambaLocation (const QString); void sambaPort (const QString); + void lastSimulator (const QString); void backupDir (const QString); void gePath (const QString); diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index 1d50bcaa8..45e22ffd8 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -54,6 +54,7 @@ #endif #include "simulatordialog.h" #include "eeprominterface.h" +#include "appdata.h" #if defined WIN32 || !defined __GNUC__ #include @@ -130,15 +131,22 @@ int main(int argc, char *argv[]) eedir.cd("OpenTX"); QStringList firmwareIds; + int currentIdx = 0; foreach(SimulatorFactory *factory, registered_simulators) { firmwareIds << factory->name(); + if (factory->name() == g.lastSimulator()) { + currentIdx = firmwareIds.size() - 1; + } } bool ok; QString firmwareId = QInputDialog::getItem(0, QObject::tr("Radio type"), QObject::tr("Which radio type do you want to simulate?"), - firmwareIds, 0, false, &ok); + firmwareIds, currentIdx, false, &ok); if (ok && !firmwareId.isEmpty()) { + if (firmwareId != g.lastSimulator()) { + g.lastSimulator(firmwareId); + } QString radioId; int pos = firmwareId.indexOf("-"); if (pos > 0) {