From 066037f1a53f35fa5036d065c42977c61bffbea7 Mon Sep 17 00:00:00 2001 From: Sebastian Wolf Date: Tue, 19 Jan 2021 21:48:28 +0100 Subject: [PATCH] Notifications: Avoid popup in current chat, play sound (again), fixes #233 --- src/notificationmanager.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index dbeb1bf..1c4550a 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -61,6 +61,7 @@ namespace { const QString HINT_TOTAL_COUNT("x-fernschreiber.total_count"); // int const QString HINT_VIBRA("x-nemo-vibrate"); // bool + const QString HINT_SUPPRESS_SOUND("suppress-sound"); // bool const QString HINT_DISPLAY_ON("x-nemo-display-on"); // bool const QString HINT_VISIBILITY("x-nemo-visibility"); // QString const QString VISIBILITY_PUBLIC("public"); @@ -207,8 +208,10 @@ void NotificationManager::updateNotificationGroup(int groupId, qlonglong chatId, } else { // New notification Notification *notification = new Notification(this); + notification->setCategory("x-nemo.messaging.im"); notification->setAppName(APP_NAME); notification->setAppIcon(appIconFile); + notification->setIcon(appIconFile); notification->setHintValue(HINT_GROUP_ID, groupId); notification->setHintValue(HINT_CHAT_ID, chatId); notification->setHintValue(HINT_TOTAL_COUNT, totalCount); @@ -358,17 +361,19 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat const QString summary(chatInformation ? chatInformation->title : QString()); nemoNotification->setBody(notificationBody); nemoNotification->setSummary(summary); - nemoNotification->setPreviewBody(notificationBody); - nemoNotification->setPreviewSummary(summary); nemoNotification->setHintValue(HINT_VIBRA, needFeedback); // Don't show popup for the currently open chat if (!needFeedback || (chatModel->getChatId() == notificationGroup->chatId && qGuiApp->applicationState() == Qt::ApplicationActive)) { + nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, true); nemoNotification->setHintValue(HINT_DISPLAY_ON, false); nemoNotification->setHintValue(HINT_VISIBILITY, QString()); nemoNotification->setUrgency(Notification::Low); } else { + nemoNotification->setPreviewBody(notificationBody); + nemoNotification->setPreviewSummary(summary); + nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, false); nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn()); nemoNotification->setHintValue(HINT_VISIBILITY, VISIBILITY_PUBLIC); nemoNotification->setUrgency(Notification::Normal);