mirror of
https://github.com/status-im/snorenotify.git
synced 2025-01-09 16:15:45 +00:00
added tray icon notifer,fixed SNorePlugin cast
This commit is contained in:
parent
109f15450e
commit
bd80a4aea3
@ -36,8 +36,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SNORE_EXPORT Notification_Backend:public SnorePlugin
|
class SNORE_EXPORT Notification_Backend:public SnorePlugin{
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Notification_Backend(QString name,class SnoreServer *snore=0);
|
Notification_Backend(QString name,class SnoreServer *snore=0);
|
||||||
@ -54,6 +53,7 @@ public slots:
|
|||||||
|
|
||||||
|
|
||||||
class SNORE_EXPORT Notification_Frontend:public SnorePlugin{
|
class SNORE_EXPORT Notification_Frontend:public SnorePlugin{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Notification_Frontend(QString name,class SnoreServer *snore=0);
|
Notification_Frontend(QString name,class SnoreServer *snore=0);
|
||||||
virtual ~Notification_Frontend();
|
virtual ~Notification_Frontend();
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#include "snoreserver.h"
|
#include "snoreserver.h"
|
||||||
#include "notification.h"
|
#include "notification.h"
|
||||||
|
#include "trayiconnotifer.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
@ -42,6 +44,14 @@ SnoreServer::SnoreServer(QSystemTrayIcon *trayIcon):
|
|||||||
|
|
||||||
}else
|
}else
|
||||||
QDir::temp().mkpath("SnoreNotify");
|
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<Notification>)),_notificationBackend,SLOT(notify(QSharedPointer<Notification>)));
|
||||||
|
_notificationBackend->notify(QSharedPointer<Notification>(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+_notificationBackend->name(),"")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreServer::publicatePlugin(const QString &fileName){
|
void SnoreServer::publicatePlugin(const QString &fileName){
|
||||||
@ -52,9 +62,10 @@ void SnoreServer::publicatePlugin(const QString &fileName){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SnorePlugin *sp = qobject_cast<SnorePlugin*>(plugin);
|
// SnorePlugin *sp = qobject_cast<SnorePlugin*>(plugin);
|
||||||
|
SnorePlugin *sp = dynamic_cast<SnorePlugin*>(plugin);
|
||||||
if(sp==NULL){
|
if(sp==NULL){
|
||||||
qDebug()<<"Error:"<<fileName<<"is not a snarl plugin" ;
|
std::cerr<<"Error:"<<fileName.toLatin1().data()<<"is not a snarl plugin"<<std::endl ;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString pluginName(sp->name());
|
QString pluginName(sp->name());
|
||||||
@ -82,7 +93,7 @@ void SnoreServer::publicatePlugin(const QString &fileName){
|
|||||||
connect(this,SIGNAL(notify(QSharedPointer<Notification>)),_notificationBackend,SLOT(notify(QSharedPointer<Notification>)));
|
connect(this,SIGNAL(notify(QSharedPointer<Notification>)),_notificationBackend,SLOT(notify(QSharedPointer<Notification>)));
|
||||||
}
|
}
|
||||||
_notificationBackend=nb;
|
_notificationBackend=nb;
|
||||||
_notificationBackend->notify(QSharedPointer<Notification>(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+plugin->property("name").value<QString>(),"")));
|
_notificationBackend->notify(QSharedPointer<Notification>(new Notification(NULL,"Welcome","Snore Notify succesfully registred "+pluginName,"")));
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
_notyfier.insert(pluginName,nb);
|
_notyfier.insert(pluginName,nb);
|
||||||
|
@ -5,11 +5,14 @@
|
|||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPluginLoader>
|
#include <QPluginLoader>
|
||||||
|
#include <QSystemTrayIcon>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
SnoreServer s;
|
QSystemTrayIcon *trayIcon=new QSystemTrayIcon();
|
||||||
|
trayIcon->show();
|
||||||
|
SnoreServer s(trayIcon);
|
||||||
|
|
||||||
QDir pluginsDir(a.applicationDirPath()+"/snoreplugins");
|
QDir pluginsDir(a.applicationDirPath()+"/snoreplugins");
|
||||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user