summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-09-12 18:55:01 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-09-12 18:55:01 (GMT)
commit7dafb815ca404f1e15c9cdf6b26817c941dae4ec (patch)
tree5f1a523042bd4b9ccb84efce74ab2441dacef8ea /Swift
parent7e157ace6678dd4af7a091ea5cc5fbc3baabe7f7 (diff)
downloadswift-7dafb815ca404f1e15c9cdf6b26817c941dae4ec.zip
swift-7dafb815ca404f1e15c9cdf6b26817c941dae4ec.tar.bz2
Getting ready for sounds to be turned off.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/MainController.cpp2
-rw-r--r--Swift/Controllers/SoundEventController.cpp8
-rw-r--r--Swift/Controllers/SoundEventController.h4
-rw-r--r--Swift/QtUI/QtSettingsProvider.cpp9
-rw-r--r--Swift/QtUI/QtSettingsProvider.h2
5 files changed, 21 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_;
};