diff options
Diffstat (limited to 'Swift')
-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 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.cpp | 13 | ||||
-rw-r--r-- | Swift/QtUI/QtLoginWindow.h | 1 |
6 files changed, 46 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_; + }; +} diff --git a/Swift/QtUI/QtLoginWindow.cpp b/Swift/QtUI/QtLoginWindow.cpp index da23ea0..4f6b423 100644 --- a/Swift/QtUI/QtLoginWindow.cpp +++ b/Swift/QtUI/QtLoginWindow.cpp @@ -2,6 +2,7 @@ #include "Swift/Controllers/UIEvents/UIEventStream.h" #include "Swift/Controllers/UIEvents/RequestXMLConsoleUIEvent.h" +#include "Swift/Controllers/UIEvents/ToggleSoundsUIEvent.h" #include "Swiften/Base/Platform.h" #include "QtAboutWidget.h" @@ -115,6 +116,13 @@ QtLoginWindow::QtLoginWindow(UIEventStream* uiEventStream) : QMainWindow() { QAction* xmlConsoleAction = new QAction(tr("Show Debug Console"), this); connect(xmlConsoleAction, SIGNAL(activated()), SLOT(handleShowXMLConsole())); toolsMenu_->addAction(xmlConsoleAction); + + QAction* toggleSoundsAction = new QAction(tr("Toggle Sounds"), this); + toggleSoundsAction->setCheckable(true); + toggleSoundsAction->setChecked(true); + connect(toggleSoundsAction, SIGNAL(toggled(bool)), SLOT(handleToggleSounds(bool))); + swiftMenu_->addAction(toggleSoundsAction); + QAction* quitAction = new QAction("Quit", this); connect(quitAction, SIGNAL(activated()), SLOT(handleQuit())); @@ -234,6 +242,11 @@ void QtLoginWindow::handleShowXMLConsole() { uiEventStream_->send(boost::shared_ptr<RequestXMLConsoleUIEvent>(new RequestXMLConsoleUIEvent())); } +void QtLoginWindow::handleToggleSounds(bool enabled) { + uiEventStream_->send(boost::shared_ptr<ToggleSoundsUIEvent>(new ToggleSoundsUIEvent(enabled))); +} + + void QtLoginWindow::handleQuit() { QApplication::quit(); } diff --git a/Swift/QtUI/QtLoginWindow.h b/Swift/QtUI/QtLoginWindow.h index 38852ce..40ea4ec 100644 --- a/Swift/QtUI/QtLoginWindow.h +++ b/Swift/QtUI/QtLoginWindow.h @@ -39,6 +39,7 @@ namespace Swift { void handleCertficateChecked(bool); void handleQuit(); void handleShowXMLConsole(); + void handleToggleSounds(bool enabled); void handleAbout(); void bringToFront(); void handleUsernameTextChanged(); |