mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 06:30:05 +00:00 
			
		
		
		
	Add alert sound file to settings
This commit is contained in:
		
							parent
							
								
									40fc8ade20
								
							
						
					
					
						commit
						a495cf1b3b
					
				
					 5 changed files with 21 additions and 6 deletions
				
			
		|  | @ -84,7 +84,8 @@ void MediaManager::Play(types::AudioFile media) | ||||||
| 
 | 
 | ||||||
|    logger_->debug("Playing audio: {}", path); |    logger_->debug("Playing audio: {}", path); | ||||||
| 
 | 
 | ||||||
|    p->mediaPlayer_->setSource(QUrl(QString::fromStdString(path))); |    p->mediaPlayer_->setSource( | ||||||
|  |       QUrl(QString("qrc:%1").arg(QString::fromStdString(path)))); | ||||||
| 
 | 
 | ||||||
|    QMetaObject::invokeMethod(p->mediaPlayer_, &QMediaPlayer::play); |    QMetaObject::invokeMethod(p->mediaPlayer_, &QMediaPlayer::play); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -3,6 +3,7 @@ | ||||||
| #include <scwx/qt/settings/settings_variable.hpp> | #include <scwx/qt/settings/settings_variable.hpp> | ||||||
| #include <scwx/qt/types/alert_types.hpp> | #include <scwx/qt/types/alert_types.hpp> | ||||||
| #include <scwx/qt/types/location_types.hpp> | #include <scwx/qt/types/location_types.hpp> | ||||||
|  | #include <scwx/qt/types/media_types.hpp> | ||||||
| 
 | 
 | ||||||
