summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-04 23:14:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-04 23:14:37 (GMT)
commit326cd32e2c9e3ec9bac54f5bb952928680c93749 (patch)
tree6992a6810897fdcdc9cce9cc2c7e2b79bf0e6011 /Swift/Controllers
parenta9173b68bf4a44325ec55843017d65d04a7f0c75 (diff)
downloadswift-326cd32e2c9e3ec9bac54f5bb952928680c93749.zip
swift-326cd32e2c9e3ec9bac54f5bb952928680c93749.tar.bz2
Allow sounds to be toggled.
Doesn't persist option yet. Resolves: #192
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/SoundEventController.cpp13
-rw-r--r--Swift/Controllers/SoundEventController.h7
-rw-r--r--Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h13
4 files changed, 32 insertions, 3 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp
index d042115..ccce0bb 100644
--- a/Swift/Controllers/MainController.cpp
+++ b/Swift/Controllers/MainController.cpp
@@ -71,7 +71,7 @@ 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));
+ soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings->getBoolSetting("playSounds", true), uiEventStream_);
loginWindow_ = loginWindowFactory_->createLoginWindow(uiEventStream_);
foreach (String profile, settings->getAvailableProfiles()) {
ProfileSettingsProvider* profileSettings = new ProfileSettingsProvider(profile, settings);
diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp
index 456de44..29f7fbf 100644
--- a/Swift/Controllers/SoundEventController.cpp
+++ b/Swift/Controllers/SoundEventController.cpp
@@ -4,14 +4,18 @@
#include "Swift/Controllers/EventController.h"
#include "Swift/Controllers/SoundPlayer.h"
+#include "Swift/Controllers/UIEvents/UIEventStream.h"
+#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h"
namespace Swift {
-SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds) {
+SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds, UIEventStream* uiEvents) {
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));
}
void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent>) {
@@ -22,4 +26,11 @@ void SoundEventController::setPlaySounds(bool playSounds) {
playSounds_ = 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());
+ }
+}
+
}
diff --git a/Swift/Controllers/SoundEventController.h b/Swift/Controllers/SoundEventController.h
index 07ac667..34499d4 100644
--- a/Swift/Controllers/SoundEventController.h
+++ b/Swift/Controllers/SoundEventController.h
@@ -4,17 +4,22 @@
#include "Swiften/Events/StanzaEvent.h"
+#include "Swift/Controllers/UIEvents/UIEvent.h"
+
namespace Swift {
class EventController;
class SoundPlayer;
+ class UIEventStream;
class SoundEventController {
public:
- SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds);
+ SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds, UIEventStream* uiEvents);
void setPlaySounds(bool playSounds);
private:
+ void handleUIEvent(boost::shared_ptr<UIEvent> event);
void handleEventQueueEventAdded(boost::shared_ptr<StanzaEvent> event);
EventController* eventController_;
SoundPlayer* soundPlayer_;
bool playSounds_;
+ UIEventStream* uiEvents_;
};
}
diff --git a/Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h b/Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h
new file mode 100644
index 0000000..826ee09
--- /dev/null
+++ b/Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h
@@ -0,0 +1,13 @@
+#pragma once
+
+#include "Swift/Controllers/UIEvents/UIEvent.h"
+
+namespace Swift {
+ class ToggleSoundsUIEvent : public UIEvent {
+ public:
+ ToggleSoundsUIEvent(bool enable) : enabled_(enable) {};
+ bool getEnabled() {return enabled_;};
+ private:
+ bool enabled_;
+ };
+}