summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-08-28 16:53:45 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-08-28 16:53:45 (GMT)
commit18c39e032395ee49796d330905caea4e28ef5608 (patch)
treed5da261d27feff987ea0cdd37992dd0a9d9b6ad2
parentabc4579164fa06b6f8a7d9d27d6e36c100cbcc4f (diff)
downloadswift-18c39e032395ee49796d330905caea4e28ef5608.zip
swift-18c39e032395ee49796d330905caea4e28ef5608.tar.bz2
Show the hidden roster on system tray click.
-rw-r--r--Swift/QtUI/QtLoginWindowFactory.cpp4
-rw-r--r--Swift/QtUI/QtLoginWindowFactory.h7
-rw-r--r--Swift/QtUI/QtSwift.cpp6
-rw-r--r--Swift/QtUI/QtSystemTray.cpp8
-rw-r--r--Swift/QtUI/QtSystemTray.h7
5 files changed, 24 insertions, 8 deletions
diff --git a/Swift/QtUI/QtLoginWindowFactory.cpp b/Swift/QtUI/QtLoginWindowFactory.cpp
index 5d63ebc..c150892 100644
--- a/Swift/QtUI/QtLoginWindowFactory.cpp
+++ b/Swift/QtUI/QtLoginWindowFactory.cpp
@@ -3,8 +3,9 @@
namespace Swift {
-QtLoginWindowFactory::QtLoginWindowFactory(QSplitter* splitter) {
+QtLoginWindowFactory::QtLoginWindowFactory(QSplitter* splitter, QtSystemTray* systemTray) : QObject() {
splitter_ = splitter;
+ systemTray_ = systemTray;
}
LoginWindow* QtLoginWindowFactory::createLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate) {
@@ -12,6 +13,7 @@ LoginWindow* QtLoginWindowFactory::createLoginWindow(const String& defaultJID, c
if (splitter_) {
splitter_->insertWidget(0, window);
}
+ connect(systemTray_, SIGNAL(clicked()), window, SLOT(show()));
return window;
}
}
diff --git a/Swift/QtUI/QtLoginWindowFactory.h b/Swift/QtUI/QtLoginWindowFactory.h
index 617851e..7513ab6 100644
--- a/Swift/QtUI/QtLoginWindowFactory.h
+++ b/Swift/QtUI/QtLoginWindowFactory.h
@@ -2,16 +2,19 @@
#define SWIFT_QtLoginWindowFactory_H
#include "Swift/Controllers/LoginWindowFactory.h"
+#include "Swift/QtUI/QtSystemTray.h"
#include <QSplitter>
namespace Swift {
- class QtLoginWindowFactory : public LoginWindowFactory{
+ class QtLoginWindowFactory : public QObject, public LoginWindowFactory {
+ Q_OBJECT
public:
- QtLoginWindowFactory(QSplitter* splitter);
+ QtLoginWindowFactory(QSplitter* splitter, QtSystemTray* systemTray);
LoginWindow* createLoginWindow(const String& defaultJID, const String& defaultPassword, const String& defaultCertificate);
private:
QSplitter* splitter_;
+ QtSystemTray* systemTray_;
};
}
diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index 00efc17..90742a5 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -27,10 +27,10 @@ QtSwift::QtSwift(bool netbookMode) {
splitter_ = NULL;
}
treeWidgetFactory_ = new QtTreeWidgetFactory();
- loginWindowFactory_ = new QtLoginWindowFactory(splitter_);
- rosterWindowFactory_ = new QtMainWindowFactory(treeWidgetFactory_);
- chatWindowFactory_ = new QtChatWindowFactory(treeWidgetFactory_, splitter_);
systemTray_ = new QtSystemTray();
+ loginWindowFactory_ = new QtLoginWindowFactory(splitter_, systemTray_);
+ chatWindowFactory_ = new QtChatWindowFactory(treeWidgetFactory_, splitter_);
+ rosterWindowFactory_ = new QtMainWindowFactory(treeWidgetFactory_);
soundPlayer_ = new QtSoundPlayer();
QCoreApplication::setApplicationName("Swift");
QCoreApplication::setOrganizationName("Swift");
diff --git a/Swift/QtUI/QtSystemTray.cpp b/Swift/QtUI/QtSystemTray.cpp
index f1c8e27..e85f13f 100644
--- a/Swift/QtUI/QtSystemTray.cpp
+++ b/Swift/QtUI/QtSystemTray.cpp
@@ -5,8 +5,9 @@
#include <QResource>
namespace Swift {
-QtSystemTray::QtSystemTray() : standardIcon_(":icons/tray-standard.png"), newMessageIcon_(":icons/new-chat.png") {
+QtSystemTray::QtSystemTray() : QObject(), standardIcon_(":icons/tray-standard.png"), newMessageIcon_(":icons/new-chat.png") {
trayIcon_ = new QSystemTrayIcon(standardIcon_);
+ connect(trayIcon_, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(handleIconActivated(QSystemTrayIcon::ActivationReason)));
trayIcon_->show();
}
@@ -18,4 +19,9 @@ void QtSystemTray::setUnreadMessages(bool some) {
trayIcon_->setIcon(some ? newMessageIcon_ : standardIcon_);
}
+void QtSystemTray::handleIconActivated(QSystemTrayIcon::ActivationReason reason) {
+ if (reason == QSystemTrayIcon::Trigger) {
+ emit clicked();
+ }
+}
}
diff --git a/Swift/QtUI/QtSystemTray.h b/Swift/QtUI/QtSystemTray.h
index 40cc540..4ef55d9 100644
--- a/Swift/QtUI/QtSystemTray.h
+++ b/Swift/QtUI/QtSystemTray.h
@@ -7,11 +7,16 @@
class QIcon;
namespace Swift {
- class QtSystemTray : public SystemTray {
+ class QtSystemTray : public QObject, public SystemTray {
+ Q_OBJECT
public:
QtSystemTray();
~QtSystemTray();
void setUnreadMessages(bool some);
+ signals:
+ void clicked();
+ private slots:
+ void handleIconActivated(QSystemTrayIcon::ActivationReason reason);
private:
QSystemTrayIcon* trayIcon_;
QIcon standardIcon_;