mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-18 19:26:36 +00:00
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.
@ -22,6 +22,7 @@
|
|||||||
#include "notification/icon.h"
|
#include "notification/icon.h"
|
||||||
#include "notification/notification_p.h"
|
#include "notification/notification_p.h"
|
||||||
#include "plugins/plugincontainer.h"
|
#include "plugins/plugincontainer.h"
|
||||||
|
#include <QMetaEnum>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
using namespace Snore;
|
using namespace Snore;
|
||||||
@ -174,5 +175,31 @@ QDataStream &operator<< ( QDataStream &stream, const Notification ¬i )
|
|||||||
return stream;
|
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
|
class SNORE_EXPORT Notification
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Q_OBJECT
|
||||||
|
*/
|
||||||
|
Q_GADGET
|
||||||
|
Q_PROPERTY(CloseReasons closeReason READ closeReason)
|
||||||
friend class NotificationData;
|
friend class NotificationData;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The reason why the Notification was closed.
|
* The reason why the Notification was closed.
|
||||||
*/
|
*/
|
||||||
@ -54,25 +58,26 @@ public:
|
|||||||
/**
|
/**
|
||||||
* The default value, the notification was not closed.
|
* The default value, the notification was not closed.
|
||||||
*/
|
*/
|
||||||
NONE = 0x0,
|
NONE = 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Notification was closed becaouse it timed out.
|
* The Notification was closed becaouse it timed out.
|
||||||
*/
|
*/
|
||||||
TIMED_OUT = 0x1,
|
TIMED_OUT = 1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Notification was dismissed by the user, close button.
|
* The Notification was dismissed by the user, close button.
|
||||||
*/
|
*/
|
||||||
DISMISSED = 0x2,
|
DISMISSED = 2,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Notification was closed after an action was invoked.
|
* The Notification was closed after an action was invoked.
|
||||||
* @see actionInvoked()
|
* @see actionInvoked()
|
||||||
*/
|
*/
|
||||||
CLOSED = 0x4
|
CLOSED = 3
|
||||||
};
|
};
|
||||||
Q_DECLARE_FLAGS(CloseReasons, CloseReason)
|
Q_DECLARE_FLAGS(CloseReasons, CloseReason)
|
||||||
|
Q_ENUMS(CloseReasons)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Priority for the Notification.
|
* 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 );
|
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 )
|
inline QDebug operator<< ( QDebug debug, const Snore::Notification ¬i )
|
||||||
{
|
{
|
||||||
if(noti.isValid())
|
if(noti.isValid())
|
||||||
|
@ -32,8 +32,10 @@
|
|||||||
|
|
||||||
namespace Snore{
|
namespace Snore{
|
||||||
|
|
||||||
|
|
||||||
class SNORE_EXPORT NotificationData : public QSharedData
|
class SNORE_EXPORT NotificationData : public QSharedData
|
||||||
{
|
{
|
||||||
|
|
||||||
friend class Notification;
|
friend class Notification;
|
||||||
public:
|
public:
|
||||||
NotificationData ( const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,
|
NotificationData ( const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,
|
||||||
@ -53,6 +55,7 @@ public:
|
|||||||
|
|
||||||
void setCloseReason(Notification::CloseReasons r);
|
void setCloseReason(Notification::CloseReasons r);
|
||||||
|
|
||||||
|
|
||||||
QTimer *timeoutTimer();
|
QTimer *timeoutTimer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -17,7 +17,7 @@ Q_EXPORT_PLUGIN2(libsnore_backend_snoretoast,SnoreToast)
|
|||||||
|
|
||||||
|
|
||||||
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"
|
arguements << "-w"
|
||||||
<< "-appID"
|
<< "-appID"
|
||||||
<< appId(notification.application());
|
<< appId(notification.application())
|
||||||
;
|
<< "-id"
|
||||||
|
<< QString::number(notification.id());
|
||||||
if(notification.hints().value("silent",true).toBool())
|
if(notification.hints().value("silent",true).toBool())
|
||||||
{
|
{
|
||||||
arguements << "-silent";
|
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)
|
void SnoreToast::slotToastNotificationClosed(int code, QProcess::ExitStatus)
|
||||||
{
|
{
|
||||||
QProcess *p = qobject_cast<QProcess*>(sender());
|
QProcess *p = qobject_cast<QProcess*>(sender());
|
||||||
|
@ -17,6 +17,7 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void slotNotify(Snore::Notification notification);
|
void slotNotify(Snore::Notification notification);
|
||||||
void slotRegisterApplication(const Snore::Application &application);
|
void slotRegisterApplication(const Snore::Application &application);
|
||||||
|
void slotCloseNotification ( Snore::Notification notification );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
void slotToastNotificationClosed(int code, QProcess::ExitStatus);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user