Skip to content

Commit e4a5a7b

Browse files
committed
Use InfoString flags for Speech output
1 parent 6831b67 commit e4a5a7b

File tree

4 files changed

+216
-3
lines changed

4 files changed

+216
-3
lines changed

src/core/StelSpeechMgr.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,14 @@ void StelSpeechMgr::localeChanged(const QLocale &locale)
255255
}
256256
#endif
257257

258+
//! Retrieve the currently active flags which information bits to narrate
259+
const StelObject::InfoStringGroup& StelSpeechMgr::getNarrationTextFilters() const
260+
{
261+
return flags;
262+
}
263+
264+
//! Set the currently active flags which information bits to narrate
265+
void StelSpeechMgr::setNarrationTextFilters(const StelObject::InfoStringGroup &flags)
266+
{
267+
this->flags=flags;
268+
}

src/core/StelSpeechMgr.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define STELSPEECHMGR_HPP
2121

2222
#include "StelModule.hpp"
23+
#include "StelObject.hpp"
2324
#include <QObject>
2425
#include <QSettings>
2526
#include <QMap>
@@ -37,7 +38,11 @@ class QVoice;
3738
//!
3839
//! Sometimes, in the dark you may want voice output over reading small text on the screen.
3940
//! Calling a "narrate" action (default: Shift+R) for the selected object will provide some information.
40-
//! This functionality requires Qt6.6 and higher or else just emits the narration to logfile.
41+
//!
42+
//! Parallel to the InfoString settings which decide what information items to show,
43+
//! we use a similar structure to decide what data elements are being narrated.
44+
//!
45+
//! @note: This functionality requires Qt6.6 and higher or else just emits the narration to logfile.
4146

4247

4348
class StelSpeechMgr : public StelModule
@@ -61,6 +66,12 @@ class StelSpeechMgr : public StelModule
6166
~StelSpeechMgr() override;
6267
void init() override;
6368

69+
//! Retrieve the currently active flags which information bits to narrate
70+
const StelObject::InfoStringGroup& getNarrationTextFilters() const;
71+
72+
//! Set the currently active flags which information bits to narrate
73+
void setNarrationTextFilters(const StelObject::InfoStringGroup &flags);
74+
6475
signals:
6576
void rateChanged(double);
6677
void pitchChanged(double);
@@ -124,6 +135,7 @@ public slots:
124135
double m_rate; // -1...1
125136
double m_pitch; // -1...1
126137
double m_volume; // 0...1
138+
StelObject::InfoStringGroup flags; //! Selection of info bits to be narrated
127139
};
128140

129141
#endif // STELSPEECHMGR_HPP

src/gui/ConfigurationDialog.cpp

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "CustomDeltaTEquationDialog.hpp"
2525
#include "ConfigureScreenshotsDialog.hpp"
2626
#include "StelMainView.hpp"
27+
#include "StelSpeechMgr.hpp"
2728
#include "ui_configurationDialog.h"
2829
#include "StelApp.hpp"
2930
#include "StelFileMgr.hpp"
@@ -801,6 +802,159 @@ void ConfigurationDialog::saveCustomSelectedInfo()
801802
conf->endGroup();
802803
}
803804

