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>
namespace Snore{
class SnoreIcon::SnoreIconData : public QObject
class SnoreIcon::SnoreIconData
{
Q_OBJECT
public:
SnoreIconData():
m_isLocalFile(false)
@ -108,7 +107,7 @@ SnoreIcon &SnoreIcon::operator=(const SnoreIcon &other)
{
if(d && !d->m_ref.deref())
{
d->deleteLater();
delete d;
}
other.d->m_ref.ref();
d = other.d;
@ -119,7 +118,7 @@ SnoreIcon::~SnoreIcon()
{
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;
class Notification::NotificationData : public QObject
class Notification::NotificationData
{
Q_OBJECT
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 ):
m_id ( id == 0 ?m_idCount++:id),
@ -117,7 +116,7 @@ Notification::~Notification()
{
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())
{
d->deleteLater();
delete d;
}
other.d->m_ref.ref();
d = other.d;
@ -246,22 +245,17 @@ bool Notification::isValid() const
return d != NULL;
}
const QObject *Notification::data() const
{
return d;
}
QDataStream & operator<< ( QDataStream &stream, const Notification &noti )
QDataStream &operator<< ( QDataStream &stream, const Notification &noti )
{
stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ;
return stream;
}
QDataStream & operator<< ( QDataStream &stream, const Notification::Action &a)
QDataStream &operator<< ( QDataStream &stream, const Notification::Action &a)
{
stream<<a.id<<a.id;
return stream;
}
}
#include "notification.moc"

View File

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

View File

@ -68,8 +68,12 @@ bool SnoreBackend::requestCloseNotification ( Notification notification,Notifica
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);
slotCloseNotification(n);
emit closeNotification(n);
}

View File

@ -61,9 +61,18 @@ public:
}else if(msg->message == SNORENOTIFIER_MESSAGE_ID){
int action = msg->wParam & 0xffff;
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);
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;
switch(action){
case SnarlEnums::CallbackInvoked:
@ -217,7 +226,8 @@ void SnarlBackend::slotNotify(Notification notification){
startTimeout(notification.id(),notification.timeout());
}
bool SnarlBackend::slotCloseNotification(Notification notification){
m_defautSnarlinetrface->Hide(m_idMap.remove(notification.id()));
bool SnarlBackend::slotCloseNotification(Notification notification)
{
m_defautSnarlinetrface->Hide(m_idMap.take(notification.id()));
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(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill()));
connect(notification.data(),SIGNAL(destroyed()),p,SLOT(kill()));
QStringList arguements;
arguements << "-t"