1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

DBusNotifications: Use non-blocking DBuS calls

This commit is contained in:
nowrep 2013-07-25 11:37:54 +02:00
parent 51a262bc8d
commit 621ab56951
2 changed files with 22 additions and 8 deletions

View File

@ -22,6 +22,7 @@
#include <QFile>
#include <QDir>
#include <QDebug>
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS)
#include <QDBusInterface>
@ -92,11 +93,7 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
args.append(QStringList());
args.append(QVariantMap());
args.append(m_timeout);
QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args);
QVariantList list = message.arguments();
if (list.count() > 0) {
m_uint = list.at(0).toInt();
}
dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
#endif
break;
}
@ -119,10 +116,19 @@ void DesktopNotificationsFactory::nativeNotificationPreview()
args.append(QStringList());
args.append(QVariantMap());
args.append(m_timeout);
QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args);
QVariantList list = message.arguments();
dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
#endif
}
void DesktopNotificationsFactory::updateLastId(const QDBusMessage &msg)
{
QVariantList list = msg.arguments();
if (list.count() > 0) {
m_uint = list.at(0).toInt();
}
#endif
}
void DesktopNotificationsFactory::error(const QDBusError &error)
{
qWarning() << "QDBusError:" << error.message();
}

View File

@ -25,11 +25,15 @@
#include <QPointer>
class QPixmap;
class QDBusMessage;
class QDBusError;
class DesktopNotification;
class QT_QUPZILLA_EXPORT DesktopNotificationsFactory : public QObject
{
Q_OBJECT
public:
enum Type { DesktopNative, PopupWidget };
@ -42,6 +46,10 @@ public:
void showNotification(const QPixmap &icon, const QString &heading, const QString &text);
void nativeNotificationPreview();
private slots:
void updateLastId(const QDBusMessage &msg);
void error(const QDBusError &error);
private:
bool m_enabled;
int m_timeout;