Add option to suppress notification previews (#521)
* Add Switch in Settings * Don't set notification preview body * Support the setting in appSettings * fixup! Add Switch in Settings * Just show message count * Also show only when notifications are enabled at all --------- Co-authored-by: nephros <nemo@pgxperiiia10>
This commit is contained in:
parent
46419b0960
commit
c7324c020b
4 changed files with 39 additions and 1 deletions
|
@ -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 {
|
TextSwitch {
|
||||||
width: parent.columnWidth
|
width: parent.columnWidth
|
||||||
checked: appSettings.notificationTurnsDisplayOn && enabled
|
checked: appSettings.notificationTurnsDisplayOn && enabled
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace {
|
||||||
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
const QString KEY_ANIMATE_STICKERS("animateStickers");
|
||||||
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn");
|
||||||
const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled");
|
const QString KEY_NOTIFICATION_SOUNDS_ENABLED("notificationSoundsEnabled");
|
||||||
|
const QString KEY_NOTIFICATION_SUPPRESS_ENABLED("notificationSuppressContent");
|
||||||
const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback");
|
const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback");
|
||||||
const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer");
|
const QString KEY_STORAGE_OPTIMIZER("useStorageOptimizer");
|
||||||
const QString KEY_INLINEBOT_LOCATION_ACCESS("allowInlineBotLocationAccess");
|
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
|
AppSettings::NotificationFeedback AppSettings::notificationFeedback() const
|
||||||
{
|
{
|
||||||
return (NotificationFeedback) settings.value(KEY_NOTIFICATION_FEEDBACK, (int) NotificationFeedbackAll).toInt();
|
return (NotificationFeedback) settings.value(KEY_NOTIFICATION_FEEDBACK, (int) NotificationFeedbackAll).toInt();
|
||||||
|
|
|
@ -32,6 +32,7 @@ class AppSettings : public QObject {
|
||||||
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
|
Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged)
|
||||||
Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged)
|
Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged)
|
||||||
Q_PROPERTY(bool notificationSoundsEnabled READ notificationSoundsEnabled WRITE setNotificationSoundsEnabled NOTIFY notificationSoundsEnabledChanged)
|
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(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged)
|
||||||
Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged)
|
Q_PROPERTY(bool storageOptimizer READ storageOptimizer WRITE setStorageOptimizer NOTIFY storageOptimizerChanged)
|
||||||
Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged)
|
Q_PROPERTY(bool allowInlineBotLocationAccess READ allowInlineBotLocationAccess WRITE setAllowInlineBotLocationAccess NOTIFY allowInlineBotLocationAccessChanged)
|
||||||
|
@ -84,6 +85,9 @@ public:
|
||||||
bool notificationSoundsEnabled() const;
|
bool notificationSoundsEnabled() const;
|
||||||
void setNotificationSoundsEnabled(bool enable);
|
void setNotificationSoundsEnabled(bool enable);
|
||||||
|
|
||||||
|
bool notificationSuppressContent() const;
|
||||||
|
void setNotificationSuppressContent(bool enable);
|
||||||
|
|
||||||
NotificationFeedback notificationFeedback() const;
|
NotificationFeedback notificationFeedback() const;
|
||||||
void setNotificationFeedback(NotificationFeedback feedback);
|
void setNotificationFeedback(NotificationFeedback feedback);
|
||||||
|
|
||||||
|
@ -120,6 +124,7 @@ signals:
|
||||||
void animateStickersChanged();
|
void animateStickersChanged();
|
||||||
void notificationTurnsDisplayOnChanged();
|
void notificationTurnsDisplayOnChanged();
|
||||||
void notificationSoundsEnabledChanged();
|
void notificationSoundsEnabledChanged();
|
||||||
|
void notificationSuppressContentChanged();
|
||||||
void notificationFeedbackChanged();
|
void notificationFeedbackChanged();
|
||||||
void storageOptimizerChanged();
|
void storageOptimizerChanged();
|
||||||
void allowInlineBotLocationAccessChanged();
|
void allowInlineBotLocationAccessChanged();
|
||||||
|
|
|
@ -377,7 +377,11 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat
|
||||||
nemoNotification->setHintValue(HINT_VISIBILITY, QString());
|
nemoNotification->setHintValue(HINT_VISIBILITY, QString());
|
||||||
nemoNotification->setUrgency(Notification::Low);
|
nemoNotification->setUrgency(Notification::Low);
|
||||||
} else {
|
} else {
|
||||||
nemoNotification->setPreviewBody(notificationBody);
|
if (!appSettings->notificationSuppressContent()) {
|
||||||
|
nemoNotification->setPreviewBody(notificationBody);
|
||||||
|
} else {
|
||||||
|
nemoNotification->setPreviewBody(tr("%Ln unread messages", "", notificationGroup->totalCount));
|
||||||
|
}
|
||||||
nemoNotification->setPreviewSummary(summary);
|
nemoNotification->setPreviewSummary(summary);
|
||||||
nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, !appSettings->notificationSoundsEnabled());
|
nemoNotification->setHintValue(HINT_SUPPRESS_SOUND, !appSettings->notificationSoundsEnabled());
|
||||||
nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn());
|
nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn());
|
||||||
|
|
Loading…
Reference in a new issue