From bd80a4aea32b4e101ad46e1ec081875363b0c282 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Fri, 16 Jul 2010 16:02:04 +0200 Subject: [PATCH] added tray icon notifer,fixed SNorePlugin cast --- src/core/interface.h | 4 ++-- src/core/snoreserver.cpp | 17 ++++++++++++++--- src/main.cpp | 5 ++++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/core/interface.h b/src/core/interface.h index f02f24c..99dd4a1 100644 --- a/src/core/interface.h +++ b/src/core/interface.h @@ -36,8 +36,7 @@ private: }; -class SNORE_EXPORT Notification_Backend:public SnorePlugin -{ +class SNORE_EXPORT Notification_Backend:public SnorePlugin{ Q_OBJECT public: Notification_Backend(QString name,class SnoreServer *snore=0); @@ -54,6 +53,7 @@ public slots: class SNORE_EXPORT Notification_Frontend:public SnorePlugin{ + Q_OBJECT public: Notification_Frontend(QString name,class SnoreServer *snore=0); virtual ~Notification_Frontend(); diff --git a/src/core/snoreserver.cpp b/src/core/snoreserver.cpp index fe99925..77bbb42 100644 --- a/src/core/snoreserver.cpp +++ b/src/core/snoreserver.cpp @@ -16,6 +16,8 @@ #include "snoreserver.h" #include "notification.h" +#include "trayiconnotifer.h" + #include #include @@ -42,6 +44,14 @@ SnoreServer::SnoreServer(QSystemTrayIcon *trayIcon): }else QDir::temp().mkpath("SnoreNotify"); + + if(trayIcon!=NULL){ + _notificationBackend=new TrayIconNotifer(this,trayIcon); + _notyfier.insert(_notificationBackend->name(),_notificationBackend); + _primaryNotificationBackends.insert(_notificationBackend->name(),_notificationBackend); + connect(this,SIGNAL(notify(QSharedPointer)),_notificationBackend,SLOT(notify(QSharedPointer))); + _notificationBackend->notify(QSharedPointer(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+_notificationBackend->name(),""))); + } } void SnoreServer::publicatePlugin(const QString &fileName){ @@ -52,9 +62,10 @@ void SnoreServer::publicatePlugin(const QString &fileName){ return; } - SnorePlugin *sp = qobject_cast(plugin); + // SnorePlugin *sp = qobject_cast(plugin); + SnorePlugin *sp = dynamic_cast(plugin); if(sp==NULL){ - qDebug()<<"Error:"<name()); @@ -82,7 +93,7 @@ void SnoreServer::publicatePlugin(const QString &fileName){ connect(this,SIGNAL(notify(QSharedPointer)),_notificationBackend,SLOT(notify(QSharedPointer))); } _notificationBackend=nb; - _notificationBackend->notify(QSharedPointer(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+plugin->property("name").value(),""))); + _notificationBackend->notify(QSharedPointer(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+pluginName,""))); }else{ _notyfier.insert(pluginName,nb); diff --git a/src/main.cpp b/src/main.cpp index eb78b0c..84db693 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,11 +5,14 @@ #include #include #include +#include int main(int argc, char *argv[]) { QApplication a(argc, argv); - SnoreServer s; + QSystemTrayIcon *trayIcon=new QSystemTrayIcon(); + trayIcon->show(); + SnoreServer s(trayIcon); QDir pluginsDir(a.applicationDirPath()+"/snoreplugins"); foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {