From 6f4fa16b1ddb0633771423a8e8d9520864ffb95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Wed, 5 Aug 2009 19:09:37 +0200 Subject: Slimber: Add Qt implementation. 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 +#include +#include +#include +#include +#include + +#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 @@ + + + + ../Resources/Offline.png + ../Resources/Online.png + ../Resources/UsersOffline.png + ../Resources/UsersOnline.png + + 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 +#include +#include + +#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(); +} -- cgit v0.10.2-6-g49f6