This commit is contained in:
Patrick von Reth 2014-01-19 18:03:05 +01:00
parent 9000ab5ad0
commit a3b2805d7b
7 changed files with 27 additions and 19 deletions

View File

@ -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();
}

View File

@ -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),

View File

@ -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;
}

View File

@ -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<int, Action> &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();

View File

@ -70,7 +70,7 @@ const QString &SnorePlugin::name() const
void SnorePlugin::startTimeout(Notification &notification)
{
if(notification.sticky())
if(notification.isSticky())
{
return;
}
@ -78,7 +78,7 @@ void SnorePlugin::startTimeout(Notification &notification)
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()));

View File

@ -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(),

View File

@ -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<QDBusArgument>()>>image;
hints["image_data"].value<QDBusArgument>() >> image;
icon = Icon(image.toQImage());
}
else