From 9a898533d18e9e73b54c1ba2938aaddf61b33365 Mon Sep 17 00:00:00 2001 From: philmoz Date: Fri, 17 Mar 2023 13:09:38 +1100 Subject: [PATCH] fix(cpn): QoL tweaks to joystick preferences (#3105) * Add preference option to Companion to disable the 'Cannot open joystick, joystick disabled' popup warning when starting the simulator. * Don't erase joystick settings if user opens preferences dialog while joystick is not connected. Remove reference to "Ubuntu" font family for 'Radio Type' label in preferences dialog (generates warning on MacOS). --- companion/src/apppreferencesdialog.cpp | 8 ++++++-- companion/src/apppreferencesdialog.ui | 12 +++++++++--- companion/src/simulation/simulatorwidget.cpp | 3 ++- companion/src/storage/appdata.h | 1 + 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index d9e309a53..c540199a5 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -78,6 +78,7 @@ void AppPreferencesDialog::accept() g.showSplash(ui->showSplash->isChecked()); g.promptProfile(ui->chkPromptProfile->isChecked()); g.simuSW(ui->simuSW->isChecked()); + g.disableJoystickWarning(ui->joystickWarningCB->isChecked()); g.removeModelSlots(ui->opt_removeBlankSlots->isChecked()); g.newModelAction((AppData::NewModelAction)ui->cboNewModelAction->currentIndex()); g.historySize(ui->historySize->value()); @@ -93,9 +94,11 @@ void AppPreferencesDialog::accept() g.appLogsDir(ui->appLogsDir->text()); g.runAppInstaller(ui->chkPromptInstall->isChecked()); - if (ui->joystickChkB ->isChecked() && ui->joystickCB->isEnabled()) { + if (ui->joystickChkB ->isChecked()) { g.jsSupport(ui->joystickChkB ->isChecked()); - g.jsCtrl(ui->joystickCB ->currentIndex()); + // Don't overwrite selected joystick if not connected. Avoid surprising the user. + if (ui->joystickCB->isEnabled()) + g.jsCtrl(ui->joystickCB ->currentIndex()); } else { g.jsSupport(false); @@ -237,6 +240,7 @@ void AppPreferencesDialog::initSettings() } ui->simuSW->setChecked(g.simuSW()); + ui->joystickWarningCB->setChecked(g.disableJoystickWarning()); ui->opt_removeBlankSlots->setChecked(g.removeModelSlots()); ui->cboNewModelAction->addItems(AppData::newModelActionsList()); ui->cboNewModelAction->setCurrentIndex(g.newModelAction()); diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index eca37e07c..ffa1dd713 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -7,7 +7,7 @@ 0 0 864 - 668 + 673 @@ -481,7 +481,6 @@ Mode 4: - Ubuntu 75 true @@ -1284,7 +1283,7 @@ Mode 4: - + Qt::Vertical @@ -1388,6 +1387,13 @@ Mode 4: + + + + Disable 'Cannot open joystick, joystick disabled' warning + + + diff --git a/companion/src/simulation/simulatorwidget.cpp b/companion/src/simulation/simulatorwidget.cpp index 8c1b0f3e2..6ff5978b1 100644 --- a/companion/src/simulation/simulatorwidget.cpp +++ b/companion/src/simulation/simulatorwidget.cpp @@ -691,7 +691,8 @@ void SimulatorWidget::setupJoysticks() joysticksEnabled = true; } else { - QMessageBox::critical(this, CPN_STR_TTL_WARNING, tr("Cannot open joystick, joystick disabled")); + if (!g.disableJoystickWarning()) + QMessageBox::critical(this, CPN_STR_TTL_WARNING, tr("Cannot open joystick, joystick disabled")); } } else if (joystick) { diff --git a/companion/src/storage/appdata.h b/companion/src/storage/appdata.h index ad7419203..a33bc9173 100644 --- a/companion/src/storage/appdata.h +++ b/companion/src/storage/appdata.h @@ -687,6 +687,7 @@ class AppData: public CompStoreObj PROPERTY(int, backLight, 0) PROPERTY(int, simuLastProfId, -1) PROPERTY(bool, simuSW, true) + PROPERTY(bool, disableJoystickWarning, false) // Message box confirmations PROPERTY(bool, confirmWriteModelsAndSettings, true)