diff --git a/CHANGELOG.md b/CHANGELOG.md index 086de753e..cbb5b9d21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - '[ui] logs_max_size' : option to set the max size of one log file. - '[ui] notification_origin' : option to specify where to display notifications (only supported: 0=bottom-right and 1=top-right). +- '[ui] systray_notification_blink' : option to activate/deactivate the blinking systray on unread notifications. +- '[ui] systray_notification_global' : option to display notification number from all accounts or only selected. +- '[ui] systray_notification_filtered' : option to filtering the number (not count if chat room is muted). ## 5.2.1 - 2024-02-01 diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp index ce218288e..2f614fa7a 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -22,33 +22,69 @@ #include "components/call/CallModel.hpp" #include "components/core/CoreManager.hpp" +#include "components/settings/AccountSettingsModel.hpp" #include "components/settings/SettingsModel.hpp" +#include "components/timeline/TimelineListModel.hpp" #include "AbstractEventCountNotifier.hpp" +#include "components/timeline/TimelineModel.hpp" // ============================================================================= using namespace std; -AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObject(parent) { - CoreManager *coreManager = CoreManager::getInstance(); - connect(coreManager, &CoreManager::eventCountChanged, this, &AbstractEventCountNotifier::eventCountChanged); - connect(this, &AbstractEventCountNotifier::eventCountChanged, this, &AbstractEventCountNotifier::internalNotifyEventCount); +AbstractEventCountNotifier::AbstractEventCountNotifier(QObject *parent) + : QObject(parent) +{ + CoreManager *coreManager = CoreManager::getInstance(); + connect(coreManager, + &CoreManager::eventCountChanged, + this, + &AbstractEventCountNotifier::eventCountChanged); + connect(coreManager->getAccountSettingsModel(), + &AccountSettingsModel::defaultAccountChanged, + this, + &AbstractEventCountNotifier::internalNotifyEventCount); + connect(this, + &AbstractEventCountNotifier::eventCountChanged, + this, + &AbstractEventCountNotifier::internalNotifyEventCount); } // ----------------------------------------------------------------------------- -int AbstractEventCountNotifier::getEventCount () const { +int AbstractEventCountNotifier::getEventCount() const +{ auto coreManager = CoreManager::getInstance(); int count = coreManager->getCore()->getMissedCallsCount(); - if( coreManager->getSettingsModel()->getStandardChatEnabled() || coreManager->getSettingsModel()->getSecureChatEnabled()) - count += coreManager->getCore()->getUnreadChatMessageCount(); + if (coreManager->getSettingsModel()->getStandardChatEnabled() + || coreManager->getSettingsModel()->getSecureChatEnabled()) + count += coreManager->getCore()->getUnreadChatMessageCountFromActiveLocals(); return count; } -void AbstractEventCountNotifier::internalNotifyEventCount () { - int n = getEventCount(); - qInfo() << QStringLiteral("Notify event count: %1.").arg(n); - n = n > 99 ? 99 : n; - notifyEventCount(n); -} \ No newline at end of file +int AbstractEventCountNotifier::getCurrentEventCount() const +{ + auto coreManager = CoreManager::getInstance(); + int count = coreManager->getCore()->getMissedCallsCount(); + auto timelines = coreManager->getTimelineListModel()->getSharedList(); + bool filtered = CoreManager::getInstance()->getSettingsModel()->isSystrayNotificationFiltered(); + bool global = CoreManager::getInstance()->getSettingsModel()->isSystrayNotificationGlobal(); + if( global && !filtered) return getEventCount(); + for (const auto &timeline : timelines) { + auto chatRoom = timeline->getChatRoomModel(); + if (!coreManager->getCore()->getDefaultAccount() + || ((global || chatRoom->isCurrentAccount()) && (!filtered || chatRoom->isNotificationsEnabled()))) + count += chatRoom->getUnreadMessagesCount(); + } + return count; +} + +void AbstractEventCountNotifier::internalNotifyEventCount() +{ + int n = getCurrentEventCount(); + + qInfo() << QStringLiteral("Notify event count: %1.").arg(n); + n = n > 99 ? 99 : n; + notifyEventCount(n); +} diff --git a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp index e5a438152..ab6191079 100644 --- a/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp +++ b/linphone-app/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp @@ -45,7 +45,8 @@ public: int getUnreadMessageCount () const; int getMissedCallCount () const; - int getEventCount () const; + int getEventCount () const;// global + int getCurrentEventCount () const;// Current account signals: void eventCountChanged (); diff --git a/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp b/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp index 707710feb..244c75989 100644 --- a/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp +++ b/linphone-app/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp @@ -28,7 +28,9 @@ #include "app/App.hpp" #include "utils/Utils.hpp" #include "utils/Constants.hpp" +#include "components/core/CoreManager.hpp" #include "components/other/colors/ColorListModel.hpp" +#include "components/settings/SettingsModel.hpp" #include "EventCountNotifierSystemTrayIcon.hpp" @@ -102,7 +104,9 @@ void EventCountNotifier::notifyEventCount (int n) { // Change counter. mBlinkTimer->stop(); - mBlinkTimer->start(); + auto coreManager = CoreManager::getInstance(); + if(!coreManager->isInitialized() || coreManager->getSettingsModel()->isSystrayNotificationBlinkEnabled()) + mBlinkTimer->start(); mDisplayCounter = true; update(); } diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 5c0ce9d68..2d60ff00c 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -1046,6 +1046,18 @@ int SettingsModel::getNotificationOrigin() const { ); } +bool SettingsModel::isSystrayNotificationBlinkEnabled() const { + return !!mConfig->getInt(UiSection, "systray_notification_blink", 1); +} + +bool SettingsModel::isSystrayNotificationGlobal() const { + return !!mConfig->getInt(UiSection, "systray_notification_global", 1); +} + +bool SettingsModel::isSystrayNotificationFiltered() const { + return !!mConfig->getInt(UiSection, "systray_notification_filtered", 0); +} + // ----------------------------------------------------------------------------- QString SettingsModel::getFileTransferUrl () const { diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index 2a0f51053..841b43bb1 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -490,6 +490,9 @@ public: void setChatNotificationSoundPath (const QString &path); int getNotificationOrigin() const; + bool isSystrayNotificationBlinkEnabled() const; + bool isSystrayNotificationGlobal() const; + bool isSystrayNotificationFiltered() const; QString getFileTransferUrl () const; void setFileTransferUrl (const QString &url);