From a3b2805d7b91ebe71dae6866df79e534aca26d47 Mon Sep 17 00:00:00 2001 From: Patrick von Reth Date: Sun, 19 Jan 2014 18:03:05 +0100 Subject: [PATCH] fixes --- src/core/notification/icon.cpp | 2 +- src/core/notification/icon_p.cpp | 3 ++- src/core/notification/notification.cpp | 15 +++++++++------ src/core/notification/notification.h | 13 +++++++------ src/core/plugins/plugins.cpp | 4 ++-- src/plugins/backends/snarl/snarl.cpp | 4 +++- .../freedesktopnotificationfrontend.cpp | 5 +++-- 7 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/core/notification/icon.cpp b/src/core/notification/icon.cpp index d6f10dd..78a583e 100644 --- a/src/core/notification/icon.cpp +++ b/src/core/notification/icon.cpp @@ -92,6 +92,6 @@ bool Snore::Icon::isRemoteFile() const QDebug operator<< ( QDebug debug, const Snore::Icon &icon ) { - debug << "Snore::Icon(" << icon.url() << ")" ; + debug << "Snore::Icon(" << (icon.url().isEmpty()?icon.localUrl():icon.url()) << ")" ; return debug.maybeSpace(); } diff --git a/src/core/notification/icon_p.cpp b/src/core/notification/icon_p.cpp index 77345a7..18c0cf4 100644 --- a/src/core/notification/icon_p.cpp +++ b/src/core/notification/icon_p.cpp @@ -44,7 +44,8 @@ IconData::IconData(const QString &url): IconData::IconData(const QImage &img): m_img(img), - m_hash(SnoreCorePrivate::computeHash(dataFromImage(img))), + m_data(dataFromImage(img)), + m_hash(SnoreCorePrivate::computeHash(m_data)), m_localUrl(QString("%1%2.png").arg(SnoreCorePrivate::snoreTMP(), m_hash)), m_isLocalFile(false), m_isResource(false), diff --git a/src/core/notification/notification.cpp b/src/core/notification/notification.cpp index d057905..247a39a 100644 --- a/src/core/notification/notification.cpp +++ b/src/core/notification/notification.cpp @@ -44,7 +44,7 @@ Notification::Notification(const Application &application, const Alert &alert, c } Notification::Notification(const Notification &old, const QString &title, const QString &text, const Icon &icon, int timeout, NotificationEnums::Prioritys::prioritys priority): - d(new NotificationData(old,title,text,icon,timeout,priority)) + d(new NotificationData(old,title,text,icon,timeout,priority)) { } @@ -78,7 +78,7 @@ const int &Notification::timeout() const return d->m_timeout; } -Notification Notification::notificationToReplace() const +Notification Notification::old() const { return d->m_toReplace; } @@ -113,17 +113,20 @@ const Alert &Notification::alert() const return d->m_alert; } -bool Notification::sticky() const +bool Notification::isSticky() const { return d->m_timeout == 0; } -void Notification::setSticky() +void Notification::setIsSticky(bool b) { - d->m_timeout = 0; + if(b) + { + d->m_timeout = 0; + } } -const NotificationEnums::Prioritys::prioritys &Notification::priority() const +NotificationEnums::Prioritys::prioritys Notification::priority() const { return d->m_priority; } diff --git a/src/core/notification/notification.h b/src/core/notification/notification.h index 9035c82..0f4ccff 100644 --- a/src/core/notification/notification.h +++ b/src/core/notification/notification.h @@ -52,18 +52,15 @@ public: //0 means sticky const int &timeout() const; - Notification notificationToReplace() const; - bool isUpdate() const; - const Action &actionInvoked() const; const Application &application() const; QString title() const; QString text() const; const Icon &icon() const; const Alert &alert() const; - void setSticky(); - bool sticky() const; - const NotificationEnums::Prioritys::prioritys &priority() const; + void setIsSticky(bool b); + bool isSticky() const; + NotificationEnums::Prioritys::prioritys priority() const; const QHash &actions() const; void addAction(const Action &a); const NotificationEnums::CloseReasons::closeReasons &closeReason(); @@ -73,6 +70,10 @@ public: bool isValid() const; + + Notification old() const; + bool isUpdate() const; + NotificationData *data(); diff --git a/src/core/plugins/plugins.cpp b/src/core/plugins/plugins.cpp index 9cd2af2..edc2ea3 100644 --- a/src/core/plugins/plugins.cpp +++ b/src/core/plugins/plugins.cpp @@ -70,7 +70,7 @@ const QString &SnorePlugin::name() const void SnorePlugin::startTimeout(Notification ¬ification) { - if(notification.sticky()) + if(notification.isSticky()) { return; } @@ -78,7 +78,7 @@ void SnorePlugin::startTimeout(Notification ¬ification) timer->stop(); if(notification.isUpdate()) { - notification.notificationToReplace().data()->timeoutTimer()->stop(); + notification.old().data()->timeoutTimer()->stop(); } timer->setInterval(notification.timeout() * 1000); connect(timer,SIGNAL(timeout()),this,SLOT(notificationTimedOut())); diff --git a/src/plugins/backends/snarl/snarl.cpp b/src/plugins/backends/snarl/snarl.cpp index cc4f4aa..d3c1c64 100644 --- a/src/plugins/backends/snarl/snarl.cpp +++ b/src/plugins/backends/snarl/snarl.cpp @@ -104,6 +104,7 @@ public: if(notification.isValid()) { m_snarl->closeNotification(notification,reason); + m_snarl->m_idMap.take(msg->lParam); } else { @@ -220,6 +221,7 @@ void SnarlBackend::slotNotify(Notification notification){ } ULONG32 id = 0; + qDebug() << Q_FUNC_INFO << notification.icon(); if(!notification.isUpdate()) { id = snarlInterface->Notify(notification.alert().name().toUtf8().constData(), @@ -240,7 +242,7 @@ void SnarlBackend::slotNotify(Notification notification){ else { //update message - id = notification.notificationToReplace().hints().privateValue(this, "id").toUInt(); + id = notification.old().hints().privateValue(this, "id").toUInt(); snarlInterface->Update(id, notification.alert().name().toUtf8().constData(), Snore::toPlainText(notification.title()).toUtf8().constData(), diff --git a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp index 4d7fbf3..5d26f1c 100644 --- a/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp +++ b/src/plugins/frontends/freedesktop/freedesktopnotificationfrontend.cpp @@ -95,9 +95,10 @@ uint FreedesktopFrontend::Notify(const QString &app_name, uint replaces_id, Application app; NotificationEnums::Prioritys::prioritys priotity = NotificationEnums::Prioritys::NORMAL; - if(hints.contains("image_data")){ + if(hints.contains("image_data")) + { FreedesktopImageHint image; - hints["image_data"].value()>>image; + hints["image_data"].value() >> image; icon = Icon(image.toQImage()); } else