diff options
author | Kevin Smith <git@kismith.co.uk> | 2010-06-26 19:56:55 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2010-06-26 19:56:55 (GMT) |
commit | 533111880ed9346dc8844f148a5dcfecb5095047 (patch) | |
tree | da9c0f8a84335d68580a6a3b93313dc6aa1a8db5 /Swift/QtUI | |
parent | de7ee8e38a2dfaab9fde40a7916c8212f5859d68 (diff) | |
download | swift-contrib-533111880ed9346dc8844f148a5dcfecb5095047.zip swift-contrib-533111880ed9346dc8844f148a5dcfecb5095047.tar.bz2 |
Show status in system tray.
Resolves: #304
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSystemTray.cpp | 26 | ||||
-rw-r--r-- | Swift/QtUI/QtSystemTray.h | 8 |
2 files changed, 30 insertions, 4 deletions
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_; }; } |