diff --git a/vendor/DOtherSide/lib/include/DOtherSide/DOtherSide.h b/vendor/DOtherSide/lib/include/DOtherSide/DOtherSide.h index 4d70be2534..f9ad636b14 100644 --- a/vendor/DOtherSide/lib/include/DOtherSide/DOtherSide.h +++ b/vendor/DOtherSide/lib/include/DOtherSide/DOtherSide.h @@ -1004,6 +1004,7 @@ DOS_API void dos_event_delete(DosEvent* vptr); DOS_API DosOSNotification* dos_osnotification_create(); DOS_API void dos_osnotification_show_notification(DosOSNotification* vptr, const char* title, const char* message, const char* identifier); +DOS_API void dos_osnotification_show_badge_notification(DosOSNotification* vptr, int notificationsCount); DOS_API void dos_osnotification_delete(DosOSNotification* vptr); #pragma endregion diff --git a/vendor/DOtherSide/lib/include/DOtherSide/Status/OSNotification.h b/vendor/DOtherSide/lib/include/DOtherSide/Status/OSNotification.h index 41a75cf606..a4484ec1f3 100644 --- a/vendor/DOtherSide/lib/include/DOtherSide/Status/OSNotification.h +++ b/vendor/DOtherSide/lib/include/DOtherSide/Status/OSNotification.h @@ -23,6 +23,8 @@ namespace Status void showNotification(const QString& title, const QString& message, const QString& identifier); + void showIconBadgeNotification(int notificationsCount); + signals: void notificationClicked(QString identifier); @@ -41,6 +43,7 @@ namespace Status private: void initNotificationMacOs(); void showNotificationMacOs(QString title, QString message, QString identifier); + void showIconBadgeNotificationMacOs(int notificationsCount); private: NotificationHelper *m_notificationHelper; diff --git a/vendor/DOtherSide/lib/src/DOtherSide.cpp b/vendor/DOtherSide/lib/src/DOtherSide.cpp index c7554fe7a7..6b1e6acb89 100644 --- a/vendor/DOtherSide/lib/src/DOtherSide.cpp +++ b/vendor/DOtherSide/lib/src/DOtherSide.cpp @@ -1435,6 +1435,13 @@ void dos_osnotification_show_notification(DosOSNotification* vptr, notificationObj->showNotification(title, message, identifier); } +void dos_osnotification_show_badge_notification(DosOSNotification* vptr, int notificationsCount) +{ + auto notificationObj = static_cast(vptr); + if(notificationObj) + notificationObj->showIconBadgeNotification(notificationsCount); +} + void dos_osnotification_delete(DosOSNotification* vptr) { auto qobject = static_cast(vptr); diff --git a/vendor/DOtherSide/lib/src/Status/OSNotification.cpp b/vendor/DOtherSide/lib/src/Status/OSNotification.cpp index 11fa779d9b..d4b2689980 100644 --- a/vendor/DOtherSide/lib/src/Status/OSNotification.cpp +++ b/vendor/DOtherSide/lib/src/Status/OSNotification.cpp @@ -159,4 +159,13 @@ void OSNotification::showNotification(const QString& title, #elif defined Q_OS_MACOS showNotificationMacOs(title, message, identifier); #endif +} + +void OSNotification::showIconBadgeNotification(int notificationsCount) +{ +#ifdef Q_OS_WIN + // TODO +#elif defined Q_OS_MACOS + showIconBadgeNotificationMacOs(notificationsCount); +#endif } \ No newline at end of file diff --git a/vendor/DOtherSide/lib/src/Status/OSNotification.mm b/vendor/DOtherSide/lib/src/Status/OSNotification.mm index c81d78d05e..00393e728b 100644 --- a/vendor/DOtherSide/lib/src/Status/OSNotification.mm +++ b/vendor/DOtherSide/lib/src/Status/OSNotification.mm @@ -1,5 +1,7 @@ #include "DOtherSide/Status/OSNotification.h" +#include + #ifdef Q_OS_MACOS #import @@ -55,6 +57,17 @@ void OSNotification::showNotificationMacOs(QString title, QString message, [notification release]; } +void OSNotification::showIconBadgeNotificationMacOs(int notificationsCount) +{ + QString notificationsString; // empty string will clear the badge + if (notificationsCount > 0 && notificationsCount < 10) { + notificationsString = QString::number(notificationsCount); + } else if (notificationsCount >= 10) { + notificationsString = "9+"; + } + [[NSApp dockTile] setBadgeLabel:notificationsString.toNSString()]; +} + @implementation NotificationDelegate { OSNotification* instance; }