diff --git a/share/snoretoast/SnoreToast.exe b/share/snoretoast/SnoreToast.exe index 96d70d2..eb45738 100644 Binary files a/share/snoretoast/SnoreToast.exe and b/share/snoretoast/SnoreToast.exe differ diff --git a/src/core/notification/CMakeLists.txt b/src/core/notification/CMakeLists.txt index a2469f9..95ef48e 100644 --- a/src/core/notification/CMakeLists.txt +++ b/src/core/notification/CMakeLists.txt @@ -6,7 +6,7 @@ set ( SnoreNotify_SRCS ${SnoreNotify_SRCS} notification/icon_p.cpp PARENT_SCOPE) -set ( Notification_HDR +set ( Notification_HDR notification.h notification_p.h notificationaction.h diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index 0f3716e..fe15ce2 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -22,6 +22,7 @@ #include "notification/icon.h" #include "notification/notification_p.h" #include "plugins/plugincontainer.h" +#include #include using namespace Snore; @@ -174,5 +175,31 @@ QDataStream &operator<< ( QDataStream &stream, const Notification ¬i ) return stream; } +QDebug operator <<(QDebug debug, const Snore::Notification::CloseReasons &flags) +{ + static QMetaEnum e = Notification::staticMetaObject.property(Notification::staticMetaObject.indexOfProperty("closeReason")).enumerator(); + debug.nospace() << "CloseReasons("; + bool needSeparator = false; + int key; + for (int i = 0; i < e.keyCount(); ++i) + { + key = e.value(i); + if (flags.testFlag((Notification::CloseReason)key)) + { + if (needSeparator) + { + debug.nospace() << '|'; + } + else + { + needSeparator = true; + } + debug.nospace() << e.valueToKey(key); + + } + } + debug << ')'; + return debug.space(); +} diff --git a/src/core/notification/notification.h b/src/core/notification/notification.h index 6d864be..9d5a01d 100644 --- a/src/core/notification/notification.h +++ b/src/core/notification/notification.h @@ -43,9 +43,13 @@ class NotificationData; class SNORE_EXPORT Notification { + /* + Q_OBJECT + */ + Q_GADGET + Q_PROPERTY(CloseReasons closeReason READ closeReason) friend class NotificationData; public: - /** * The reason why the Notification was closed. */ @@ -54,25 +58,26 @@ public: /** * The default value, the notification was not closed. */ - NONE = 0x0, + NONE = 0, /** * The Notification was closed becaouse it timed out. */ - TIMED_OUT = 0x1, + TIMED_OUT = 1, /** * The Notification was dismissed by the user, close button. */ - DISMISSED = 0x2, + DISMISSED = 2, /** * The Notification was closed after an action was invoked. * @see actionInvoked() */ - CLOSED = 0x4 + CLOSED = 3 }; Q_DECLARE_FLAGS(CloseReasons, CloseReason) + Q_ENUMS(CloseReasons) /** * The Priority for the Notification. @@ -283,6 +288,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Snore::Notification::Prioritys) QDataStream &operator<< ( QDataStream & stream, const Snore::Notification & noti ); +SNORE_EXPORT QDebug operator<< ( QDebug, const Snore::Notification::CloseReasons &); + inline QDebug operator<< ( QDebug debug, const Snore::Notification ¬i ) { if(noti.isValid()) diff --git a/src/core/notification/notification_p.h b/src/core/notification/notification_p.h index 7c1570f..7168ffe 100644 --- a/src/core/notification/notification_p.h +++ b/src/core/notification/notification_p.h @@ -32,9 +32,11 @@ namespace Snore{ + class SNORE_EXPORT NotificationData : public QSharedData { -friend class Notification; + + friend class Notification; public: NotificationData ( const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon, int timeout,Notification::Prioritys priority ); @@ -53,6 +55,7 @@ public: void setCloseReason(Notification::CloseReasons r); + QTimer *timeoutTimer(); private: diff --git a/src/plugins/backends/snoretoast/snoretoast.cpp b/src/plugins/backends/snoretoast/snoretoast.cpp index dbc88f7..61616a2 100644 --- a/src/plugins/backends/snoretoast/snoretoast.cpp +++ b/src/plugins/backends/snoretoast/snoretoast.cpp @@ -17,7 +17,7 @@ Q_EXPORT_PLUGIN2(libsnore_backend_snoretoast,SnoreToast) SnoreToast::SnoreToast(): - SnoreBackend("Windows 8",false,false) + SnoreBackend("Windows 8", true, false) { } @@ -57,8 +57,9 @@ void SnoreToast::slotNotify(Notification notification) } arguements << "-w" << "-appID" - << appId(notification.application()); - ; + << appId(notification.application()) + << "-id" + << QString::number(notification.id()); if(notification.hints().value("silent",true).toBool()) { arguements << "-silent"; @@ -89,6 +90,22 @@ void SnoreToast::slotRegisterApplication(const Application &application) } } +void SnoreToast::slotCloseNotification(Notification notification) +{ + QProcess *p = new QProcess(this); + p->setReadChannelMode(QProcess::MergedChannels); + + QStringList arguements; + arguements << "-close" + << "-id" + << QString::number(notification.id()); + snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements; + p->start("SnoreToast", arguements); + + connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus))); + connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill())); +} + void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus) { QProcess *p = qobject_cast(sender()); diff --git a/src/plugins/backends/snoretoast/snoretoast.h b/src/plugins/backends/snoretoast/snoretoast.h index 5a2357a..6cff5a3 100644 --- a/src/plugins/backends/snoretoast/snoretoast.h +++ b/src/plugins/backends/snoretoast/snoretoast.h @@ -17,6 +17,7 @@ public: public slots: void slotNotify(Snore::Notification notification); void slotRegisterApplication(const Snore::Application &application); + void slotCloseNotification ( Snore::Notification notification ); private slots: void slotToastNotificationClosed(int code, QProcess::ExitStatus);