29#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
30#include <QDBusInterface>
44 m_enabled = settings.
value(
QSL(
"Enabled"),
true).toBool();
45 m_timeout = settings.
value(
QSL(
"Timeout"), 6000).toInt();
46#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
51 m_position = settings.
value(
QSL(
"Position"), QPoint(10, 10)).toPoint();
57#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
75 switch (m_notifType) {
77 if (!m_desktopNotif) {
80 m_desktopNotif.data()->setPixmap(icon);
81 m_desktopNotif.data()->setHeading(heading);
82 m_desktopNotif.data()->setText(text);
83 m_desktopNotif.data()->setTimeout(m_timeout);
84 m_desktopNotif.data()->move(m_position);
85 m_desktopNotif.data()->show();
88#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
90 tmp.open(QFile::WriteOnly);
91 icon.save(tmp.fileName());
93 const QVariantMap hints {
94 {QStringLiteral(
"desktop-entry"), QGuiApplication::desktopFileName()}
97 QDBusInterface dbus(
QSL(
"org.freedesktop.Notifications"),
QSL(
"/org/freedesktop/Notifications"),
QSL(
"org.freedesktop.Notifications"), QDBusConnection::sessionBus());
99 args.append(QLatin1String(
"Falkon"));
101 args.append(tmp.fileName());
102 args.append(heading);
104 args.append(QStringList());
106 args.append(m_timeout);
107 dbus.callWithCallback(
QSL(
"Notify"), args,
this, SLOT(updateLastId(QDBusMessage)), SLOT(error(QDBusError)));
115 Type type = m_notifType;
118 const QPixmap icon =
mApp->getWindow()->windowIcon().pixmap(64);
119 showNotification(icon, QObject::tr(
"Native System Notification"), tr(
"Preview"));
123void DesktopNotificationsFactory::updateLastId(
const QDBusMessage &msg)
126#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
127 QVariantList list = msg.arguments();
128 if (list.count() > 0) {
129 m_uint = list.at(0).toInt();
134void DesktopNotificationsFactory::error(
const QDBusError &error)
137#if defined(Q_OS_UNIX) && !defined(DISABLE_DBUS)
138 qWarning() <<
"QDBusError:" << error.message();
static QString path(Path type)
void nativeNotificationPreview()
bool supportsNativeNotifications() const
DesktopNotificationsFactory(QObject *parent=nullptr)
void showNotification(const QString &heading, const QString &text)
void beginGroup(const QString &prefix)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant())