diff options
| author | Kevin Smith <git@kismith.co.uk> | 2010-10-05 18:24:02 (GMT) | 
|---|---|---|
| committer | Kevin Smith <git@kismith.co.uk> | 2010-10-05 18:24:02 (GMT) | 
| commit | bfeca3cc938e325bf2cc2d9105c719feb1fe28ee (patch) | |
| tree | 8089a181b678912432f0ae4a61759b92566c62fb /Swift/Controllers/EventNotifier.cpp | |
| parent | 6cdd48b30526761f5c6365496e30580ed3bd8a82 (diff) | |
| download | swift-contrib-bfeca3cc938e325bf2cc2d9105c719feb1fe28ee.zip swift-contrib-bfeca3cc938e325bf2cc2d9105c719feb1fe28ee.tar.bz2 | |
Create 'Enable notifications' menu on Linux.
I've not actually tested this on Linux...
Resolves: #594
Diffstat (limited to 'Swift/Controllers/EventNotifier.cpp')
| -rw-r--r-- | Swift/Controllers/EventNotifier.cpp | 18 | 
1 files changed, 17 insertions, 1 deletions
| diff --git a/Swift/Controllers/EventNotifier.cpp b/Swift/Controllers/EventNotifier.cpp index 7a293b6..7743d6f 100644 --- a/Swift/Controllers/EventNotifier.cpp +++ b/Swift/Controllers/EventNotifier.cpp @@ -16,11 +16,17 @@  #include "Swift/Controllers/XMPPEvents/MessageEvent.h"  #include "Swift/Controllers/XMPPEvents/SubscriptionRequestEvent.h"  #include "Swift/Controllers/XMPPEvents/ErrorEvent.h" +#include "Swift/Controllers/UIEvents/UIEventStream.h" +#include "Swift/Controllers/UIEvents/ToggleNotificationsUIEvent.h" +#include "Swiften/Settings/SettingsProvider.h"  namespace Swift { -EventNotifier::EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver) : eventController(eventController), notifier(notifier), avatarManager(avatarManager), nickResolver(nickResolver) { +EventNotifier::EventNotifier(EventController* eventController, Notifier* notifier, AvatarManager* avatarManager, NickResolver* nickResolver, UIEventStream* uiEvents, SettingsProvider* settings) : eventController(eventController), notifier(notifier), avatarManager(avatarManager), nickResolver(nickResolver), uiEvents(uiEvents), settings(settings) {  	eventController->onEventQueueEventAdded.connect(boost::bind(&EventNotifier::handleEventAdded, this, _1)); +	bool enabled = settings->getBoolSetting("showNotifications", true); +	notifier->setEnabled(enabled); +	uiEvents->send(boost::shared_ptr<ToggleNotificationsUIEvent>(new ToggleNotificationsUIEvent(enabled)));  }  EventNotifier::~EventNotifier() { @@ -49,4 +55,14 @@ void EventNotifier::handleNotificationActivated(JID jid) {  	onNotificationActivated(jid);  } +void EventNotifier::handleUIEvent(boost::shared_ptr<UIEvent> event) { +	boost::shared_ptr<ToggleNotificationsUIEvent> notificationsEvent = boost::dynamic_pointer_cast<ToggleNotificationsUIEvent>(event); +	if (notificationsEvent) { +		bool enabled = notificationsEvent->getEnabled(); +		if (enabled != notifier->getEnabled()) { +			notifier->setEnabled(enabled); +			settings->storeBool("showNotifications", enabled); +		} +	} +}  } | 
 Swift
 Swift