added saving of backend, why doesnt it work ...

This commit is contained in:
Patrick von Reth 2010-12-31 18:19:37 +01:00
parent 7de255da37
commit 9e5d649551
6 changed files with 28 additions and 33 deletions

View File

@ -14,9 +14,9 @@ else(WIN32)
set(WIN32_SPECIFIC) set(WIN32_SPECIFIC)
endif(WIN32) endif(WIN32)
automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp trayicon.cpp ${SNORENOTIFY_DEPS}) automoc4_add_executable( snorenotify ${WIN32_SPECIFIC} main.cpp snorenotify.cpp trayicon.cpp ${SNORENOTIFY_DEPS})
target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ) target_link_libraries( snorenotify snorecore ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY} )
if(MSVC) if(MSVC)
set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"") set_target_properties(snorenotify PROPERTIES LINK_FLAGS "/ENTRY:\"mainCRTStartup\"")

View File

@ -202,7 +202,11 @@ void SnoreServer::setPrimaryNotificationBackend ( Notification_Backend *backend
if(!backend->isPrimaryNotificationBackend()) if(!backend->isPrimaryNotificationBackend())
return; return;
qDebug()<<"Setting Notification Backend to:"<<backend->name(); qDebug()<<"Setting Notification Backend to:"<<backend->name();
_notificationBackend=backend; _notificationBackend = backend;
}
Notification_Backend * SnoreServer::primaryNotificationBackend(){
return _notificationBackend;
} }
SnoreNotificationInstance * SnoreServer::defaultNotificationInterface() SnoreNotificationInstance * SnoreServer::defaultNotificationInterface()

View File

@ -48,6 +48,7 @@ public:
const QHash<QString,Notification_Backend*> &primaryNotificationBackends() const; const QHash<QString,Notification_Backend*> &primaryNotificationBackends() const;
void setPrimaryNotificationBackend ( Notification_Backend *backend ); void setPrimaryNotificationBackend ( Notification_Backend *backend );
Notification_Backend* primaryNotificationBackend();
class SnoreNotificationInstance *defaultNotificationInterface(); class SnoreNotificationInstance *defaultNotificationInterface();

View File

@ -1,33 +1,12 @@
#include "core/snoreserver.h" #include "snorenotify.h"
#include "trayicon.h"
#include <QtGui/QApplication> #include <QtGui/QApplication>
#include <QDir>
#include <QFile>
#include <QList>
#include <QDebug>
#include <QPluginLoader>
#include <QSystemTrayIcon>
int main ( int argc, char *argv[] ) int main ( int argc, char *argv[] )
{ {
QApplication a ( argc, argv ); QApplication a ( argc, argv );
QSystemTrayIcon *trayIcon=new QSystemTrayIcon(QIcon(":/root/zzz.png")); SnoreNotify();
trayIcon->setVisible(true);
SnoreServer *s = new SnoreServer( trayIcon );
s->cleanupTMP();
QDir pluginsDir ( a.applicationDirPath() +"/snoreplugins" );
foreach ( QString fileName, pluginsDir.entryList ( QDir::Files ) )
{
s->publicatePlugin ( pluginsDir.absoluteFilePath ( fileName ) );
}
TrayIcon *i = new TrayIcon(trayIcon,s);
i->initConextMenu();
return a.exec(); return a.exec();
} }

View File

@ -21,13 +21,14 @@
#include <QMenu> #include <QMenu>
#include <QAction> #include <QAction>
TrayIcon::TrayIcon(QSystemTrayIcon *trayIcon, SnoreServer *snore ): TrayIcon::TrayIcon()
_trayIcon(trayIcon), {
_snore(snore) _trayIcon = new QSystemTrayIcon(QIcon(":/root/zzz.png"));
{
} }
void TrayIcon::initConextMenu(){ void TrayIcon::initConextMenu(SnoreServer *snore){
_snore = snore;
_trayIcon->setVisible(true);
_trayMenu = new QMenu("SnoreNotify"); _trayMenu = new QMenu("SnoreNotify");
_trayMenu->addAction(QString("SnoreNotify ").append(_snore->version())); _trayMenu->addAction(QString("SnoreNotify ").append(_snore->version()));
@ -44,6 +45,14 @@ void TrayIcon::initConextMenu(){
_trayIcon->setContextMenu(_trayMenu); _trayIcon->setContextMenu(_trayMenu);
} }
void TrayIcon::hide(){
_trayIcon->setVisible(false);
}
QSystemTrayIcon* TrayIcon::trayIcon(){
return _trayIcon;
}
void TrayIcon::setPrimaryBackend(){ void TrayIcon::setPrimaryBackend(){
QAction *a= dynamic_cast<QAction*>(sender()); QAction *a= dynamic_cast<QAction*>(sender());
_snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text())); _snore->setPrimaryNotificationBackend(_snore->primaryNotificationBackends().value(a->text()));

View File

@ -23,8 +23,10 @@ class TrayIcon:public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
TrayIcon(class QSystemTrayIcon *trayIcon,class SnoreServer *snore); TrayIcon();
void initConextMenu(); void initConextMenu(class SnoreServer *snore);
void hide();
class QSystemTrayIcon* trayIcon();
private: private:
class QSystemTrayIcon *_trayIcon; class QSystemTrayIcon *_trayIcon;