diff options
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/Controllers/MainController.cpp | 2 | ||||
-rw-r--r-- | Swift/Controllers/SystemTray.h | 3 | ||||
-rw-r--r-- | Swift/Controllers/SystemTrayController.cpp | 3 | ||||
-rw-r--r-- | Swift/Controllers/SystemTrayController.h | 5 | ||||
-rw-r--r-- | Swift/QtUI/QtSystemTray.cpp | 26 | ||||
-rw-r--r-- | Swift/QtUI/QtSystemTray.h | 8 |
6 files changed, 42 insertions, 5 deletions
diff --git a/Swift/Controllers/MainController.cpp b/Swift/Controllers/MainController.cpp index 9e4eb00..a2fb3a4 100644 --- a/Swift/Controllers/MainController.cpp +++ b/Swift/Controllers/MainController.cpp @@ -277,6 +277,7 @@ void MainController::handleChangeStatusRequest(StatusShow::Type show, const Stri void MainController::sendPresence(boost::shared_ptr<Presence> presence) { rosterController_->getWindow()->setMyStatusType(presence->getShow()); rosterController_->getWindow()->setMyStatusText(presence->getStatus()); + systemTrayController_->setMyStatusType(presence->getShow()); // Add information and send if (!vCardPhotoHash_.isEmpty()) { @@ -408,6 +409,7 @@ void MainController::signOut() { } void MainController::logout() { + systemTrayController_->setMyStatusType(StatusShow::None); resetPendingReconnects(); if (client_ /*&& client_->isAvailable()*/) { client_->disconnect(); diff --git a/Swift/Controllers/SystemTray.h b/Swift/Controllers/SystemTray.h index cd007e7..2821785 100644 --- a/Swift/Controllers/SystemTray.h +++ b/Swift/Controllers/SystemTray.h @@ -6,10 +6,13 @@ #pragma once +#include "Swiften/Elements/StatusShow.h" + namespace Swift { class SystemTray { public: virtual ~SystemTray(){}; virtual void setUnreadMessages(bool some) = 0; + virtual void setStatusType(StatusShow::Type type) = 0; }; } diff --git a/Swift/Controllers/SystemTrayController.cpp b/Swift/Controllers/SystemTrayController.cpp index 00c0f31..758bdd8 100644 --- a/Swift/Controllers/SystemTrayController.cpp +++ b/Swift/Controllers/SystemTrayController.cpp @@ -23,5 +23,8 @@ void SystemTrayController::handleEventQueueLengthChange(int length) { systemTray_->setUnreadMessages(length > 0); } +void SystemTrayController::setMyStatusType(StatusShow::Type type) { + systemTray_->setStatusType(type); +} } diff --git a/Swift/Controllers/SystemTrayController.h b/Swift/Controllers/SystemTrayController.h index 3c5d29e..8fd514f 100644 --- a/Swift/Controllers/SystemTrayController.h +++ b/Swift/Controllers/SystemTrayController.h @@ -6,13 +6,16 @@ #pragma once +#include "Swiften/Elements/StatusShow.h" + namespace Swift { class EventController; class SystemTray; class SystemTrayController { public: - SystemTrayController(EventController* eventController, SystemTray* systemTray); + SystemTrayController(EventController* eventController, SystemTray* systemTray); + void setMyStatusType(StatusShow::Type type); private: void handleEventQueueLengthChange(int length); diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp index de8de23..681e403 100644 --- a/Swift/QtUI/QtSystemTray.cpp +++ b/Swift/QtUI/QtSystemTray.cpp @@ -11,8 +11,8 @@ #include <QResource> namespace Swift { -QtSystemTray::QtSystemTray() : QObject(), standardIcon_(":icons/online.png"), newMessageIcon_(":icons/new-chat.png") { - trayIcon_ = new QSystemTrayIcon(standardIcon_); +QtSystemTray::QtSystemTray() : QObject(), onlineIcon_(":icons/online.png"), awayIcon_(":icons/away.png"), dndIcon_(":icons/dnd.png"), offlineIcon_(":icons/offline.png"), newMessageIcon_(":icons/new-chat.png") { + trayIcon_ = new QSystemTrayIcon(offlineIcon_); connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason))); trayIcon_->show(); } @@ -22,7 +22,11 @@ QtSystemTray::~QtSystemTray() { } void QtSystemTray::setUnreadMessages(bool some) { - trayIcon_->setIcon(some ? newMessageIcon_ : standardIcon_); + if (some) { + trayIcon_->setIcon(newMessageIcon_); + } else { + updateStatusIcon(); + } } void QtSystemTray::handleIconActivated(QSystemTrayIcon::ActivationReason reason) { @@ -30,4 +34,20 @@ void QtSystemTray::handleIconActivated(QSystemTrayIcon::ActivationReason reason) emit clicked(); } } +void QtSystemTray::setStatusType(StatusShow::Type type) { + statusType_ = type; + updateStatusIcon(); +} + +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; + } +} + } diff --git a/Swift/QtUI/QtSystemTray.h b/Swift/QtUI/QtSystemTray.h index 9fb699f..136dd4c 100644 --- a/Swift/QtUI/QtSystemTray.h +++ b/Swift/QtUI/QtSystemTray.h @@ -19,13 +19,19 @@ namespace Swift { QtSystemTray(); ~QtSystemTray(); void setUnreadMessages(bool some); + void setStatusType(StatusShow::Type type); signals: void clicked(); private slots: void handleIconActivated(QSystemTrayIcon::ActivationReason reason); private: + void updateStatusIcon(); + StatusShow::Type statusType_; QSystemTrayIcon* trayIcon_; - QIcon standardIcon_; + QIcon onlineIcon_; + QIcon awayIcon_; + QIcon dndIcon_; + QIcon offlineIcon_; QIcon newMessageIcon_; }; } |