diff options
Diffstat (limited to 'Slimber/Qt')
-rw-r--r-- | Slimber/Qt/QtMenulet.cpp | 2 | ||||
-rw-r--r-- | Slimber/Qt/QtMenulet.h | 65 | ||||
-rw-r--r-- | Slimber/Qt/SConscript | 45 | ||||
-rw-r--r-- | Slimber/Qt/Slimber.qrc | 9 | ||||
-rw-r--r-- | Slimber/Qt/main.cpp | 19 |
5 files changed, 140 insertions, 0 deletions
diff --git a/Slimber/Qt/QtMenulet.cpp b/Slimber/Qt/QtMenulet.cpp new file mode 100644 index 0000000..58c7d50 --- /dev/null +++ b/Slimber/Qt/QtMenulet.cpp @@ -0,0 +1,2 @@ +#include "Slimber/Qt/QtMenulet.h" + 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/SConscript b/Slimber/Qt/SConscript new file mode 100644 index 0000000..b2b8320 --- /dev/null +++ b/Slimber/Qt/SConscript @@ -0,0 +1,45 @@ +import os, shutil, datetime + +Import("env") + +myenv = env.Clone() + +myenv.MergeFlags(env["SLIMBER_FLAGS"]) +myenv.MergeFlags(env["SWIFTEN_FLAGS"]) +myenv.MergeFlags(env["CPPUNIT_FLAGS"]) +myenv.MergeFlags(env["LIBIDN_FLAGS"]) +myenv.MergeFlags(env["BOOST_FLAGS"]) +myenv.MergeFlags(env.get("LIBXML_FLAGS", "")) +myenv.MergeFlags(env.get("EXPAT_FLAGS", "")) + +myenv.Tool("qt4", toolpath = ["#/BuildTools/SCons/Tools"]) +myenv.Tool("nsis", toolpath = ["#/BuildTools/SCons/Tools"]) +myenv.EnableQt4Modules(['QtCore', 'QtGui'], debug = False) + +myenv.Append(CPPPATH = ["."]) + +if env["PLATFORM"] == "win32" : + myenv.Append(LINKFLAGS = ["/SUBSYSTEM:WINDOWS"]) + myenv.Append(LIBS = "qtmain") + +sources = ["main.cpp", "QtMenulet.cpp"] + +#if env["PLATFORM"] == "win32" : +# myenv.RES("../resources/Windows/Slimber.rc") +# sources += ["../resources/Windows/Slimber.res"] + +if env["PLATFORM"] == "win32" : + slimberProgram = myenv.Program("Slimber", sources) +else : + slimberProgram = myenv.Program("slimber", sources) + +myenv.Qrc("Slimber.qrc") + +if env["PLATFORM"] == "win32" : + if "dist" in COMMAND_LINE_TARGETS or env.GetOption("clean") : + myenv.WindowsBundle("Slimber", resources = [], qtlibs = ["QtCore4", "QtGui4"]) + myenv.Append(NSIS_OPTIONS = [ + "/DmsvccRedistributableDir=\"" + env["vcredist"] + "\"", + "/DbuildDate=" + datetime.date.today().strftime("%Y%m%d") + ]) + #myenv.Nsis("../Packaging/nsis/slimber.nsi") 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(); +} |