more debug output, and added support for close notification to win8 backend
This commit is contained in:
parent
a6a668bb9f
commit
8e987c1cf8
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "notification/icon.h"
|
||||
#include "notification/notification_p.h"
|
||||
#include "plugins/plugincontainer.h"
|
||||
#include <QMetaEnum>
|
||||
#include <Qt>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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<QProcess*>(sender());
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue