diff options
-rw-r--r-- | Swift/Controllers/MainController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.cpp | 8 | ||||
-rw-r--r-- | Swift/Controllers/SoundEventController.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.cpp | 9 | ||||
-rw-r--r-- | Swift/QtUI/QtSettingsProvider.h | 2 | ||||
-rw-r--r-- | Swiften/Settings/SettingsProvider.h | 2 |
6 files changed, 23 insertions, 4 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 1fc0b2d..6bed7da 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -70,7 +70,7 @@ MainController::MainController(ChatWindowFactory* chatWindowFactory, MainWindowF eventController_ = new EventController(); eventController_->onEventQueueLengthChange.connect(boost::bind(&MainController::handleEventQueueLengthChange, this, _1)); systemTrayController_ = new SystemTrayController(eventController_, systemTray); - soundEventController_ = new SoundEventController(eventController_, soundPlayer); + soundEventController_ = new SoundEventController(eventController_, soundPlayer, settings->getBoolSetting("playSounds", true)); loginWindow_ = loginWindowFactory_->createLoginWindow(settings->getStringSetting("jid"), settings->getStringSetting("pass"), settings->getStringSetting("certificate")); loginWindow_->onLoginRequest.connect(boost::bind(&MainController::handleLoginRequest, this, _1, _2, _3, _4)); } diff --git a/Swift/Controllers/SoundEventController.cpp b/Swift/Controllers/SoundEventController.cpp index 46d6ddb..133becf 100644 --- a/Swift/Controllers/SoundEventController.cpp +++ b/Swift/Controllers/SoundEventController.cpp @@ -7,15 +7,19 @@ namespace Swift { -SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer) { +SoundEventController::SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds) { eventController_ = eventController; soundPlayer_ = soundPlayer; + playSounds_ = playSounds; eventController_->onEventQueueEventAdded.connect(boost::bind(&SoundEventController::handleEventQueueEventAdded, this, _1)); } void SoundEventController::handleEventQueueEventAdded(boost::shared_ptr<MessageEvent> event) { - soundPlayer_->playSound(SoundPlayer::MessageReceived); + if (playSounds_) soundPlayer_->playSound(SoundPlayer::MessageReceived); } +void SoundEventController::setPlaySounds(bool playSounds) { + playSounds_ = playSounds; +} } diff --git a/Swift/Controllers/SoundEventController.h b/Swift/Controllers/SoundEventController.h index 8da057d..9ac6f76 100644 --- a/Swift/Controllers/SoundEventController.h +++ b/Swift/Controllers/SoundEventController.h @@ -9,10 +9,12 @@ namespace Swift { class SoundPlayer; class SoundEventController { public: - SoundEventController(EventController* eventController, SoundPlayer* soundPlayer); + SoundEventController(EventController* eventController, SoundPlayer* soundPlayer, bool playSounds); + void setPlaySounds(bool playSounds); private: void handleEventQueueEventAdded(boost::shared_ptr<MessageEvent> event); EventController* eventController_; SoundPlayer* soundPlayer_; + bool playSounds_; }; } diff --git a/Swift/QtUI/QtSettingsProvider.cpp b/Swift/QtUI/QtSettingsProvider.cpp index 42540c1..cf02d83 100644 --- a/Swift/QtUI/QtSettingsProvider.cpp +++ b/Swift/QtUI/QtSettingsProvider.cpp @@ -19,5 +19,14 @@ void QtSettingsProvider::storeString(const String &settingPath, const String &se settings_.setValue(P2QSTRING(settingPath), P2QSTRING(settingValue)); } +bool QtSettingsProvider::getBoolSetting(const String &settingPath, bool defaultValue) { + QVariant setting = settings_.value(P2QSTRING(settingPath)); + return setting.isNull() ? defaultValue : setting.toBool(); +} + +void QtSettingsProvider::storeBool(const String &settingPath, bool settingValue) { + settings_.setValue(P2QSTRING(settingPath), settingValue); +} + } diff --git a/Swift/QtUI/QtSettingsProvider.h b/Swift/QtUI/QtSettingsProvider.h index 4739f60..fec4101 100644 --- a/Swift/QtUI/QtSettingsProvider.h +++ b/Swift/QtUI/QtSettingsProvider.h @@ -13,6 +13,8 @@ class QtSettingsProvider : public SettingsProvider { virtual ~QtSettingsProvider(); virtual String getStringSetting(const String &settingPath); virtual void storeString(const String &settingPath, const String &settingValue); + virtual bool getBoolSetting(const String &settingPath, bool defaultValue); + virtual void storeBool(const String &settingPath, bool settingValue); private: QSettings settings_; }; diff --git a/Swiften/Settings/SettingsProvider.h b/Swiften/Settings/SettingsProvider.h index ebf8d24..e311911 100644 --- a/Swiften/Settings/SettingsProvider.h +++ b/Swiften/Settings/SettingsProvider.h @@ -10,6 +10,8 @@ class SettingsProvider { virtual ~SettingsProvider() {} virtual String getStringSetting(const String &settingPath) = 0; virtual void storeString(const String &settingPath, const String &settingValue) = 0; + virtual bool getBoolSetting(const String &settingPath, bool defaultValue) = 0; + virtual void storeBool(const String &settingPath, bool settingValue) = 0; }; } |