From 2fb3d3266bd22d84604688dc9ee18b17b211b91d Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Fri, 1 Oct 2010 20:32:14 +0100 Subject: Only show system tray message icon for message events. Resolves: #583 diff --git a/Swift/Controllers/SystemTrayController.cpp b/Swift/Controllers/SystemTrayController.cpp index 23a94fa..d3824c9 100644 --- a/Swift/Controllers/SystemTrayController.cpp +++ b/Swift/Controllers/SystemTrayController.cpp @@ -19,8 +19,16 @@ SystemTrayController::SystemTrayController(EventController* eventController, Sys eventController_->onEventQueueLengthChange.connect(boost::bind(&SystemTrayController::handleEventQueueLengthChange, this, _1)); } -void SystemTrayController::handleEventQueueLengthChange(int length) { - systemTray_->setUnreadMessages(length > 0); +void SystemTrayController::handleEventQueueLengthChange(int /*length*/) { + EventList events = eventController_->getEvents(); + bool found = false; + for (EventList::iterator it = events.begin(); it != events.end(); it++) { + if (boost::dynamic_pointer_cast<MessageEvent>(*it)) { + found = true; + break; + } + } + systemTray_->setUnreadMessages(found); } void SystemTrayController::setMyStatusType(StatusShow::Type type) { diff --git a/Swift/Controllers/XMPPEvents/EventController.h b/Swift/Controllers/XMPPEvents/EventController.h index b405556..ba3fd5b 100644 --- a/Swift/Controllers/XMPPEvents/EventController.h +++ b/Swift/Controllers/XMPPEvents/EventController.h @@ -16,16 +16,19 @@ #include "Swift/Controllers/XMPPEvents/MessageEvent.h" namespace Swift { + typedef std::vector<boost::shared_ptr<StanzaEvent> > EventList; class EventController { public: + EventController(); void handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceEvent); boost::signal<void (int)> onEventQueueLengthChange; boost::signal<void (boost::shared_ptr<StanzaEvent>)> onEventQueueEventAdded; + const EventList getEvents() const {return events_;} private: void handleEventConcluded(boost::shared_ptr<StanzaEvent> event); - std::vector<boost::shared_ptr<StanzaEvent> > events_; + EventList events_; }; } #endif -- cgit v0.10.2-6-g49f6