mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +01:00
DBusNotifications: Use non-blocking DBuS calls
This commit is contained in:
parent
51a262bc8d
commit
621ab56951
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS)
|
#if defined(QZ_WS_X11) && !defined(DISABLE_DBUS)
|
||||||
#include <QDBusInterface>
|
#include <QDBusInterface>
|
||||||
|
@ -92,11 +93,7 @@ void DesktopNotificationsFactory::showNotification(const QPixmap &icon, const QS
|
||||||
args.append(QStringList());
|
args.append(QStringList());
|
||||||
args.append(QVariantMap());
|
args.append(QVariantMap());
|
||||||
args.append(m_timeout);
|
args.append(m_timeout);
|
||||||
QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args);
|
dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
|
||||||
QVariantList list = message.arguments();
|
|
||||||
if (list.count() > 0) {
|
|
||||||
m_uint = list.at(0).toInt();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -119,10 +116,19 @@ void DesktopNotificationsFactory::nativeNotificationPreview()
|
||||||
args.append(QStringList());
|
args.append(QStringList());
|
||||||
args.append(QVariantMap());
|
args.append(QVariantMap());
|
||||||
args.append(m_timeout);
|
args.append(m_timeout);
|
||||||
QDBusMessage message = dbus.callWithArgumentList(QDBus::Block, "Notify", args);
|
dbus.callWithCallback("Notify", args, this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
|
||||||
QVariantList list = message.arguments();
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void DesktopNotificationsFactory::updateLastId(const QDBusMessage &msg)
|
||||||
|
{
|
||||||
|
QVariantList list = msg.arguments();
|
||||||
if (list.count() > 0) {
|
if (list.count() > 0) {
|
||||||
m_uint = list.at(0).toInt();
|
m_uint = list.at(0).toInt();
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
void DesktopNotificationsFactory::error(const QDBusError &error)
|
||||||
|
{
|
||||||
|
qWarning() << "QDBusError:" << error.message();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,15 @@
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
|
class QDBusMessage;
|
||||||
|
class QDBusError;
|
||||||
|
|
||||||
class DesktopNotification;
|
class DesktopNotification;
|
||||||
|
|
||||||
class QT_QUPZILLA_EXPORT DesktopNotificationsFactory : public QObject
|
class QT_QUPZILLA_EXPORT DesktopNotificationsFactory : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type { DesktopNative, PopupWidget };
|
enum Type { DesktopNative, PopupWidget };
|
||||||
|
|
||||||
|
@ -42,6 +46,10 @@ public:
|
||||||
void showNotification(const QPixmap &icon, const QString &heading, const QString &text);
|
void showNotification(const QPixmap &icon, const QString &heading, const QString &text);
|
||||||
void nativeNotificationPreview();
|
void nativeNotificationPreview();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateLastId(const QDBusMessage &msg);
|
||||||
|
void error(const QDBusError &error);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_enabled;
|
bool m_enabled;
|
||||||
int m_timeout;
|
int m_timeout;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user