1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 09:48:45 -05:00

ADS-B: Only enable text to speech engine if speech used, as this can take 10 seconds on Linux

This commit is contained in:
Jon Beniston 2023-02-16 12:40:05 +00:00
parent f807b45df3
commit ab97ce7349
2 changed files with 31 additions and 6 deletions

View File

@ -3104,9 +3104,32 @@ void ADSBDemodGUI::checkDynamicNotification(Aircraft *aircraft)
}
}
// Initialise text to speech engine
// This takes 10 seconds on some versions of Linux, so only do it, if user actually
// has speech notifications configured
void ADSBDemodGUI::enableSpeechIfNeeded()
{
if (m_speech) {
return;
}
for (const auto& notification : m_settings.m_notificationSettings)
{
if (!notification->m_speech.isEmpty())
{
qDebug() << "ADSBDemodGUI: Enabling text to speech";
m_speech = new QTextToSpeech(this);
return;
}
}
}
void ADSBDemodGUI::speechNotification(Aircraft *aircraft, const QString &speech)
{
m_speech->say(subAircraftString(aircraft, speech));
if (m_speech) {
m_speech->say(subAircraftString(aircraft, speech));
} else {
qDebug() << "ADSBDemodGUI::speechNotification: Unable to say " << speech;
}
}
void ADSBDemodGUI::commandNotification(Aircraft *aircraft, const QString &command)
@ -3308,7 +3331,9 @@ void ADSBDemodGUI::on_feed_clicked(bool checked)
void ADSBDemodGUI::on_notifications_clicked()
{
ADSBDemodNotificationDialog dialog(&m_settings);
if (dialog.exec() == QDialog::Accepted) {
if (dialog.exec() == QDialog::Accepted)
{
enableSpeechIfNeeded();
applySettings();
}
}
@ -4216,7 +4241,7 @@ void ADSBDemodGUI::updateAirports()
if (azEl.getDistance() <= m_settings.m_airportRange*1000.0f)
{
// Only display the airport if it's large enough
if (airportInfo->m_type >= m_settings.m_airportMinimumSize)
if (airportInfo->m_type >= (AirportInformation::AirportType)m_settings.m_airportMinimumSize)
{
// Only display heliports if enabled
if (m_settings.m_displayHeliports || (airportInfo->m_type != AirportInformation::AirportType::Heliport))
@ -4613,6 +4638,7 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
m_airspaceModel(this),
m_trackAircraft(nullptr),
m_highlightAircraft(nullptr),
m_speech(nullptr),
m_progressDialog(nullptr),
m_loadingData(false)
{
@ -4761,9 +4787,6 @@ ADSBDemodGUI::ADSBDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseb
updateNavAids();
update3DModels();
// Initialise text to speech engine
m_speech = new QTextToSpeech(this);
m_flightInformation = nullptr;
m_aviationWeather = nullptr;
@ -4952,6 +4975,7 @@ void ADSBDemodGUI::displaySettings()
getRollupContents()->restoreState(m_rollupState);
blockApplySettings(false);
enableSpeechIfNeeded();
}
void ADSBDemodGUI::leaveEvent(QEvent* event)

View File

@ -994,6 +994,7 @@ private:
SWGSDRangel::SWGMapAnimation *engineAnimation(QDateTime startDateTime, int engine, bool stop);
void checkStaticNotification(Aircraft *aircraft);
void checkDynamicNotification(Aircraft *aircraft);
void enableSpeechIfNeeded();
void speechNotification(Aircraft *aircraft, const QString &speech);
void commandNotification(Aircraft *aircraft, const QString &command);
QString subAircraftString(Aircraft *aircraft, const QString &string);