diff options
Diffstat (limited to 'Swift/Controllers')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.cpp | 13 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.h | 7 | ||||
-rw-r--r-- | Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h | 13 |
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_; + }; +} |