Reuse the same notification
This commit is contained in:
parent
d701e8e5ac
commit
6acb908c10
10
src/osd.h
10
src/osd.h
|
@ -7,6 +7,12 @@
|
|||
#include "engine_fwd.h"
|
||||
#include "song.h"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
# ifndef _NOTIFY_NOTIFICATION_H_
|
||||
struct NotifyNotification;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
class OSD : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -25,6 +31,10 @@ class OSD : public QObject {
|
|||
|
||||
private:
|
||||
QSystemTrayIcon* tray_icon_;
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
NotifyNotification* notification_;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // OSD_H
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QtDebug>
|
||||
|
||||
void OSD::Init() {
|
||||
notification_ = NULL;
|
||||
notify_init("Tangerine");
|
||||
}
|
||||
|
||||
|
@ -16,20 +17,23 @@ void OSD::ShowMessage(const QString& summary, const QString& message,
|
|||
if (summary.isNull())
|
||||
return;
|
||||
|
||||
NotifyNotification* notification = notify_notification_new(
|
||||
summary.toUtf8().constData(),
|
||||
message.isNull() ? NULL : message.toUtf8().constData(),
|
||||
icon.isNull() ? NULL : icon.toUtf8().constData(), NULL);
|
||||
#define STR(x) (x.isNull() ? NULL : x.toUtf8().constData())
|
||||
|
||||
notify_notification_set_urgency(notification, NOTIFY_URGENCY_LOW);
|
||||
notify_notification_set_timeout(notification, 5000);
|
||||
if (notification_) {
|
||||
notify_notification_update(notification_,
|
||||
STR(summary), STR(message), STR(icon));
|
||||
} else {
|
||||
notification_ = notify_notification_new(
|
||||
STR(summary), STR(message), STR(icon), NULL);
|
||||
}
|
||||
|
||||
notify_notification_set_urgency(notification_, NOTIFY_URGENCY_LOW);
|
||||
notify_notification_set_timeout(notification_, 5000);
|
||||
|
||||
GError* error = NULL;
|
||||
notify_notification_show(notification, &error);
|
||||
notify_notification_show(notification_, &error);
|
||||
if (error) {
|
||||
qDebug() << "Error from notify_notification_show:" << error->message;
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
g_object_unref(G_OBJECT(notification));
|
||||
}
|
||||
|
|
|
@ -250,7 +250,7 @@ QString Song::PrettyTitleWithArtist() const {
|
|||
if (title.isEmpty())
|
||||
title = QFileInfo(filename_).baseName();
|
||||
|
||||
if (compilation_ && !artist_.isEmpty())
|
||||
if (!compilation_ && !artist_.isEmpty())
|
||||
title = artist_ + " - " + title;
|
||||
|
||||
return title;
|
||||
|
|
Loading…
Reference in New Issue