diff --git a/qml/components/settingsPage/SettingsBehavior.qml b/qml/components/settingsPage/SettingsBehavior.qml index 8ec3aec..17746f7 100644 --- a/qml/components/settingsPage/SettingsBehavior.qml +++ b/qml/components/settingsPage/SettingsBehavior.qml @@ -147,6 +147,20 @@ AccordionItem { } } + TextSwitch { + width: parent.columnWidth + checked: appSettings.notificationSuppressContent && enabled + text: qsTr("Hide content in Notifications") + enabled: appSettings.notificationFeedback !== AppSettings.NotificationFeedbackNone + clip: height < implicitHeight + visible: height > 0 + automaticCheck: false + onClicked: { + appSettings.notificationSuppressContent = !checked + } + Behavior on height { SmoothedAnimation { duration: 200 } } + } + TextSwitch { width: parent.columnWidth checked: appSettings.notificationTurnsDisplayOn && enabled diff --git a/src/appsettings.cpp b/src/appsettings.cpp index d749f93..146d296 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -29,6 +29,7 @@ namespace { const QString KEY_ANIMATE_STICKERS("animateStickers"); const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn"); const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled"); + const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer"); const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess"); @@ -156,6 +157,20 @@ void AppSettings::setNotificationSoundsEnabled(bool enable) } } +bool AppSettings::notificationSuppressContent() const +{ + return settings.value(KEY_NOTIFICATION_SUPPRESS_ENABLED, false).toBool(); +} + +void AppSettings::setNotificationSuppressContent(bool enable) +{ + if (notificationSuppressContent() != enable) { + LOG(KEY_NOTIFICATION_SUPPRESS_ENABLED << enable); + settings.setValue(KEY_NOTIFICATION_SUPPRESS_ENABLED, enable); + emit notificationSuppressContentChanged(); + } +} + AppSettings::NotificationFeedback AppSettings::notificationFeedback() const { return (NotificationFeedback) settings.value(KEY_NOTIFICATION_FEEDBACK, (int) NotificationFeedbackAll).toInt(); diff --git a/src/appsettings.h b/src/appsettings.h index 8071b44..7ddc7ca 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -32,6 +32,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged) Q_PROPERTY(bool notificationSoundsEnabled READ notificationSoundsEnabled WRITE setNotificationSoundsEnabled NOTIFY notificationSoundsEnabledChanged) + Q_PROPERTY(bool notificationSuppressContent READ notificationSuppressContent WRITE setNotificationSuppressContent NOTIFY notificationSuppressContentChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged) Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged) @@ -84,6 +85,9 @@ public: bool notificationSoundsEnabled() const; void setNotificationSoundsEnabled(bool enable); + bool notificationSuppressContent() const; + void setNotificationSuppressContent(bool enable); + NotificationFeedback notificationFeedback() const; void setNotificationFeedback(NotificationFeedback feedback); @@ -120,6 +124,7 @@ signals: void animateStickersChanged(); void notificationTurnsDisplayOnChanged(); void notificationSoundsEnabledChanged(); + void notificationSuppressContentChanged(); void notificationFeedbackChanged(); void storageOptimizerChanged(); void allowInlineBotLocationAccessChanged(); diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index f45f743..2bd4bd8 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -377,7 +377,11 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat nemoNotification->setHintValue(HINT_VISIBILITY, QString()); nemoNotification->setUrgency(Notification::Low); } else { - nemoNotification->setPreviewBody(notificationBody); + if (!appSettings->notificationSuppressContent()) { + nemoNotification->setPreviewBody(notificationBody); + } else { + nemoNotification->setPreviewBody(tr("%Ln unread messages", "", notificationGroup->totalCount)); + } nemoNotification->setPreviewSummary(summary); nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, !appSettings->notificationSoundsEnabled()); nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn());