summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Slimber')
-rw-r--r--Slimber/Qt/QtMenulet.h65
-rw-r--r--Slimber/Qt/Slimber.pro24
-rw-r--r--Slimber/Qt/Slimber.qrc9
-rw-r--r--Slimber/Qt/main.cpp19
4 files changed, 117 insertions, 0 deletions
diff --git a/Slimber/Qt/QtMenulet.h b/Slimber/Qt/QtMenulet.h
new file mode 100644
index 0000000..4ac9140
--- /dev/null
+++ b/Slimber/Qt/QtMenulet.h
@@ -0,0 +1,65 @@
+#pragma once
+
+#include <QCoreApplication>
+#include <QMenu>
+#include <QString>
+#include <QSystemTrayIcon>
+#include <QObject>
+#include <QPixmap>
+
+#include "Slimber/Menulet.h"
+
+class QtMenulet : public QObject, public Menulet {
+ Q_OBJECT
+ public:
+ QtMenulet() {
+ trayIcon.setIcon(QPixmap(":/icons/UsersOffline.png"));
+ trayIcon.setContextMenu(&menu);
+ trayIcon.show();
+ }
+
+ void clear() {
+ menu.clear();
+ }
+
+ void addItem(const Swift::String& name, const Swift::String& icon) {
+ menu.addAction(getIcon(icon), QString::fromUtf8(name.getUTF8Data()));
+ }
+
+ void addAboutItem() {
+ menu.addAction("About");
+ }
+
+ void addRestartItem() {
+ menu.addAction("Restart", this, SLOT(restart()));
+ }
+
+ void addExitItem() {
+ menu.addAction("Exit", qApp, SLOT(quit()));
+ }
+
+ void addSeparator() {
+ menu.addSeparator();
+ }
+
+ void setIcon(const Swift::String& icon) {
+ trayIcon.setIcon(getIcon(icon));
+ }
+
+ private:
+ QPixmap getIcon(const Swift::String& name) {
+ return QPixmap(":/icons/" + QString::fromUtf8(name.getUTF8Data()) + ".png");
+ }
+
+ private slots:
+ void showAboutDialog() {
+ }
+
+ void restart() {
+ onRestartClicked();
+ }
+
+ private:
+ QMenu menu;
+ QSystemTrayIcon trayIcon;
+};
diff --git a/Slimber/Qt/Slimber.pro b/Slimber/Qt/Slimber.pro
new file mode 100644
index 0000000..128bed6
--- /dev/null
+++ b/Slimber/Qt/Slimber.pro
@@ -0,0 +1,24 @@
+TEMPLATE = app
+CONFIG += debug
+TARGET = slimber
+
+DEPENDPATH += . ../.. ../../3rdParty/Boost
+INCLUDEPATH += . ../.. ../../3rdParty/Boost
+LIBS += ../Slimber.a ../../Swiften/Swiften.a -lexpat -L. -lavahi-client -lxml2
+include(config.pri)
+
+DEFINES += BOOST_SIGNALS_NAMESPACE=bsignals BOOST_ALL_NO_LIB
+
+HEADERS += \
+ QtMenulet.h
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += \
+ Slimber.qrc
+
+#win32 {
+# RC_FILE = ../Resources/Swift.rc
+#}
+
diff --git a/Slimber/Qt/Slimber.qrc b/Slimber/Qt/Slimber.qrc
new file mode 100644
index 0000000..6cc21ff
--- /dev/null
+++ b/Slimber/Qt/Slimber.qrc
@@ -0,0 +1,9 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource>
+ <file alias="icons/Offline.png">../Resources/Offline.png</file>
+ <file alias="icons/Online.png">../Resources/Online.png</file>
+ <file alias="icons/UsersOffline.png">../Resources/UsersOffline.png</file>
+ <file alias="icons/UsersOnline.png">../Resources/UsersOnline.png</file>
+ </qresource>
+</RCC>
diff --git a/Slimber/Qt/main.cpp b/Slimber/Qt/main.cpp
new file mode 100644
index 0000000..0988e7c
--- /dev/null
+++ b/Slimber/Qt/main.cpp
@@ -0,0 +1,19 @@
+#include <QApplication>
+#include <QSystemTrayIcon>
+#include <QMessageBox>
+
+#include "QtMenulet.h"
+#include "Slimber/MainController.h"
+
+int main(int argc, char* argv[]) {
+ QApplication app(argc, argv);
+ if (!QSystemTrayIcon::isSystemTrayAvailable()) {
+QMessageBox::critical(0, QObject::tr("Systray"), QObject::tr("No system tray"));
+ return 1;
+ }
+
+ QtMenulet menulet;
+ MainController controller(&menulet);
+
+ return app.exec();
+}