From 41d0675886dc3f0ad6e5a2ba1365c12c76ae0729 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Sun, 19 Jul 2015 13:18:46 +0200 Subject: [PATCH] Fixes #2503: Standalone simulator radio selection display problem --- companion/releasenotes.txt | 1 + companion/src/simulator.cpp | 33 ++++++++++++--------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/companion/releasenotes.txt b/companion/releasenotes.txt index 2a7d28df7..478755276 100644 --- a/companion/releasenotes.txt +++ b/companion/releasenotes.txt @@ -8,6 +8,7 @@
  • Removed constant access to floppy disk (#2160)
  • Telemetry view script combo box list was empty (#2465)
  • Telemetry view bars ranges not transfered to radio (#2491)
  • +
  • Fixed Standalone simulator radio selection display problem (#2503)
  • Version 2.1.0 / 2015-07-16

    diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index 661b66fe9..1d50bcaa8 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -123,34 +123,22 @@ int main(int argc, char *argv[]) registerSimulators(); registerOpenTxFirmwares(); - QMessageBox msgBox; - msgBox.setWindowTitle("Radio type"); - msgBox.setText("Which radio type do you want to simulate?"); - msgBox.setIcon(QMessageBox::Question); - - foreach(SimulatorFactory *factory, registered_simulators) { - QPushButton *button = msgBox.addButton(factory->name(), QMessageBox::ActionRole); - button->adjustSize(); - button->setProperty("name", factory->name()); - } - msgBox.adjustSize(); - - QPushButton *exitButton = msgBox.addButton(QMessageBox::Close); - eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); if (!eedir.exists("OpenTX")) { eedir.mkdir("OpenTX"); } eedir.cd("OpenTX"); - msgBox.exec(); - - QAbstractButton *button = msgBox.clickedButton(); - if (button == exitButton) { - return 0; + QStringList firmwareIds; + foreach(SimulatorFactory *factory, registered_simulators) { + firmwareIds << factory->name(); } - else { - QString firmwareId = button->property("name").toString(); + + 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); + if (ok && !firmwareId.isEmpty()) { QString radioId; int pos = firmwareId.indexOf("-"); if (pos > 0) { @@ -169,6 +157,9 @@ int main(int argc, char *argv[]) else dialog = new SimulatorDialog9X(NULL, factory->create()); } + else { + return 0; + } dialog->show(); dialog->start(eepromFileName.toAscii().constData());