| #include <boost/algorithm/string.hpp> | #include <boost/algorithm/string.hpp> | ||||||
| #include <fmt/format.h> | #include <fmt/format.h> | ||||||
|  | @ -24,11 +25,14 @@ class AudioSettings::Impl | ||||||
| public: | public: | ||||||
|    explicit Impl() |    explicit Impl() | ||||||
|    { |    { | ||||||
|  |       std::string defaultAlertSoundFileValue = | ||||||
|  |          types::GetMediaPath(types::AudioFile::EasAttentionSignal); | ||||||
|       std::string defaultAlertLocationMethodValue = |       std::string defaultAlertLocationMethodValue = | ||||||
|          types::GetLocationMethodName(types::LocationMethod::Fixed); |          types::GetLocationMethodName(types::LocationMethod::Fixed); | ||||||
| 
 | 
 | ||||||
|       boost::to_lower(defaultAlertLocationMethodValue); |       boost::to_lower(defaultAlertLocationMethodValue); | ||||||
| 
 | 
 | ||||||
|  |       alertSoundFile_.SetDefault(defaultAlertSoundFileValue); | ||||||
|       alertLocationMethod_.SetDefault(defaultAlertLocationMethodValue); |       alertLocationMethod_.SetDefault(defaultAlertLocationMethodValue); | ||||||
|       alertLatitude_.SetDefault(0.0); |       alertLatitude_.SetDefault(0.0); | ||||||
|       alertLongitude_.SetDefault(0.0); |       alertLongitude_.SetDefault(0.0); | ||||||
|  | @ -65,6 +69,7 @@ public: | ||||||
| 
 | 
 | ||||||
|    ~Impl() {} |    ~Impl() {} | ||||||
| 
 | 
 | ||||||
|  |    SettingsVariable<std::string> alertSoundFile_ {"alert_sound_file"}; | ||||||
|    SettingsVariable<std::string> alertLocationMethod_ {"alert_location_method"}; |    SettingsVariable<std::string> alertLocationMethod_ {"alert_location_method"}; | ||||||
|    SettingsVariable<double>      alertLatitude_ {"alert_latitude"}; |    SettingsVariable<double>      alertLatitude_ {"alert_latitude"}; | ||||||
|    SettingsVariable<double>      alertLongitude_ {"alert_longitude"}; |    SettingsVariable<double>      alertLongitude_ {"alert_longitude"}; | ||||||
|  | @ -77,8 +82,10 @@ public: | ||||||
| AudioSettings::AudioSettings() : | AudioSettings::AudioSettings() : | ||||||
|     SettingsCategory("audio"), p(std::make_unique<Impl>()) |     SettingsCategory("audio"), p(std::make_unique<Impl>()) | ||||||
| { | { | ||||||
|    RegisterVariables( |    RegisterVariables({&p->alertSoundFile_, | ||||||
|       {&p->alertLocationMethod_, &p->alertLatitude_, &p->alertLongitude_}); |                       &p->alertLocationMethod_, | ||||||
|  |                       &p->alertLatitude_, | ||||||
|  |                       &p->alertLongitude_}); | ||||||
|    RegisterVariables(p->variables_); |    RegisterVariables(p->variables_); | ||||||
|    SetDefaults(); |    SetDefaults(); | ||||||
| 
 | 
 | ||||||
|  | @ -89,6 +96,11 @@ AudioSettings::~AudioSettings() = default; | ||||||
| AudioSettings::AudioSettings(AudioSettings&&) noexcept            = default; | AudioSettings::AudioSettings(AudioSettings&&) noexcept            = default; | ||||||
| AudioSettings& AudioSettings::operator=(AudioSettings&&) noexcept = default; | AudioSettings& AudioSettings::operator=(AudioSettings&&) noexcept = default; | ||||||
| 
 | 
 | ||||||
|  | SettingsVariable<std::string>& AudioSettings::alert_sound_file() const | ||||||
|  | { | ||||||
|  |    return p->alertSoundFile_; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| SettingsVariable<std::string>& AudioSettings::alert_location_method() const | SettingsVariable<std::string>& AudioSettings::alert_location_method() const | ||||||
| { | { | ||||||
|    return p->alertLocationMethod_; |    return p->alertLocationMethod_; | ||||||
|  | @ -123,7 +135,8 @@ AudioSettings& AudioSettings::Instance() | ||||||
| 
 | 
 | ||||||
| bool operator==(const AudioSettings& lhs, const AudioSettings& rhs) | bool operator==(const AudioSettings& lhs, const AudioSettings& rhs) | ||||||
| { | { | ||||||
|    return (lhs.p->alertLocationMethod_ == rhs.p->alertLocationMethod_ && |    return (lhs.p->alertSoundFile_ == rhs.p->alertSoundFile_ && | ||||||
|  |            lhs.p->alertLocationMethod_ == rhs.p->alertLocationMethod_ && | ||||||
|            lhs.p->alertLatitude_ == rhs.p->alertLatitude_ && |            lhs.p->alertLatitude_ == rhs.p->alertLatitude_ && | ||||||
|            lhs.p->alertLongitude_ == rhs.p->alertLongitude_ && |            lhs.p->alertLongitude_ == rhs.p->alertLongitude_ && | ||||||
|            lhs.p->alertEnabled_ == rhs.p->alertEnabled_); |            lhs.p->alertEnabled_ == rhs.p->alertEnabled_); | ||||||
|  |  | ||||||
|  | @ -26,6 +26,7 @@ public: | ||||||
|    AudioSettings(AudioSettings&&) noexcept; |    AudioSettings(AudioSettings&&) noexcept; | ||||||
|    AudioSettings& operator=(AudioSettings&&) noexcept; |    AudioSettings& operator=(AudioSettings&&) noexcept; | ||||||
| 
 | 
 | ||||||
|  |    SettingsVariable<std::string>& alert_sound_file() const; | ||||||
|    SettingsVariable<std::string>& alert_location_method() const; |    SettingsVariable<std::string>& alert_location_method() const; | ||||||
|    SettingsVariable<double>&      alert_latitude() const; |    SettingsVariable<double>&      alert_latitude() const; | ||||||
|    SettingsVariable<double>&      alert_longitude() const; |    SettingsVariable<double>&      alert_longitude() const; | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ namespace types | ||||||
| 
 | 
 | ||||||
| static const std::unordered_map<AudioFile, std::string> audioFileInfo_ { | static const std::unordered_map<AudioFile, std::string> audioFileInfo_ { | ||||||
|    {AudioFile::EasAttentionSignal, |    {AudioFile::EasAttentionSignal, | ||||||
|     "qrc:/res/audio/wikimedia/" |     ":/res/audio/wikimedia/" | ||||||
|     "Emergency_Alert_System_Attention_Signal_20s.ogg"}}; |     "Emergency_Alert_System_Attention_Signal_20s.ogg"}}; | ||||||
| 
 | 
 | ||||||
| const std::string& GetMediaPath(AudioFile audioFile) | const std::string& GetMediaPath(AudioFile audioFile) | ||||||
|  |  | ||||||
|  | @ -1 +1 @@ | ||||||
| Subproject commit 85525670368987258d41f2a7b0e92266dcec9048 | Subproject commit 8a633285ecbe8ff7d48631485620a7c7a5257229 | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat