diff --git a/src/core/notification/CMakeLists.txt b/src/core/notification/CMakeLists.txt index f73dddd..7e41f32 100644 --- a/src/core/notification/CMakeLists.txt +++ b/src/core/notification/CMakeLists.txt @@ -1,6 +1,7 @@ set ( SnoreNotify_SRCS ${SnoreNotify_SRCS} notification/notification.cpp notification/notification_p.cpp + notification/notificationaction.cpp notification/icon.cpp notification/icon_p.cpp PARENT_SCOPE) @@ -8,6 +9,7 @@ set ( SnoreNotify_SRCS ${SnoreNotify_SRCS} set ( Notification_HDR notification.h notification_p.h + notificationaction.h icon.h notificationenums.h ) diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index b82d989..6509042 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -31,40 +31,6 @@ int Notification::m_defaultTimeout = 10; int NotificationData::notificationMetaID = qRegisterMetaType(); -Notification::Action::Action(): - m_id(-1) -{ - -} - -Notification::Action::Action(int id, QString name): - m_id(id), - m_name(name) -{ - -} - -Notification::Action::Action(const Notification::Action &other): - m_id(other.id()), - m_name(other.name()) -{ - -} - -QString Notification::Action::name() const -{ - return m_name; -} - -bool Notification::Action::isValid() const -{ - return m_name.isNull(); -} - -int Notification::Action::id() const -{ - return m_id; -} Notification::Notification () : d(NULL) @@ -117,7 +83,7 @@ const uint &Notification::updateID() const return d->m_updateID; } -const Notification::Action &Notification::actionInvoked() const +const Action &Notification::actionInvoked() const { return d->m_actionInvoked; } @@ -157,13 +123,13 @@ const NotificationEnums::Prioritys::prioritys &Notification::priority() const return d->m_priority; } -void Notification::addAction(const Notification::Action &a) +void Notification::addAction(const Action &a) { d->m_actions.insert(a.id(),a); } -const QHash &Notification::actions() const +const QHash &Notification::actions() const { return d->m_actions; } @@ -208,9 +174,4 @@ QDataStream &operator<< ( QDataStream &stream, const Notification ¬i ) } -QDataStream &operator<< ( QDataStream &stream, const Notification::Action &a) -{ - stream << a.id() << a.name(); - return stream; -} diff --git a/src/core/notification/notification.h b/src/core/notification/notification.h index d08df65..1fb9b4f 100644 --- a/src/core/notification/notification.h +++ b/src/core/notification/notification.h @@ -22,6 +22,7 @@ #include "../snore_exports.h" #include "icon.h" #include "notificationenums.h" +#include "notificationaction.h" #include "../hint.h" #include "../application.h" @@ -37,24 +38,6 @@ class NotificationData; class SNORE_EXPORT Notification { friend class NotificationData; -public: - class SNORE_EXPORT Action - { - public: - Action(); - Action(int id,QString name); - Action(const Action &other); - - int id() const; - QString name() const; - bool isValid() const; - - private: - int m_id; - QString m_name; - }; - - public: Notification(); explicit Notification(const Application &application,const Alert &alert,const QString &title,const QString &text,const Icon &icon,int timeout=10, NotificationEnums::Prioritys::prioritys priority = NotificationEnums::Prioritys::NORMAL ); @@ -121,5 +104,5 @@ inline QDebug operator<< ( QDebug debug, const Snore::Notification ¬i ) return debug.maybeSpace(); } -QDataStream &operator<< ( QDataStream & stream, const Snore::Notification::Action & action); + #endif // NOTIFICATION_H diff --git a/src/core/notification/notification_p.cpp b/src/core/notification/notification_p.cpp index d1133e5..855d267 100644 --- a/src/core/notification/notification_p.cpp +++ b/src/core/notification/notification_p.cpp @@ -56,7 +56,7 @@ NotificationData::~NotificationData() } -void NotificationData::setActionInvoked (const Snore::Notification::Action &action ) +void NotificationData::setActionInvoked (const Snore::Action &action ) { m_actionInvoked = action; } diff --git a/src/core/notification/notification_p.h b/src/core/notification/notification_p.h index 7829e99..5505bc5 100644 --- a/src/core/notification/notification_p.h +++ b/src/core/notification/notification_p.h @@ -42,7 +42,7 @@ public: void setSource(class SnoreFrontend *source); class SnoreFrontend *source() const; - void setActionInvoked( const Notification::Action &action ); + void setActionInvoked( const Action &action ); void setActionInvoked( const int &actionID); @@ -62,8 +62,8 @@ private: Icon m_icon; NotificationEnums::Prioritys::prioritys m_priority; NotificationEnums::CloseReasons::closeReasons m_closeReason; - Notification::Action m_actionInvoked; - QHash m_actions; + Action m_actionInvoked; + QHash m_actions; Hint m_hints; diff --git a/src/core/notification/notificationaction.cpp b/src/core/notification/notificationaction.cpp new file mode 100644 index 0000000..868e1ef --- /dev/null +++ b/src/core/notification/notificationaction.cpp @@ -0,0 +1,56 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2014 Patrick von Reth + + + 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 . +*/ + +#include "notificationaction.h" + +using namespace Snore; + +Action::Action(): + m_id(-1) +{ + +} + +Action::Action(int id, QString name): + m_id(id), + m_name(name) +{ + +} + +QString Action::name() const +{ + return m_name; +} + +bool Action::isValid() const +{ + return m_name.isNull(); +} + +int Action::id() const +{ + return m_id; +} + +QDataStream &operator<< ( QDataStream &stream, const Action &a) +{ + stream << a.id() << a.name(); + return stream; +} diff --git a/src/core/notification/notificationaction.h b/src/core/notification/notificationaction.h new file mode 100644 index 0000000..407fa84 --- /dev/null +++ b/src/core/notification/notificationaction.h @@ -0,0 +1,48 @@ +/* + SnoreNotify is a Notification Framework based on Qt + Copyright (C) 2014 Patrick von Reth + + + 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 . +*/ + +#ifndef NOTIFICATIONACTION_H +#define NOTIFICATIONACTION_H + +#include "../snore_exports.h" + +#include + + +namespace Snore +{ + +class SNORE_EXPORT Action +{ +public: + Action(); + Action(int id,QString name); + + int id() const; + QString name() const; + bool isValid() const; + +private: + int m_id; + QString m_name; +}; +} + +QDataStream &operator<< ( QDataStream & stream, const Snore::Action &action); +#endif // NOTIFICATIONACTION_H diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index 6160938..fc37d0e 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -220,7 +220,8 @@ void SnarlBackend::slotNotify(Notification notification){ break; } - if(notification.updateID() == 0){ + if(notification.updateID() == 0) + { ULONG32 id = snarlInterface->Notify(notification.alert().name().toUtf8().constData(), Snore::toPlainText(notification.title()).toUtf8().constData(), Snore::toPlainText(notification.text()).toUtf8().constData(), @@ -229,7 +230,7 @@ void SnarlBackend::slotNotify(Notification notification){ !notification.icon().isLocalFile()?notification.icon().imageData().toBase64().constData():0, priority); - foreach(const Notification::Action &a, notification.actions()) + foreach(const Action &a, notification.actions()) { snarlInterface->AddAction(id,a.name().toUtf8().constData(),QString("@").append(QString::number(a.id())).toUtf8().constData()); } diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp index c9ee742..73f6a1d 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp @@ -115,7 +115,7 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id, noti.data()->setSource(this); for(int i = 0;i < actions.length(); i+=2) { - noti.addAction(Notification::Action(actions.at(i).toInt(),actions.at(i+1))); + noti.addAction(Action(actions.at(i).toInt(),actions.at(i+1))); } snore()->broadcastNotification(noti); diff --git a/src/trayicon.cpp b/src/trayicon.cpp index 59c9c30..b685a1d 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -88,7 +88,7 @@ void TrayIcon::slotTestNotification() const Application &app = m_snore->d()->defaultApplication(); m_snore->registerApplication(app); Notification n(app, *app.alerts().begin(), "Hello World", "This is Snore", Icon(":/root/snore.png")); - n.addAction(Notification::Action(1,"Test Action")); + n.addAction(Action(1,"Test Action")); m_snore->broadcastNotification(n); m_snore->deregisterApplication(app); }