summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-05 11:01:48 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-05 11:01:48 (GMT)
commit348a4f13c5f00a27ad5c7e4f392948de7cc454e3 (patch)
tree43392423f5939190075d62aaae1478f52571af5c /Swift/Controllers/SoundEventController.cpp
parent326cd32e2c9e3ec9bac54f5bb952928680c93749 (diff)
downloadswift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.zip
swift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.tar.bz2
Persist Sound Toggleness.
Resolves: #192
Diffstat (limited to 'Swift/Controllers/SoundEventController.cpp')
-rw-r--r--Swift/Controllers/SoundEventController.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp
index 29f7fbf..b1fa584 100644
--- a/Swift/Controllers/SoundEventController.cpp
+++ b/Swift/Controllers/SoundEventController.cpp
@@ -9,13 +9,17 @@
namespace Swift {
-SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds, UIEventStream* uiEvents) {
+SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings, UIEventStream* uiEvents) {
+ uiEvents_ = uiEvents;
+ settings_ = settings;
eventController_ = eventController;
- eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1));
soundPlayer_ = soundPlayer;
- playSounds_ = playSounds;
- uiEvents_ = uiEvents;
uiEvents_->onUIEvent.connect(boost::bind(&SoundEventController::handleUIEvent, this, _1));
+ eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1));
+
+ bool playSounds = settings->getBoolSetting("playSounds", true);
+ playSounds_ = !playSounds;
+ setPlaySounds(playSounds);
}
void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent>) {
@@ -23,7 +27,12 @@ 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_)));
+ }
}
void SoundEventController::handleUIEvent(boost::shared_ptr<UIEvent> event) {