refactored notification
This commit is contained in:
parent
38242655f0
commit
a43234f115
|
@ -23,6 +23,7 @@ set ( SnoreNotify_SRCS ${SnoreNotify_SRCS}
|
||||||
|
|
||||||
set ( SnoreNotify_HDR ${SnoreNotify_HDR}
|
set ( SnoreNotify_HDR ${SnoreNotify_HDR}
|
||||||
snore.h
|
snore.h
|
||||||
|
snore_p.h
|
||||||
application.h
|
application.h
|
||||||
hint.h
|
hint.h
|
||||||
snore_exports.h
|
snore_exports.h
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
set ( SnoreNotify_SRCS ${SnoreNotify_SRCS}
|
set ( SnoreNotify_SRCS ${SnoreNotify_SRCS}
|
||||||
notification/notification.cpp
|
notification/notification.cpp
|
||||||
|
notification/notification_p.cpp
|
||||||
notification/icon.cpp
|
notification/icon.cpp
|
||||||
PARENT_SCOPE)
|
PARENT_SCOPE)
|
||||||
|
|
||||||
set ( Notification_HDR
|
set ( Notification_HDR
|
||||||
notification.h
|
notification.h
|
||||||
|
notification_p.h
|
||||||
icon.h
|
icon.h
|
||||||
notificationenums.h
|
notificationenums.h
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,10 +29,6 @@ using namespace Snore;
|
||||||
|
|
||||||
int Notification::DefaultTimeout = 10;
|
int Notification::DefaultTimeout = 10;
|
||||||
|
|
||||||
uint NotificationData::notificationCount = 0;
|
|
||||||
|
|
||||||
uint NotificationData::m_idCount = 1;
|
|
||||||
|
|
||||||
int NotificationData::notificationMetaID = qRegisterMetaType<Notification>();
|
int NotificationData::notificationMetaID = qRegisterMetaType<Notification>();
|
||||||
|
|
||||||
Notification::Notification () :
|
Notification::Notification () :
|
||||||
|
@ -90,16 +86,6 @@ const Notification::Action *Notification::actionInvoked() const
|
||||||
return d->m_actionInvoked;
|
return d->m_actionInvoked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::setActionInvoked ( Action *action )
|
|
||||||
{
|
|
||||||
d->m_actionInvoked = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notification::setActionInvoked ( const int &id)
|
|
||||||
{
|
|
||||||
d->m_actionInvoked = d->m_actions[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
void Notification::setSource(SnoreFrontend *source){
|
void Notification::setSource(SnoreFrontend *source){
|
||||||
d->m_source = source;
|
d->m_source = source;
|
||||||
}
|
}
|
||||||
|
@ -179,6 +165,11 @@ bool Notification::isValid() const
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NotificationData *Notification::data()
|
||||||
|
{
|
||||||
|
return d.data();
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream &operator<< ( QDataStream &stream, const Notification ¬i )
|
QDataStream &operator<< ( QDataStream &stream, const Notification ¬i )
|
||||||
{
|
{
|
||||||
stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ;
|
stream << "Title: " << noti.title() << " Text: " << noti.text() << " ID: " << noti.id() ;
|
||||||
|
|
|
@ -84,9 +84,7 @@ public:
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
//protected://TODO::make only accesable from a backend
|
NotificationData *data();
|
||||||
void setActionInvoked ( Action *action );
|
|
||||||
void setActionInvoked ( const int &actionID);
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "notification/notification_p.h"
|
||||||
|
#include "notification/icon.h"
|
||||||
|
#include "../hint.h"
|
||||||
|
|
||||||
|
#include <QSharedData>
|
||||||
|
|
||||||
|
using namespace Snore;
|
||||||
|
|
||||||
|
uint NotificationData::notificationCount = 0;
|
||||||
|
|
||||||
|
uint NotificationData::m_idCount = 1;
|
||||||
|
|
||||||
|
NotificationData::NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const Icon &icon,
|
||||||
|
int timeout,NotificationEnums::Prioritys::prioritys priority ):
|
||||||
|
m_id ( m_idCount++ ),
|
||||||
|
m_updateID(0),
|
||||||
|
m_timeout ( timeout ),
|
||||||
|
m_source ( NULL),
|
||||||
|
m_application ( application ),
|
||||||
|
m_alert ( alert ),
|
||||||
|
m_title ( title ),
|
||||||
|
m_text ( text ),
|
||||||
|
m_icon ( icon ),
|
||||||
|
m_priority(priority),
|
||||||
|
m_closeReason(NotificationEnums::CloseReasons::NONE),
|
||||||
|
m_actionInvoked( NULL )
|
||||||
|
{
|
||||||
|
notificationCount++;
|
||||||
|
qDebug()<< "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotificationData::~NotificationData()
|
||||||
|
{
|
||||||
|
notificationCount--;
|
||||||
|
qDebug() << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NotificationData::setActionInvoked ( Notification::Action *action )
|
||||||
|
{
|
||||||
|
m_actionInvoked = action;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotificationData::setActionInvoked ( const int &id)
|
||||||
|
{
|
||||||
|
m_actionInvoked = m_actions[id];
|
||||||
|
}
|
|
@ -1,43 +1,45 @@
|
||||||
|
/*
|
||||||
|
SnoreNotify is a Notification Framework based on Qt
|
||||||
|
Copyright (C) 2013-2014 Patrick von Reth <vonreth@kde.org>
|
||||||
|
|
||||||
|
|
||||||
|
SnoreNotify is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
SnoreNotify is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public License
|
||||||
|
along with SnoreNotify. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef NOTIFICATIONDATA_H
|
#ifndef NOTIFICATIONDATA_H
|
||||||
#define NOTIFICATIONDATA_H
|
#define NOTIFICATIONDATA_H
|
||||||
|
|
||||||
|
|
||||||
#include "notification/icon.h"
|
#include "icon.h"
|
||||||
#include "notification/notificationenums.h"
|
#include "notification.h"
|
||||||
|
#include "notificationenums.h"
|
||||||
#include "../hint.h"
|
#include "../hint.h"
|
||||||
|
|
||||||
#include <QSharedData>
|
#include <QSharedData>
|
||||||
|
|
||||||
namespace Snore{
|
namespace Snore{
|
||||||
|
|
||||||
class NotificationData : public QSharedData
|
class SNORE_EXPORT NotificationData : public QSharedData
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const Icon &icon,
|
NotificationData ( const QString &application,const QString &alert,const QString &title,const QString &text,const Icon &icon,
|
||||||
int timeout,NotificationEnums::Prioritys::prioritys priority ):
|
int timeout,NotificationEnums::Prioritys::prioritys priority );
|
||||||
m_id ( m_idCount++ ),
|
|
||||||
m_updateID(0),
|
|
||||||
m_timeout ( timeout ),
|
|
||||||
m_source ( NULL),
|
|
||||||
m_application ( application ),
|
|
||||||
m_alert ( alert ),
|
|
||||||
m_title ( title ),
|
|
||||||
m_text ( text ),
|
|
||||||
m_icon ( icon ),
|
|
||||||
m_priority(priority),
|
|
||||||
m_closeReason(NotificationEnums::CloseReasons::NONE),
|
|
||||||
m_actionInvoked( NULL )
|
|
||||||
{
|
|
||||||
notificationCount++;
|
|
||||||
qDebug()<< "Creating Notification: ActiveNotifications" << notificationCount << "id" << m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
~NotificationData()
|
~NotificationData();
|
||||||
{
|
void setActionInvoked ( Notification::Action *action );
|
||||||
notificationCount--;
|
void setActionInvoked ( const int &actionID);
|
||||||
qDebug() << "Deleting Notification: ActiveNotifications" << notificationCount << "id" << m_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint m_id;
|
uint m_id;
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "core/snore_p.h"
|
#include "core/snore_p.h"
|
||||||
#include "core/plugins/plugins.h"
|
#include "core/plugins/plugins.h"
|
||||||
#include "core/plugins/snorebackend.h"
|
#include "core/plugins/snorebackend.h"
|
||||||
|
#include "core/notification/notification_p.h"
|
||||||
|
|
||||||
#include <QtCore>
|
#include <QtCore>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
@ -88,7 +89,7 @@ public:
|
||||||
reason = NotificationEnums::CloseReasons::CLOSED;
|
reason = NotificationEnums::CloseReasons::CLOSED;
|
||||||
if(notification.isValid())
|
if(notification.isValid())
|
||||||
{
|
{
|
||||||
notification.setActionInvoked(data);
|
notification.data()->setActionInvoked(data);
|
||||||
m_snarl->snore()->d()->notificationActionInvoked(notification);
|
m_snarl->snore()->d()->notificationActionInvoked(notification);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue