added tray icon and possebility to select backend
This commit is contained in:
parent
b591336d16
commit
431bf01e85
|
@ -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)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
set(SNORE_RCS ${SNORE_RCS} ../data/snore.qrc PARENT_SCOPE)
|
|
@ -0,0 +1,5 @@
|
|||
<RCC>
|
||||
<qresource prefix="/root">
|
||||
<file>zzz.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -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)
|
||||
|
||||
|
|
17
src/main.cpp
17
src/main.cpp
|
@ -1,5 +1,8 @@
|
|||
#include <QtGui/QApplication>
|
||||
|
||||
#include "core/snoreserver.h"
|
||||
#include "trayicon.h"
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QList>
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/****************************************************************************************
|
||||
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include "trayicon.h"
|
||||
#include "snore/core/snoreserver.h"
|
||||
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
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<QAction*>(sender());
|
||||
_snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "trayicon.moc"
|
|
@ -0,0 +1,39 @@
|
|||
/****************************************************************************************
|
||||
* Copyright (c) 2010 Patrick von Reth <patrick.vonreth@gmail.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef TRAYICON_H
|
||||
#define TRAYICON_H
|
||||
|
||||
#include <QtCore>
|
||||
|
||||
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
|
Loading…
Reference in New Issue