diff options
author | Kevin Smith <git@kismith.co.uk> | 2009-06-18 20:34:41 (GMT) |
---|---|---|
committer | Kevin Smith <git@kismith.co.uk> | 2009-06-18 20:35:22 (GMT) |
commit | 9a457c621bd75a9929cc0616b7659dba2945fdac (patch) | |
tree | fa1b7e541355edb1983dea78728892ddf89f08ff /Swift/QtUI | |
parent | 38e83db22eed41e115c1483323a62c62be34dbec (diff) | |
download | swift-contrib-9a457c621bd75a9929cc0616b7659dba2945fdac.zip swift-contrib-9a457c621bd75a9929cc0616b7659dba2945fdac.tar.bz2 |
System Tray
We need to have a look at the icons somewhat, but these will do for the second.
Diffstat (limited to 'Swift/QtUI')
-rw-r--r-- | Swift/QtUI/QtSwift.cpp | 5 | ||||
-rw-r--r-- | Swift/QtUI/QtSwift.h | 4 | ||||
-rw-r--r-- | Swift/QtUI/QtSystemTray.cpp | 21 | ||||
-rw-r--r-- | Swift/QtUI/QtSystemTray.h | 20 | ||||
-rw-r--r-- | Swift/QtUI/Swift.pro | 2 | ||||
-rw-r--r-- | Swift/QtUI/Swift.qrc | 2 |
6 files changed, 52 insertions, 2 deletions
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp index b8b45a1..6aab3b4 100644 --- a/Swift/QtUI/QtSwift.cpp +++ b/Swift/QtUI/QtSwift.cpp @@ -4,6 +4,7 @@ #include "QtChatWindowFactory.h" #include "QtMainWindowFactory.h" #include "QtTreeWidgetFactory.h" +#include "QtSystemTray.h" #include <boost/bind.hpp> @@ -22,12 +23,13 @@ QtSwift::QtSwift() : chatWindowFactory_(new QtChatWindowFactory(treeWidgetFactory_)), rosterWindowFactory_(new QtMainWindowFactory(treeWidgetFactory_)), loginWindowFactory_(new QtLoginWindowFactory()) { + systemTray_ = new QtSystemTray(); QCoreApplication::setApplicationName("Swift"); QCoreApplication::setOrganizationName("Swift"); QCoreApplication::setOrganizationDomain("swift.im"); settings_ = new QtSettingsProvider(); application_ = new PlatformApplication("Swift"); - mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, settings_, application_); + mainController_ = new MainController(chatWindowFactory_, rosterWindowFactory_, loginWindowFactory_, treeWidgetFactory_, settings_, application_, systemTray_); } QtSwift::~QtSwift() { @@ -38,6 +40,7 @@ QtSwift::~QtSwift() { delete mainController_; delete settings_; delete application_; + delete systemTray_; } } diff --git a/Swift/QtUI/QtSwift.h b/Swift/QtUI/QtSwift.h index 5bfd62c..5c6656a 100644 --- a/Swift/QtUI/QtSwift.h +++ b/Swift/QtUI/QtSwift.h @@ -15,7 +15,8 @@ namespace Swift { class QtMainWindowFactory; class QtLoginWindowFactory; class QtTreeWidgetFactory; - + class QtSystemTray; + class QtSwift : public QObject { Q_OBJECT public: @@ -29,6 +30,7 @@ namespace Swift { QtLoginWindowFactory *loginWindowFactory_; QtMainEventLoop clientMainThreadCaller_; QtSettingsProvider *settings_; + QtSystemTray* systemTray_; Application* application_; }; } diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp new file mode 100644 index 0000000..b22da6b --- /dev/null +++ b/Swift/QtUI/QtSystemTray.cpp @@ -0,0 +1,21 @@ +#include "Swift/QtUI/QtSystemTray.h" + +#include <QIcon> +#include <QPixmap> +#include <QResource> + +namespace Swift { +QtSystemTray::QtSystemTray() : standardIcon_(":icons/tray-standard.png"), newMessageIcon_(":icons/new-chat.png") { + trayIcon_ = new QSystemTrayIcon(standardIcon_); + trayIcon_->show(); +} + +QtSystemTray::~QtSystemTray() { + delete trayIcon_; +} + +void QtSystemTray::setUnreadMessages(bool some) { + trayIcon_->setIcon(some ? newMessageIcon_ : standardIcon_); +} + +}
\ No newline at end of file diff --git a/Swift/QtUI/QtSystemTray.h b/Swift/QtUI/QtSystemTray.h new file mode 100644 index 0000000..40cc540 --- /dev/null +++ b/Swift/QtUI/QtSystemTray.h @@ -0,0 +1,20 @@ +#pragma once + +#include "Swift/Controllers/SystemTray.h" + +#include <QSystemTrayIcon> + +class QIcon; + +namespace Swift { + class QtSystemTray : public SystemTray { + public: + QtSystemTray(); + ~QtSystemTray(); + void setUnreadMessages(bool some); + private: + QSystemTrayIcon* trayIcon_; + QIcon standardIcon_; + QIcon newMessageIcon_; + }; +} diff --git a/Swift/QtUI/Swift.pro b/Swift/QtUI/Swift.pro index fbf5537..6221fa8 100644 --- a/Swift/QtUI/Swift.pro +++ b/Swift/QtUI/Swift.pro @@ -60,6 +60,7 @@ HEADERS += \ QtTreeWidgetItem.h \ QtChatView.h \ QtChatTabs.h \ + QtSystemTray.h \ QtTabbable.h \ ChatSnippet.h \ MessageSnippet.h \ @@ -80,6 +81,7 @@ SOURCES += \ QtTreeWidget.cpp \ QtChatView.cpp \ QtChatTabs.cpp \ + QtSystemTray.cpp \ ChatSnippet.cpp \ MessageSnippet.cpp \ SystemMessageSnippet.cpp diff --git a/Swift/QtUI/Swift.qrc b/Swift/QtUI/Swift.qrc index 2db382e..4e3b9df 100644 --- a/Swift/QtUI/Swift.qrc +++ b/Swift/QtUI/Swift.qrc @@ -5,5 +5,7 @@ <file alias="icons/certificate.png">../../resources/icons/certificate.png</file> <file alias="icons/error.png">../../resources/icons/error.png</file> <file alias="icons/avatar.png">../../resources/icons/avatar.png</file> + <file alias="icons/tray-standard.png">../../resources/icons/tray-standard.png</file> + <file alias="icons/new-chat.png">../../resources/icons/new-chat.png</file> </qresource> </RCC> |