Skip to content

Commit

Permalink
Disable the connection and connection type combo boxes when connection
Browse files Browse the repository at this point in the history
is active
  • Loading branch information
till213 committed May 22, 2024
1 parent 894f53d commit b0bddbe
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

## Improvements
- Seeking backward and forward via flight simulator keyboard shortcuts (CTRL+, respectively CTRL+.) now repeats the action while keeping the shortcut combination pressed
- Application settings: the flight simulator connection plugin and connection type (pipe, IPv4, IPv6) combo boxes are disabled while the connection is active (replay or recording in progress)

### Bug Fixes
- Fix the example [Flight-Analysis.sql](doc/SQL/Flight-Analysis.sql) script (documentation) [[Issue #150](https://github.com/till213/SkyDolly/issues/150)]
Expand Down
2 changes: 1 addition & 1 deletion src/PluginManager/src/SkyConnectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ bool SkyConnectManager::isInReplayState() const noexcept
bool SkyConnectManager::isActive() const noexcept
{
std::optional<std::reference_wrapper<SkyConnectIntf>> skyConnect = getCurrentSkyConnect();
return skyConnect ? skyConnect->get().isInRecordingState() || skyConnect->get().isInReplayState(): false;
return skyConnect ? skyConnect->get().isActive() : false;
}

void SkyConnectManager::stop() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#endif

#include <PluginManager/Connect/ConnectPluginBaseSettings.h>
#include <PluginManager/SkyConnectManager.h>
#include "MSFSSimConnectSettings.h"
#include "MSFSSimConnectOptionWidget.h"
#include "ui_MSFSSimConnectOptionWidget.h"
Expand Down Expand Up @@ -91,12 +92,19 @@ void MSFSSimConnectOptionWidget::accept() noexcept

void MSFSSimConnectOptionWidget::frenchConnection() noexcept
{
const auto &skyConnectManager = SkyConnectManager::getInstance();
// TODO FIXME: The option widget "survives" the plugin settings for a short moment, when the plugin is unloaded
// the connection then tries to access the settings that have already been deleted
// -> delete this option widget together with the plugin unloading, or get at least notified when the settings are deleted (disconnect this signal then)
// connect(&skyConnectManager, &SkyConnectManager::stateChanged,
// this, &MSFSSimConnectOptionWidget::updateUi);

connect(&d->pluginSettings, &MSFSSimConnectSettings::changed,
this, &MSFSSimConnectOptionWidget::updateUi);
connect(ui->restoreDefaultsPushButton, &QPushButton::clicked,
this, &MSFSSimConnectOptionWidget::restoreDefaults);
connect(ui->connectionComboBox, &QComboBox::currentIndexChanged,
this, &MSFSSimConnectOptionWidget::updateInfoText);
this, &MSFSSimConnectOptionWidget::updateInfoText);
}

void MSFSSimConnectOptionWidget::initUi() noexcept
Expand Down Expand Up @@ -128,6 +136,8 @@ void MSFSSimConnectOptionWidget::updateUi() noexcept
default:
break;
}
const bool enabled = !SkyConnectManager::getInstance().isActive();
ui->connectionComboBox->setEnabled(enabled);

updateInfoText();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ MSFSSimConnectSettings::MSFSSimConnectSettings() noexcept
d(std::make_unique<MSFSSimConnectSettingsPrivate>())
{}

MSFSSimConnectSettings::~MSFSSimConnectSettings() = default;
MSFSSimConnectSettings::~MSFSSimConnectSettings()
{
#ifdef DEBUG
qDebug() << "MSFSSimConnectSettings::~MSFSSimConnectSettings: DELETED";
#endif
}

MSFSSimConnectSettings::ConnectionType MSFSSimConnectSettings::getConnectionType() const noexcept
{
Expand Down
5 changes: 5 additions & 0 deletions src/UserInterface/src/Dialog/SettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ void SettingsDialog::frenchConnection() noexcept
const auto &skyConnectManager = SkyConnectManager::getInstance();
connect(&skyConnectManager, &SkyConnectManager::connectionChanged,
this, &SettingsDialog::onSkyConnectPluginChanged);
connect(&skyConnectManager, &SkyConnectManager::stateChanged,
this, &SettingsDialog::updateUi);

connect(this, &SettingsDialog::accepted,
this, &SettingsDialog::onAccepted);
connect(ui->settingsTabWidget, &QTabWidget::currentChanged,
Expand Down Expand Up @@ -195,6 +198,8 @@ void SettingsDialog::updateUi() noexcept
if (pluginName) {
ui->connectionComboBox->setCurrentText(pluginName.value());
}
const bool enabled = !skyConnectManager.isActive();
ui->connectionComboBox->setEnabled(enabled);
updateConnectionStatus();

// User interface
Expand Down

0 comments on commit b0bddbe

Please sign in to comment.