-void MainWin::sendDesktopNotification(const QString &title, const QString &message)
-{
- QStringList actions;
- QMap<QString, QVariant> hints;
- QDBusMessage msg = QDBusMessage::createMethodCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "", "Notify");
+void MainWin::sendDesktopNotification(const QString &title, const QString &message) {
+ QStringList actions;
+ QMap<QString, QVariant> hints;
+ UiSettings uiSettings;
+
+ hints["x"] = uiSettings.value("NotificationDesktopHintX", QVariant(0)).toInt(); // Standard hint: x location for the popup to show up
+ hints["y"] = uiSettings.value("NotificationDesktopHintY", QVariant(0)).toInt(); // Standard hint: y location for the popup to show up
+
+ actions << "click" << "Click Me!";
+
+ QDBusReply<uint> reply = desktopNotifications->Notify(
+ "Quassel", // Application name
+ notificationId, // ID of previous notification to replace
+ "", // Icon to display
+ title, // Summary / Header of the message to display
+ QString("%1: %2:\n%3").arg(QTime::currentTime().toString()).arg(title).arg(message), // Body of the message to display
+ actions, // Actions from which the user may choose
+ hints, // Hints to the server displaying the message
+ uiSettings.value("NotificationDesktopTimeout", QVariant(5000)).toInt() // Timeout in milliseconds
+ );
+
+ if(!reply.isValid()) {
+ /* ERROR */
+ qDebug() << "Error on sending notification..." << reply;
+ return;
+ }
+
+ notificationId = reply.value();