Skip to content

Commit

Permalink
fix(sim): do not allow launching if no radio profiles found (#3712)
Browse files Browse the repository at this point in the history
* Test for existence of radio profiles and advise if not found

* Fix message box title and move simulator name to constants
  • Loading branch information
pfeerick committed Jun 23, 2023
1 parent 41467e3 commit 3ea236e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions companion/src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define CPN_MAX_SPACEMOUSE 6

#define CPN_STR_APP_NAME QCoreApplication::translate("Companion", "EdgeTX Companion")
#define CPN_STR_SIMU_NAME QCoreApplication::translate("Companion", "EdgeTX Simulator")
#define CPN_STR_TTL_INFO QCoreApplication::translate("Companion", "Information") // shared Title Case words, eg. for a window title or section heading
#define CPN_STR_TTL_WARNING QCoreApplication::translate("Companion", "Warning")
#define CPN_STR_TTL_ERROR QCoreApplication::translate("Companion", "Error")
Expand Down
12 changes: 12 additions & 0 deletions companion/src/simulation/simulatorstartupdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
#include <QFileDialog>
#include <QStandardItemModel>
#include <QSortFilterProxyModel>
#include <QMessageBox>
#include <QPushButton>
#include <QTimer>

using namespace Simulator;

Expand All @@ -44,6 +47,7 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
{
ui->setupUi(this);
this->setWindowIcon(QIcon(":/icon.png"));
this->setWindowTitle(QString("%1 - %2").arg(CPN_STR_SIMU_NAME).arg(tr("Startup Options")));

QMapIterator<int, QString> pi(g.getActiveProfiles());
while (pi.hasNext()) {
Expand Down Expand Up @@ -97,6 +101,14 @@ SimulatorStartupDialog::SimulatorStartupDialog(SimulatorOptions * options, int *
QObject::connect(ui->btnSelectDataFolder, &QToolButton::clicked, this, &SimulatorStartupDialog::onDataFolderSelect);
QObject::connect(ui->btnSelectSdPath, &QToolButton::clicked, this, &SimulatorStartupDialog::onSdPathSelect);

if (ui->radioProfile->count() < 1) {
// give Startup dialog time to display so this error message can overlay it
QTimer::singleShot(250, [=] {
QMessageBox::critical(this, CPN_STR_SIMU_NAME, tr("No radio profiles have been found. Use %1 to create.").arg(CPN_STR_APP_NAME));
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
});
}

}

SimulatorStartupDialog::~SimulatorStartupDialog()
Expand Down
2 changes: 1 addition & 1 deletion companion/src/simulation/simulatorstartupdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</sizepolicy>
</property>
<property name="title">
<string>Simulator Startup Options:</string>
<string>Simulator Startup Options</string>
</property>
<layout class="QFormLayout" name="layout_options">
<property name="sizeConstraint">
Expand Down

0 comments on commit 3ea236e

Please sign in to comment.