From e68340d406243f32208cd1ef7677731ad09c22c6 Mon Sep 17 00:00:00 2001 From: Slava Monich Date: Sat, 21 Nov 2020 01:15:13 +0200 Subject: [PATCH] Added notificationTurnsDisplayOn option It defaults to false --- src/appsettings.cpp | 15 +++++++++++++++ src/appsettings.h | 5 +++++ src/notificationmanager.cpp | 5 ++--- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/appsettings.cpp b/src/appsettings.cpp index 02904e6..6dd3bcc 100644 --- a/src/appsettings.cpp +++ b/src/appsettings.cpp @@ -25,6 +25,7 @@ namespace { const QString KEY_USE_OPEN_WITH("useOpenWith"); const QString KEY_SHOW_STICKERS_AS_IMAGES("showStickersAsImages"); const QString KEY_ANIMATE_STICKERS("animateStickers"); + const QString KEY_NOTIFICATION_TURNS_DISPLAY_ON("notificationTurnsDisplayOn"); const QString KEY_NOTIFICATION_FEEDBACK("notificationFeedback"); } @@ -88,6 +89,20 @@ void AppSettings::setAnimateStickers(bool animate) } } +bool AppSettings::notificationTurnsDisplayOn() const +{ + return settings.value(KEY_NOTIFICATION_TURNS_DISPLAY_ON, false).toBool(); +} + +void AppSettings::setNotificationTurnsDisplayOn(bool turnOn) +{ + if (notificationTurnsDisplayOn() != turnOn) { + LOG(KEY_NOTIFICATION_TURNS_DISPLAY_ON << turnOn); + settings.setValue(KEY_NOTIFICATION_TURNS_DISPLAY_ON, turnOn); + emit notificationTurnsDisplayOnChanged(); + } +} + 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 5df3d6c..a813300 100644 --- a/src/appsettings.h +++ b/src/appsettings.h @@ -27,6 +27,7 @@ class AppSettings : public QObject { Q_PROPERTY(bool useOpenWith READ getUseOpenWith WRITE setUseOpenWith NOTIFY useOpenWithChanged) Q_PROPERTY(bool showStickersAsImages READ showStickersAsImages WRITE setShowStickersAsImages NOTIFY showStickersAsImagesChanged) Q_PROPERTY(bool animateStickers READ animateStickers WRITE setAnimateStickers NOTIFY animateStickersChanged) + Q_PROPERTY(bool notificationTurnsDisplayOn READ notificationTurnsDisplayOn WRITE setNotificationTurnsDisplayOn NOTIFY notificationTurnsDisplayOnChanged) Q_PROPERTY(NotificationFeedback notificationFeedback READ notificationFeedback WRITE setNotificationFeedback NOTIFY notificationFeedbackChanged) public: @@ -52,6 +53,9 @@ public: bool animateStickers() const; void setAnimateStickers(bool animate); + bool notificationTurnsDisplayOn() const; + void setNotificationTurnsDisplayOn(bool turnOn); + NotificationFeedback notificationFeedback() const; void setNotificationFeedback(NotificationFeedback feedback); @@ -60,6 +64,7 @@ signals: void useOpenWithChanged(); void showStickersAsImagesChanged(); void animateStickersChanged(); + void notificationTurnsDisplayOnChanged(); void notificationFeedbackChanged(); private: diff --git a/src/notificationmanager.cpp b/src/notificationmanager.cpp index a9ce0a3..f1c6914 100644 --- a/src/notificationmanager.cpp +++ b/src/notificationmanager.cpp @@ -362,11 +362,10 @@ void NotificationManager::publishNotification(const NotificationGroup *notificat if (!needFeedback || (chatModel->getChatId() == notificationGroup->chatId && qGuiApp->applicationState() == Qt::ApplicationActive)) { nemoNotification->setHintValue(HINT_DISPLAY_ON, false); - nemoNotification->setHintValue(HINT_VISIBILITY, QVariant()); + nemoNotification->setHintValue(HINT_VISIBILITY, QString()); nemoNotification->setUrgency(Notification::Low); } else { - // The "display on" option will be configurable - nemoNotification->setHintValue(HINT_DISPLAY_ON, true); + nemoNotification->setHintValue(HINT_DISPLAY_ON, appSettings->notificationTurnsDisplayOn()); nemoNotification->setHintValue(HINT_VISIBILITY, VISIBILITY_PUBLIC); nemoNotification->setUrgency(Notification::Normal); }