feature(desktop/general): Showing number of all notifications on tray icon badge
Functionality added to OSNotification. MacOS version. Issue #4922
This commit is contained in:
parent
3487862d27
commit
e666ccf1ad
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Status::OSNotification*>(vptr);
|
||||
if(notificationObj)
|
||||
notificationObj->showIconBadgeNotification(notificationsCount);
|
||||
}
|
||||
|
||||
void dos_osnotification_delete(DosOSNotification* vptr)
|
||||
{
|
||||
auto qobject = static_cast<QObject*>(vptr);
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
#include "DOtherSide/Status/OSNotification.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue