diff --git a/CMakeLists.txt b/CMakeLists.txt
index caaf646..fed43ee 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,7 +49,7 @@ option(WITH_WEBINTERFACE "Buld with WebInterface" OFF)
set(PLUGIN_INSTALL_PATH LIBRARY DESTINATION bin/snoreplugins)
-
+add_subdirectory(data)
add_subdirectory(src)
install(FILES share/FindLibsnore.cmake DESTINATION share/apps/cmake/modules)
diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt
new file mode 100644
index 0000000..5ffd513
--- /dev/null
+++ b/data/CMakeLists.txt
@@ -0,0 +1 @@
+set(SNORE_RCS ${SNORE_RCS} ../data/snore.qrc PARENT_SCOPE)
diff --git a/data/snore.qrc b/data/snore.qrc
new file mode 100644
index 0000000..644ca3e
--- /dev/null
+++ b/data/snore.qrc
@@ -0,0 +1,5 @@
+
+
+ zzz.png
+
+
diff --git a/data/zzz.png b/data/zzz.png
new file mode 100644
index 0000000..942a304
Binary files /dev/null and b/data/zzz.png differ
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5cd24d0..8a59367 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,8 +5,10 @@ include_directories(
add_subdirectory(core)
-add_executable ( snorenotify main.cpp )
-target_link_libraries ( snorenotify snorecore ${QT_QTGUI_LIBRARY})
+QT4_ADD_RESOURCES(snorenotify_DEPS ${SNORE_RCS})
+automoc4_add_executable( snorenotify main.cpp trayicon.cpp ${snorenotify_DEPS})
+
+target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} )
add_dependencies(snorenotify snorecore)
install(TARGETS snorenotify RUNTIME DESTINATION bin
@@ -16,4 +18,3 @@ install(TARGETS snorenotify RUNTIME DESTINATION bin
#add_subdirectory(webinterface)
add_subdirectory(plugins)
-
diff --git a/src/main.cpp b/src/main.cpp
index e1b195a..b258a85 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,5 +1,8 @@
-#include
+
#include "core/snoreserver.h"
+#include "trayicon.h"
+
+#include
#include
#include
#include
@@ -10,17 +13,19 @@
int main ( int argc, char *argv[] )
{
QApplication a ( argc, argv );
- QSystemTrayIcon *trayIcon=new QSystemTrayIcon();
- trayIcon->show();
- SnoreServer s ( trayIcon );
+ QSystemTrayIcon *trayIcon=new QSystemTrayIcon(QIcon(":/root/zzz.png"));
+ trayIcon->setVisible(true);
+
+ SnoreServer *s = new SnoreServer( trayIcon );
QDir pluginsDir ( a.applicationDirPath() +"/snoreplugins" );
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )
{
- s.publicatePlugin ( pluginsDir.absoluteFilePath ( fileName ) );
+ s->publicatePlugin ( pluginsDir.absoluteFilePath ( fileName ) );
}
-
+ TrayIcon *i = new TrayIcon(trayIcon,s);
+ i->initConextMenu();
return a.exec();
}
diff --git a/src/trayicon.cpp b/src/trayicon.cpp
new file mode 100644
index 0000000..deab4fe
--- /dev/null
+++ b/src/trayicon.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************************
+ * Copyright (c) 2010 Patrick von Reth *
+ * *
+ * This program is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License as published by the Free Software *
+ * Foundation; either version 2 of the License, or (at your option) any later *
+ * version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along with *
+ * this program. If not, see . *
+ ****************************************************************************************/
+
+#include "trayicon.h"
+#include "snore/core/snoreserver.h"
+
+#include
+#include
+#include
+
+TrayIcon::TrayIcon(QSystemTrayIcon *trayIcon, SnoreServer *snore ):
+ _trayIcon(trayIcon),
+ _snore(snore)
+{
+}
+
+void TrayIcon::initConextMenu(){
+
+ _trayMenu = new QMenu("SnoreNotify");
+ _trayMenu->addAction("SnoreNotify");
+ _trayMenu->addSeparator();
+ foreach(Notification_Backend *back,_snore->primaryNotificationBackends()){
+ QAction *b= new QAction(back->name(),this);
+ connect(b,SIGNAL(triggered()),this,SLOT(setPrimaryBackend()));
+ _trayMenu->addAction(b);
+ }
+ _trayMenu->addSeparator();
+ _trayMenu->addAction("Exit",qApp,SLOT(quit()));
+
+
+ _trayIcon->setContextMenu(_trayMenu);
+}
+
+void TrayIcon::setPrimaryBackend(){
+ QAction *a= dynamic_cast(sender());
+ _snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text()));
+}
+
+
+
+#include "trayicon.moc"
diff --git a/src/trayicon.h b/src/trayicon.h
new file mode 100644
index 0000000..d0067a1
--- /dev/null
+++ b/src/trayicon.h
@@ -0,0 +1,39 @@
+/****************************************************************************************
+ * Copyright (c) 2010 Patrick von Reth *
+ * *
+ * This program is free software; you can redistribute it and/or modify it under *
+ * the terms of the GNU General Public License as published by the Free Software *
+ * Foundation; either version 2 of the License, or (at your option) any later *
+ * version. *
+ * *
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY *
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
+ * PARTICULAR PURPOSE. See the GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License along with *
+ * this program. If not, see . *
+ ****************************************************************************************/
+
+#ifndef TRAYICON_H
+#define TRAYICON_H
+
+#include
+
+class TrayIcon:public QObject
+{
+ Q_OBJECT
+public:
+ TrayIcon(class QSystemTrayIcon *trayIcon,class SnoreServer *snore);
+ void initConextMenu();
+
+private:
+ class QSystemTrayIcon *_trayIcon;
+ class QMenu *_trayMenu;
+ class SnoreServer *_snore;
+
+
+public slots:
+ void setPrimaryBackend();
+};
+
+#endif // TRAYICON_H