diff options
Diffstat (limited to 'Swift/Controllers/SoundEventController.cpp')
-rw-r--r-- | Swift/Controllers/SoundEventController.cpp | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp index 26847ed..d056990 100644 --- a/Swift/Controllers/SoundEventController.cpp +++ b/Swift/Controllers/SoundEventController.cpp @@ -1,31 +1,28 @@ /* - * Copyright (c) 2010 Kevin Smith + * Copyright (c) 2010-2012 Kevin Smith * Licensed under the GNU General Public License v3. * See Documentation/Licenses/GPLv3.txt for more information. */ -#include "Swift/Controllers/SoundEventController.h" +#include <Swift/Controllers/SoundEventController.h> #include <boost/bind.hpp> -#include "Swift/Controllers/XMPPEvents/EventController.h" -#include "Swift/Controllers/SoundPlayer.h" -#include "Swift/Controllers/UIEvents/UIEventStream.h" -#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" +#include <Swift/Controllers/XMPPEvents/EventController.h> +#include <Swift/Controllers/SoundPlayer.h> +#include <Swift/Controllers/UIEvents/UIEventStream.h> +#include <Swift/Controllers/SettingConstants.h> namespace Swift { -SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings, UIEventStream* uiEvents) { - uiEvents_ = uiEvents; +SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings) { settings_ = settings; eventController_ = eventController; soundPlayer_ = soundPlayer; - uiEvents_->onUIEvent.connect(boost::bind(&SoundEventController::handleUIEvent, this, _1)); eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1)); + settings_->onSettingChanged.connect(boost::bind(&SoundEventController::handleSettingChanged, this, _1)); - bool playSounds = settings->getBoolSetting("playSounds", true); - playSounds_ = !playSounds; - setPlaySounds(playSounds); + playSounds_ = settings->getSetting(SettingConstants::PLAY_SOUNDS); } void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event) { @@ -35,18 +32,13 @@ void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEv } void SoundEventController::setPlaySounds(bool playSounds) { - bool transmit = playSounds != playSounds_; playSounds_ = playSounds; - settings_->storeBool("playSounds", playSounds); - if (transmit) { - uiEvents_->send(boost::shared_ptr<ToggleSoundsUIEvent>(new ToggleSoundsUIEvent(playSounds_))); - } + settings_->storeSetting(SettingConstants::PLAY_SOUNDS, playSounds); } -void SoundEventController::handleUIEvent(boost::shared_ptr<UIEvent> event) { - boost::shared_ptr<ToggleSoundsUIEvent> soundEvent = boost::dynamic_pointer_cast<ToggleSoundsUIEvent>(event); - if (soundEvent) { - setPlaySounds(soundEvent->getEnabled()); +void SoundEventController::handleSettingChanged(const std::string& settingPath) { + if (SettingConstants::PLAY_SOUNDS.getKey() == settingPath) { + playSounds_ = settings_->getSetting(SettingConstants::PLAY_SOUNDS); } } |