mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 03:40: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); | ||||
| 
 | ||||
|    p->mediaPlayer_->setSource(QUrl(QString::fromStdString(path))); | ||||
|    p->mediaPlayer_->setSource( | ||||
|       QUrl(QString("qrc:%1").arg(QString::fromStdString(path)))); | ||||
| 
 | ||||
|    QMetaObject::invokeMethod(p->mediaPlayer_, &QMediaPlayer::play); | ||||
| } | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ | |||
| #include <scwx/qt/settings/settings_variable.hpp> | ||||
| #include <scwx/qt/types/alert_types.hpp> | ||||
| #include <scwx/qt/types/location_types.hpp> | ||||
| #include <scwx/qt/types/media_types.hpp> | ||||
| 
 | ||||
| #include <boost/algorithm/string.hpp> | ||||
| #include <fmt/format.h> | ||||
|  | @ -24,11 +25,14 @@ class AudioSettings::Impl | |||
| public: | ||||
|    explicit Impl() | ||||
|    { | ||||
|       std::string defaultAlertSoundFileValue = | ||||
|          types::GetMediaPath(types::AudioFile::EasAttentionSignal); | ||||
|       std::string defaultAlertLocationMethodValue = | ||||
|          types::GetLocationMethodName(types::LocationMethod::Fixed); | ||||
| 
 | ||||
|       boost::to_lower(defaultAlertLocationMethodValue); | ||||
| 
 | ||||
|       alertSoundFile_.SetDefault(defaultAlertSoundFileValue); | ||||
|       alertLocationMethod_.SetDefault(defaultAlertLocationMethodValue); | ||||
|       alertLatitude_.SetDefault(0.0); | ||||
|       alertLongitude_.SetDefault(0.0); | ||||
|  | @ -65,6 +69,7 @@ public: | |||
| 
 | ||||
|    ~Impl() {} | ||||
| 
 | ||||
|    SettingsVariable<std::string> alertSoundFile_ {"alert_sound_file"}; | ||||
|    SettingsVariable<std::string> alertLocationMethod_ {"alert_location_method"}; | ||||
|    SettingsVariable<double>      alertLatitude_ {"alert_latitude"}; | ||||
|    SettingsVariable<double>      alertLongitude_ {"alert_longitude"}; | ||||
|  | @ -77,8 +82,10 @@ public: | |||
| AudioSettings::AudioSettings() : | ||||
|     SettingsCategory("audio"), p(std::make_unique<Impl>()) | ||||
| { | ||||
|    RegisterVariables( | ||||
|       {&p->alertLocationMethod_, &p->alertLatitude_, &p->alertLongitude_}); | ||||
|    RegisterVariables({&p->alertSoundFile_, | ||||
|                       &p->alertLocationMethod_, | ||||
|                       &p->alertLatitude_, | ||||
|                       &p->alertLongitude_}); | ||||
|    RegisterVariables(p->variables_); | ||||
|    SetDefaults(); | ||||
| 
 | ||||
|  | @ -89,6 +96,11 @@ AudioSettings::~AudioSettings() = default; | |||
| AudioSettings::AudioSettings(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 | ||||
| { | ||||
|    return p->alertLocationMethod_; | ||||
|  | @ -123,7 +135,8 @@ AudioSettings& AudioSettings::Instance() | |||
| 
 | ||||
| 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->alertLongitude_ == rhs.p->alertLongitude_ && | ||||
|            lhs.p->alertEnabled_ == rhs.p->alertEnabled_); | ||||
|  |  | |||
|  | @ -26,6 +26,7 @@ public: | |||
|    AudioSettings(AudioSettings&&) noexcept; | ||||
|    AudioSettings& operator=(AudioSettings&&) noexcept; | ||||
| 
 | ||||
|    SettingsVariable<std::string>& alert_sound_file() const; | ||||
|    SettingsVariable<std::string>& alert_location_method() const; | ||||
|    SettingsVariable<double>&      alert_latitude() const; | ||||
|    SettingsVariable<double>&      alert_longitude() const; | ||||
|  |  | |||
|  | @ -11,7 +11,7 @@ namespace types | |||
| 
 | ||||
| static const std::unordered_map<AudioFile, std::string> audioFileInfo_ { | ||||
|    {AudioFile::EasAttentionSignal, | ||||
|     "qrc:/res/audio/wikimedia/" | ||||
|     ":/res/audio/wikimedia/" | ||||
|     "Emergency_Alert_System_Attention_Signal_20s.ogg"}}; | ||||
| 
 | ||||
| const std::string& GetMediaPath(AudioFile audioFile) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat