From cc8eb390a08580900ef2a00b1d3d45ce93a81785 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Fri, 23 Jul 2010 10:59:14 +0100
Subject: Don't allow a status change to override the new message systray icon.

Resolves: #481

diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp
index 681e403..57bf20c 100644
--- a/Swift/QtUI/QtSystemTray.cpp
+++ b/Swift/QtUI/QtSystemTray.cpp
@@ -11,7 +11,7 @@
 #include <QResource>
 
 namespace Swift {
-QtSystemTray::QtSystemTray() : QObject(), onlineIcon_(":icons/online.png"), awayIcon_(":icons/away.png"), dndIcon_(":icons/dnd.png"), offlineIcon_(":icons/offline.png"), newMessageIcon_(":icons/new-chat.png") {
+QtSystemTray::QtSystemTray() : QObject(), onlineIcon_(":icons/online.png"), awayIcon_(":icons/away.png"), dndIcon_(":icons/dnd.png"), offlineIcon_(":icons/offline.png"), newMessageIcon_(":icons/new-chat.png"), unreadMessages_(false) {
 	trayIcon_ = new QSystemTrayIcon(offlineIcon_);
 	connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason)));
 	trayIcon_->show();
@@ -22,11 +22,8 @@ QtSystemTray::~QtSystemTray() {
 }
 
 void QtSystemTray::setUnreadMessages(bool some) {
-	if (some) {
-		trayIcon_->setIcon(newMessageIcon_);
-	} else {
-		updateStatusIcon();
-	}
+	unreadMessages_ = some;
+	updateStatusIcon();
 }
 
 void QtSystemTray::handleIconActivated(QSystemTrayIcon::ActivationReason reason) {
@@ -40,13 +37,17 @@ void QtSystemTray::setStatusType(StatusShow::Type type) {
 }
 
 void QtSystemTray::updateStatusIcon() {
-	switch (statusType_) {
-		case StatusShow::Online : trayIcon_->setIcon(onlineIcon_);break;
-		case StatusShow::FFC : trayIcon_->setIcon(onlineIcon_);break;
-		case StatusShow::Away : trayIcon_->setIcon(awayIcon_);break;
-		case StatusShow::XA : trayIcon_->setIcon(awayIcon_);break;
-		case StatusShow::DND : trayIcon_->setIcon(dndIcon_);break;
-		case StatusShow::None : trayIcon_->setIcon(offlineIcon_);break;
+	if (unreadMessages_) {
+		trayIcon_->setIcon(newMessageIcon_);
+	} else {
+		switch (statusType_) {
+			case StatusShow::Online : trayIcon_->setIcon(onlineIcon_);break;
+			case StatusShow::FFC : trayIcon_->setIcon(onlineIcon_);break;
+			case StatusShow::Away : trayIcon_->setIcon(awayIcon_);break;
+			case StatusShow::XA : trayIcon_->setIcon(awayIcon_);break;
+			case StatusShow::DND : trayIcon_->setIcon(dndIcon_);break;
+			case StatusShow::None : trayIcon_->setIcon(offlineIcon_);break;
+		}
 	}
 }
 
diff --git a/Swift/QtUI/QtSystemTray.h b/Swift/QtUI/QtSystemTray.h
index 136dd4c..c889ecf 100644
--- a/Swift/QtUI/QtSystemTray.h
+++ b/Swift/QtUI/QtSystemTray.h
@@ -33,5 +33,6 @@ namespace Swift {
 			QIcon dndIcon_;
 			QIcon offlineIcon_;
 			QIcon newMessageIcon_;
+			bool unreadMessages_;
 	};
 }
-- 
cgit v0.10.2-6-g49f6