805+
void ConfigurationDialog::setSelectedNarrationFromCheckBoxes()
806+
{
807+
StelObject::InfoStringGroup flags(StelObject::None);
808+
809+
if (ui->checkBoxName_Narrate->isChecked())
810+
flags |= StelObject::Name;
811+
if (ui->checkBoxCatalogNumbers_Narrate->isChecked())
812+
flags |= StelObject::CatalogNumber;
813+
if (ui->checkBoxVisualMag_Narrate->isChecked())
814+
flags |= StelObject::Magnitude;
815+
if (ui->checkBoxAbsoluteMag_Narrate->isChecked())
816+
flags |= StelObject::AbsoluteMagnitude;
817+
if (ui->checkBoxRaDecJ2000_Narrate->isChecked())
818+
flags |= StelObject::RaDecJ2000;
819+
if (ui->checkBoxRaDecOfDate_Narrate->isChecked())
820+
flags |= StelObject::RaDecOfDate;
821+
if (ui->checkBoxHourAngle_Narrate->isChecked())
822+
flags |= StelObject::HourAngle;
823+
if (ui->checkBoxAltAz_Narrate->isChecked())
824+
flags |= StelObject::AltAzi;
825+
if (ui->checkBoxDistance_Narrate->isChecked())
826+
flags |= StelObject::Distance;
827+
if (ui->checkBoxVelocity_Narrate->isChecked())
828+
flags |= StelObject::Velocity;
829+
if (ui->checkBoxProperMotion_Narrate->isChecked())
830+
flags |= StelObject::ProperMotion;
831+
if (ui->checkBoxSize_Narrate->isChecked())
832+
flags |= StelObject::Size;
833+
if (ui->checkBoxExtra_Narrate->isChecked())
834+
flags |= StelObject::Extra;
835+
if (ui->checkBoxGalacticCoordinates_Narrate->isChecked())
836+
flags |= StelObject::GalacticCoord;
837+
if (ui->checkBoxSupergalacticCoordinates_Narrate->isChecked())
838+
flags |= StelObject::SupergalacticCoord;
839+
if (ui->checkBoxOtherCoords_Narrate->isChecked())
840+
flags |= StelObject::OtherCoord;
841+
if (ui->checkBoxElongation_Narrate->isChecked())
842+
flags |= StelObject::Elongation;
843+
if (ui->checkBoxType_Narrate->isChecked())
844+
flags |= StelObject::ObjectType;
845+
if (ui->checkBoxEclipticCoordsJ2000_Narrate->isChecked())
846+
flags |= StelObject::EclipticCoordJ2000;
847+
if (ui->checkBoxEclipticCoordsOfDate_Narrate->isChecked())
848+
flags |= StelObject::EclipticCoordOfDate;
849+
if (ui->checkBoxConstellation_Narrate->isChecked())
850+
flags |= StelObject::IAUConstellation;
851+
if (ui->checkBoxSiderealTime_Narrate->isChecked())
852+
flags |= StelObject::SiderealTime;
853+
if (ui->checkBoxRTSTime_Narrate->isChecked())
854+
flags |= StelObject::RTSTime;
855+
if (ui->checkBoxSolarLunarPosition_Narrate->isChecked())
856+
flags |= StelObject::SolarLunarPosition;
857+
858+
StelApp::getInstance().getStelSpeechMgr()->setNarrationTextFilters(flags);
859+
// overwrite custom selected info settings
860+
saveCustomSelectedNarration();
861+
}
862+
863+
void ConfigurationDialog::setCustomSelectedNarration()
864+
{
865+
StelObject::InfoStringGroup flags(StelObject::None);
866+
QSettings* conf = StelApp::getInstance().getSettings();
867+
Q_ASSERT(conf);
868+
869+
if (conf->value("custom_selected_info/flag_narration_name", false).toBool())
870+
flags |= StelObject::Name;
871+
if (conf->value("custom_selected_info/flag_narration_catalognumber", false).toBool())
872+
flags |= StelObject::CatalogNumber;
873+
if (conf->value("custom_selected_info/flag_narration_magnitude", false).toBool())
874+
flags |= StelObject::Magnitude;
875+
if (conf->value("custom_selected_info/flag_narration_absolutemagnitude", false).toBool())
876+
flags |= StelObject::AbsoluteMagnitude;
877+
if (conf->value("custom_selected_info/flag_narration_radecj2000", false).toBool())
878+
flags |= StelObject::RaDecJ2000;
879+
if (conf->value("custom_selected_info/flag_narration_radecofdate", false).toBool())
880+
flags |= StelObject::RaDecOfDate;
881+
if (conf->value("custom_selected_info/flag_narration_hourangle", false).toBool())
882+
flags |= StelObject::HourAngle;
883+
if (conf->value("custom_selected_info/flag_narration_altaz", false).toBool())
884+
flags |= StelObject::AltAzi;
885+
if (conf->value("custom_selected_info/flag_narration_elongation", false).toBool())
886+
flags |= StelObject::Elongation;
887+
if (conf->value("custom_selected_info/flag_narration_distance", false).toBool())
888+
flags |= StelObject::Distance;
889+
if (conf->value("custom_selected_info/flag_narration_velocity", false).toBool())
890+
flags |= StelObject::Velocity;
891+
if (conf->value("custom_selected_info/flag_narration_propermotion", false).toBool())
892+
flags |= StelObject::ProperMotion;
893+
if (conf->value("custom_selected_info/flag_narration_size", false).toBool())
894+
flags |= StelObject::Size;
895+
if (conf->value("custom_selected_info/flag_narration_extra", false).toBool())
896+
flags |= StelObject::Extra;
897+
if (conf->value("custom_selected_info/flag_narration_galcoord", false).toBool())
898+
flags |= StelObject::GalacticCoord;
899+
if (conf->value("custom_selected_info/flag_narration_supergalcoord", false).toBool())
900+
flags |= StelObject::SupergalacticCoord;
901+
if (conf->value("custom_selected_info/flag_narration_othercoord", false).toBool())
902+
flags |= StelObject::OtherCoord;
903+
if (conf->value("custom_selected_info/flag_narration_type", false).toBool())
904+
flags |= StelObject::ObjectType;
905+
if (conf->value("custom_selected_info/flag_narration_eclcoordofdate", false).toBool())
906+
flags |= StelObject::EclipticCoordOfDate;
907+
if (conf->value("custom_selected_info/flag_narration_eclcoordj2000", false).toBool())
908+
flags |= StelObject::EclipticCoordJ2000;
909+
if (conf->value("custom_selected_info/flag_narration_constellation", false).toBool())
910+
flags |= StelObject::IAUConstellation;
911+
if (conf->value("custom_selected_info/flag_narration_sidereal_time", false).toBool())
912+
flags |= StelObject::SiderealTime;
913+
if (conf->value("custom_selected_info/flag_narration_rts_time", false).toBool())
914+
flags |= StelObject::RTSTime;
915+
if (conf->value("custom_selected_info/flag_narration_solar_lunar", false).toBool())
916+
flags |= StelObject::SolarLunarPosition;
917+
918+
StelApp::getInstance().getStelSpeechMgr()->setNarrationTextFilters(flags);
919+
updateSelectedInfoCheckBoxes();
920+
}
921+
922+
void ConfigurationDialog::saveCustomSelectedNarration()
923+
{
924+
// configuration dialog / selected object info tab
925+
const StelObject::InfoStringGroup& flags = StelApp::getInstance().getStelSpeechMgr()->getNarrationTextFilters();
926+
QSettings* conf = StelApp::getInstance().getSettings();
927+
Q_ASSERT(conf);
928+
929+
conf->beginGroup("custom_selected_info");
930+
conf->setValue("flag_narration_name", static_cast<bool>(flags & StelObject::Name));
931+
conf->setValue("flag_narration_catalognumber", static_cast<bool>(flags & StelObject::CatalogNumber));
932+
conf->setValue("flag_narration_magnitude", static_cast<bool>(flags & StelObject::Magnitude));
933+
conf->setValue("flag_narration_absolutemagnitude", static_cast<bool>(flags & StelObject::AbsoluteMagnitude));
934+
conf->setValue("flag_narration_radecj2000", static_cast<bool>(flags & StelObject::RaDecJ2000));
935+
conf->setValue("flag_narration_radecofdate", static_cast<bool>(flags & StelObject::RaDecOfDate));
936+
conf->setValue("flag_narration_hourangle", static_cast<bool>(flags & StelObject::HourAngle));
937+
conf->setValue("flag_narration_altaz", static_cast<bool>(flags & StelObject::AltAzi));
938+
conf->setValue("flag_narration_elongation", static_cast<bool>(flags & StelObject::Elongation));
939+
conf->setValue("flag_narration_distance", static_cast<bool>(flags & StelObject::Distance));
940+
conf->setValue("flag_narration_velocity", static_cast<bool>(flags & StelObject::Velocity));
941+
conf->setValue("flag_narration_propermotion", static_cast<bool>(flags & StelObject::ProperMotion));
942+
conf->setValue("flag_narration_size", static_cast<bool>(flags & StelObject::Size));
943+
conf->setValue("flag_narration_extra", static_cast<bool>(flags & StelObject::Extra));
944+
conf->setValue("flag_narration_galcoord", static_cast<bool>(flags & StelObject::GalacticCoord));
945+
conf->setValue("flag_narration_supergalcoord", static_cast<bool>(flags & StelObject::SupergalacticCoord));
946+
conf->setValue("flag_narration_othercoord", static_cast<bool>(flags & StelObject::OtherCoord));
947+
conf->setValue("flag_narration_type", static_cast<bool>(flags & StelObject::ObjectType));
948+
conf->setValue("flag_narration_eclcoordofdate", static_cast<bool>(flags & StelObject::EclipticCoordOfDate));
949+
conf->setValue("flag_narration_eclcoordj2000", static_cast<bool>(flags & StelObject::EclipticCoordJ2000));
950+
conf->setValue("flag_narration_constellation", static_cast<bool>(flags & StelObject::IAUConstellation));
951+
conf->setValue("flag_narration_sidereal_time", static_cast<bool>(flags & StelObject::SiderealTime));
952+
conf->setValue("flag_narration_rts_time", static_cast<bool>(flags & StelObject::RTSTime));
953+
conf->setValue("flag_narration_solar_lunar", static_cast<bool>(flags & StelObject::SolarLunarPosition));
954+
conf->endGroup();
955+
}
956+
957+
804958
void ConfigurationDialog::browseForScreenshotDir()
805959
{
806960
const QString &oldScreenshotDir = StelFileMgr::getScreenshotDir();
@@ -1904,6 +2058,36 @@ void ConfigurationDialog::updateSelectedInfoCheckBoxes()
19042058
ui->checkBoxRTSTime->setChecked(flags & StelObject::RTSTime);
19052059
ui->checkBoxSolarLunarPosition->setChecked(flags & StelObject::SolarLunarPosition);
19062060

2061+
#if (QT_VERSION>=QT_VERSION_CHECK(6,6,0)) && defined(ENABLE_MEDIA)
2062+
static StelSpeechMgr *speech=StelApp::getInstance().getStelSpeechMgr();
2063+
const StelObject::InfoStringGroup& nFlags = speech->getNarrationTextFilters();
2064+
2065+
ui->checkBoxName_Narrate->setChecked(nFlags & StelObject::Name);
2066+
ui->checkBoxCatalogNumbers_Narrate->setChecked(nFlags & StelObject::CatalogNumber);
2067+
ui->checkBoxVisualMag_Narrate->setChecked(nFlags & StelObject::Magnitude);
2068+
ui->checkBoxAbsoluteMag_Narrate->setChecked(nFlags & StelObject::AbsoluteMagnitude);
2069+
ui->checkBoxRaDecJ2000_Narrate->setChecked(nFlags & StelObject::RaDecJ2000);
2070+
ui->checkBoxRaDecOfDate_Narrate->setChecked(nFlags & StelObject::RaDecOfDate);
2071+
ui->checkBoxHourAngle_Narrate->setChecked(nFlags & StelObject::HourAngle);
2072+
ui->checkBoxAltAz_Narrate->setChecked(nFlags & StelObject::AltAzi);
2073+
ui->checkBoxDistance_Narrate->setChecked(nFlags & StelObject::Distance);
2074+
ui->checkBoxVelocity_Narrate->setChecked(nFlags & StelObject::Velocity);
2075+
ui->checkBoxProperMotion_Narrate->setChecked(nFlags & StelObject::ProperMotion);
2076+
ui->checkBoxSize_Narrate->setChecked(nFlags & StelObject::Size);
2077+
ui->checkBoxExtra_Narrate->setChecked(nFlags & StelObject::Extra);
2078+
ui->checkBoxGalacticCoordinates_Narrate->setChecked(nFlags & StelObject::GalacticCoord);
2079+
ui->checkBoxSupergalacticCoordinates_Narrate->setChecked(nFlags & StelObject::SupergalacticCoord);
2080+
ui->checkBoxOtherCoords_Narrate->setChecked(nFlags & StelObject::OtherCoord);
2081+
ui->checkBoxElongation_Narrate->setChecked(nFlags & StelObject::Elongation);
2082+
ui->checkBoxType_Narrate->setChecked(nFlags & StelObject::ObjectType);
2083+
ui->checkBoxEclipticCoordsJ2000_Narrate->setChecked(nFlags & StelObject::EclipticCoordJ2000);
2084+
ui->checkBoxEclipticCoordsOfDate_Narrate->setChecked(nFlags & StelObject::EclipticCoordOfDate);
2085+
ui->checkBoxConstellation_Narrate->setChecked(nFlags & StelObject::IAUConstellation);
2086+
ui->checkBoxSiderealTime_Narrate->setChecked(nFlags & StelObject::SiderealTime);
2087+
ui->checkBoxRTSTime_Narrate->setChecked(nFlags & StelObject::RTSTime);
2088+
ui->checkBoxSolarLunarPosition_Narrate->setChecked(nFlags & StelObject::SolarLunarPosition);
2089+
#endif
2090+
19072091
if (StelApp::getInstance().getFlagImmediateSave())
19082092
{
19092093
saveCustomSelectedInfo();

src/gui/ConfigurationDialog.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,17 @@ private slots:
7979
void setDefaultSelectedInfo();
8080
void setCustomSelectedInfo();
8181
//! Set the selected object info fields from the "Displayed Fields" boxes.
82-
//! Called when any of the boxes has been clicked. Sets the
83-
//! "selected info" mode to "Custom".
82+
//! Called when any of the boxes has been clicked.
83+
//! Sets the "selected info" mode to "Custom".
8484
void setSelectedInfoFromCheckBoxes();
8585
void saveCustomSelectedInfo();
8686

87+
void setCustomSelectedNarration();
88+
//! Set the selected object narration fields from the "Displayed Fields" boxes.
89+
//! Called when any of the boxes has been clicked.
90+
void setSelectedNarrationFromCheckBoxes();
91+
void saveCustomSelectedNarration();
92+
8793
void updateCurrentLanguage();
8894
void selectLanguage(const int id); // id is index of name in QComboBox (must be called in a signal/slot connection!)
8995
void storeLanguageSettings(); // Store only currently set language settings (program and skyculture)

0 commit comments

Comments
 (0)