This commit is contained in:
Patrick von Reth 2013-07-07 13:39:58 +02:00
parent 8745c966f5
commit ca1a89d3ef
6 changed files with 39 additions and 29 deletions

View File

@ -24,9 +24,8 @@
#include <QDebug> #include <QDebug>
namespace Snore{ namespace Snore{
class SnoreIcon::SnoreIconData : public QObject class SnoreIcon::SnoreIconData
{ {
Q_OBJECT
public: public:
SnoreIconData(): SnoreIconData():
m_isLocalFile(false) m_isLocalFile(false)
@ -108,7 +107,7 @@ SnoreIcon &SnoreIcon::operator=(const SnoreIcon &other)
{ {
if(d && !d->m_ref.deref()) if(d && !d->m_ref.deref())
{ {
d->deleteLater(); delete d;
} }
other.d->m_ref.ref(); other.d->m_ref.ref();
d = other.d; d = other.d;
@ -119,7 +118,7 @@ SnoreIcon::~SnoreIcon()
{ {
if(d && !d->m_ref.deref()) if(d && !d->m_ref.deref())
{ {
d->deleteLater(); delete d;
} }
} }
@ -178,6 +177,3 @@ const QString &SnoreIcon::url() const
} }
} }
#include "icon.moc"

View File

@ -36,9 +36,8 @@ int Notification::notificationCount = 0;
uint Notification::m_idCount = 1; uint Notification::m_idCount = 1;
class Notification::NotificationData : public QObject class Notification::NotificationData
{ {
Q_OBJECT
public: public:
NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const SnoreIcon &icon,int timeout,uint id,NotificationEnums::Prioritys::prioritys priority ): NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const SnoreIcon &icon,int timeout,uint id,NotificationEnums::Prioritys::prioritys priority ):
m_id ( id == 0 ?m_idCount++:id), m_id ( id == 0 ?m_idCount++:id),
@ -117,7 +116,7 @@ Notification::~Notification()
{ {
if(d && !d->m_ref.deref()) if(d && !d->m_ref.deref())
{ {
d->deleteLater(); delete d;
} }
} }
@ -125,7 +124,7 @@ Notification &Notification::operator=(const Notification& other)
{ {
if(d && !d->m_ref.deref()) if(d && !d->m_ref.deref())
{ {
d->deleteLater(); delete d;
} }
other.d->m_ref.ref(); other.d->m_ref.ref();
d = other.d; d = other.d;
@ -246,22 +245,17 @@ bool Notification::isValid() const
return d != NULL; return d != NULL;
} }
const QObject *Notification::data() const QDataStream &operator<< ( QDataStream &stream, const Notification &noti )
{
return d;
}
QDataStream & operator<< ( QDataStream &stream, const Notification &noti )
{ {
stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ; stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ;
return stream; return stream;
} }
QDataStream & operator<< ( QDataStream &stream, const Notification::Action &a)
QDataStream &operator<< ( QDataStream &stream, const Notification::Action &a)
{ {
stream<<a.id<<a.id; stream<<a.id<<a.id;
return stream; return stream;
} }
} }
#include "notification.moc"

View File

@ -25,6 +25,8 @@
#include "notificationenums.h" #include "notificationenums.h"
#include <QVariant> #include <QVariant>
#include <QDebug>
namespace Snore{ namespace Snore{
class SNORE_EXPORT Notification class SNORE_EXPORT Notification
@ -74,8 +76,6 @@ public:
bool isValid() const; bool isValid() const;
const QObject *data() const;
//protected://TODO::make only accesable from a backend //protected://TODO::make only accesable from a backend
void setActionInvoked ( Action *action ); void setActionInvoked ( Action *action );
void setActionInvoked ( const int &actionID); void setActionInvoked ( const int &actionID);
@ -94,6 +94,13 @@ private:
Q_DECLARE_METATYPE(Snore::Notification) Q_DECLARE_METATYPE(Snore::Notification)
QDataStream & operator<< ( QDataStream & stream, const Snore::Notification & noti ); QDataStream &operator<< ( QDataStream & stream, const Snore::Notification & noti );
QDataStream & operator<< ( QDataStream & stream, const Snore::Notification::Action & action);
inline QDebug operator<< ( QDebug debug, const Snore::Notification &noti )
{
debug << "Snore::Notification(" << noti.title() << ", " << noti.text() << "," << noti.id() << ")" ;
return debug.maybeSpace();
}
QDataStream &operator<< ( QDataStream & stream, const Snore::Notification::Action & action);
#endif // NOTIFICATION_H #endif // NOTIFICATION_H

View File

@ -68,8 +68,12 @@ bool SnoreBackend::requestCloseNotification ( Notification notification,Notifica
void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseReasons::closeReasons reason) void SnoreBackend::closeNotification(Notification n, NotificationEnums::CloseReasons::closeReasons reason)
{ {
m_activeNotifications.remove(n.id()); if(m_activeNotifications.contains(n.id()))
{
m_activeNotifications.remove(n.id());
}
n.setCloseReason(reason); n.setCloseReason(reason);
slotCloseNotification(n);
emit closeNotification(n); emit closeNotification(n);
} }

View File

@ -61,9 +61,18 @@ public:
}else if(msg->message == SNORENOTIFIER_MESSAGE_ID){ }else if(msg->message == SNORENOTIFIER_MESSAGE_ID){
int action = msg->wParam & 0xffff; int action = msg->wParam & 0xffff;
int data = (msg->wParam & 0xffffffff) >> 16; int data = (msg->wParam & 0xffffffff) >> 16;
uint notificationID = msg->lParam; uint notificationID = 0;
for(QHash<uint,LONG32>::iterator it = m_snarl->m_idMap.begin();it != m_snarl->m_idMap.end();++it)
{
if(it.value() == msg->lParam)
{
notificationID = it.key();
break;
}
}
Notification notification = m_snarl->snore()->getActiveNotificationByID(notificationID); Notification notification = m_snarl->snore()->getActiveNotificationByID(notificationID);
qDebug()<<"recived a Snarl callback id:"<<notificationID<<"action:"<<action<<"data:"<<data; qDebug()<<"recived a Snarl callback id:"<<notificationID<< "|" << msg->lParam <<"action:"<<action<<"data:"<<data;
NotificationEnums::CloseReasons::closeReasons reason = NotificationEnums::CloseReasons::NONE; NotificationEnums::CloseReasons::closeReasons reason = NotificationEnums::CloseReasons::NONE;
switch(action){ switch(action){
case SnarlEnums::CallbackInvoked: case SnarlEnums::CallbackInvoked:
@ -217,7 +226,8 @@ void SnarlBackend::slotNotify(Notification notification){
startTimeout(notification.id(),notification.timeout()); startTimeout(notification.id(),notification.timeout());
} }
bool SnarlBackend::slotCloseNotification(Notification notification){ bool SnarlBackend::slotCloseNotification(Notification notification)
m_defautSnarlinetrface->Hide(m_idMap.remove(notification.id())); {
m_defautSnarlinetrface->Hide(m_idMap.take(notification.id()));
return true; return true;
} }

View File

@ -65,7 +65,6 @@ void SnoreToast::slotNotify(Notification notification)
connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus))); connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus)));
connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill())); connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill()));
connect(notification.data(),SIGNAL(destroyed()),p,SLOT(kill()));
QStringList arguements; QStringList arguements;
arguements << "-t" arguements << "-t"