Reuse the same native notification popup on Linux. Fixes issue #118
This commit is contained in:
parent
48632b5fc0
commit
d68c61ff25
12
src/osd.h
12
src/osd.h
@ -29,13 +29,12 @@ class OSDPretty;
|
||||
class QDBusPendingCallWatcher;
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
#include <QDBusArgument>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include "notification.h"
|
||||
|
||||
QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image);
|
||||
const QDBusArgument& operator>> (const QDBusArgument& arg, QImage& image);
|
||||
# include <QDBusArgument>
|
||||
# include <boost/scoped_ptr.hpp>
|
||||
# include "notification.h"
|
||||
|
||||
QDBusArgument& operator<< (QDBusArgument& arg, const QImage& image);
|
||||
const QDBusArgument& operator>> (const QDBusArgument& arg, QImage& image);
|
||||
#endif
|
||||
|
||||
class OSD : public QObject {
|
||||
@ -97,6 +96,7 @@ class OSD : public QObject {
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
boost::scoped_ptr<org::freedesktop::Notifications> interface_;
|
||||
uint notification_id_;
|
||||
#endif
|
||||
private slots:
|
||||
void CallFinished(QDBusPendingCallWatcher* watcher);
|
||||
|
@ -59,6 +59,8 @@ void OSD::Init() {
|
||||
if (!interface_->isValid()) {
|
||||
qWarning() << "Error connecting to notifications service.";
|
||||
}
|
||||
|
||||
notification_id_ = 0;
|
||||
}
|
||||
|
||||
bool OSD::SupportsNativeNotifications() {
|
||||
@ -73,7 +75,7 @@ void OSD::ShowMessageNative(const QString& summary, const QString& message,
|
||||
const QString& icon) {
|
||||
QDBusPendingReply<uint> reply = interface_->Notify(
|
||||
QCoreApplication::applicationName(),
|
||||
0,
|
||||
notification_id_,
|
||||
icon,
|
||||
summary,
|
||||
message,
|
||||
@ -93,7 +95,7 @@ void OSD::ShowMessageNative(const QString& summary, const QString& message,
|
||||
}
|
||||
QDBusPendingReply<uint> reply = interface_->Notify(
|
||||
QCoreApplication::applicationName(),
|
||||
0,
|
||||
notification_id_,
|
||||
QString(),
|
||||
summary,
|
||||
message,
|
||||
@ -111,5 +113,11 @@ void OSD::CallFinished(QDBusPendingCallWatcher* watcher) {
|
||||
QDBusPendingReply<uint> reply = *watcher;
|
||||
if (reply.isError()) {
|
||||
qWarning() << "Error sending notification" << reply.error();
|
||||
return;
|
||||
}
|
||||
|
||||
uint id = reply.value();
|
||||
if (id != 0) {
|
||||
notification_id_ = id;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user