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
parent326cd32e2c9e3ec9bac54f5bb952928680c93749 (diff)
downloadswift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.zip
swift-348a4f13c5f00a27ad5c7e4f392948de7cc454e3.tar.bz2
Persist Sound Toggleness.
Resolves: #192
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/SoundEventController.cpp17
-rw-r--r--Swift/Controllers/SoundEventController.h6
3 files changed, 18 insertions, 7 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index ccce0bb..8aeca97 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -71,8 +71,8 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF
eventController_->onEventQueueLengthChange.connect(boost::bind(&MainController::handleEventQueueLengthChange, this, _1));
systemTrayController_ = new SystemTrayController(eventController_, systemTray);
- soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings->getBoolSetting("playSounds", true), uiEventStream_);
loginWindow_ = loginWindowFactory_->createLoginWindow(uiEventStream_);
+ soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings, uiEventStream_);
foreach (String profile, settings->getAvailableProfiles()) {
ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(profile, settings);
loginWindow_->addAvailableAccount(profileSettings->getStringSetting("jid"), profileSettings->getStringSetting("pass"), profileSettings->getStringSetting("certificate"));
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) {
diff --git a/Swift/Controllers/SoundEventController.h b/Swift/Controllers/SoundEventController.h
index 34499d4..e9a853f 100644
--- a/Swift/Controllers/SoundEventController.h
+++ b/Swift/Controllers/SoundEventController.h
@@ -3,7 +3,7 @@
#include <boost/shared_ptr.hpp>
#include "Swiften/Events/StanzaEvent.h"
-
+#include "Swiften/Settings/SettingsProvider.h"
#include "Swift/Controllers/UIEvents/UIEvent.h"
namespace Swift {
@@ -12,8 +12,9 @@ namespace Swift {
class UIEventStream;
class SoundEventController {
public:
- SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds, UIEventStream* uiEvents);
+ SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, SettingsProvider* settings, UIEventStream* uiEvents);
void setPlaySounds(bool playSounds);
+ bool getSoundEnabled() {return playSounds_;};
private:
void handleUIEvent(boost::shared_ptr<UIEvent> event);
void handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event);
@@ -21,5 +22,6 @@ namespace Swift {
SoundPlayer* soundPlayer_;
bool playSounds_;
UIEventStream* uiEvents_;
+ SettingsProvider* settings_;
};
}