mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +03:00
parent
b8e9dd587d
commit
d4132072d8
4 changed files with 39 additions and 1 deletions
|
@ -84,8 +84,8 @@ set(updater_SRCS
|
|||
|
||||
IF( APPLE )
|
||||
list(APPEND client_SRCS cocoainitializer_mac.mm)
|
||||
|
||||
list(APPEND client_SRCS settingsdialogmac.cpp)
|
||||
list(APPEND client_SRCS systray.mm)
|
||||
|
||||
if(SPARKLE_FOUND)
|
||||
# Define this, we need to check in updater.cpp
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "systray.h"
|
||||
#include "theme.h"
|
||||
#include <QDebug>
|
||||
|
||||
#ifdef USE_FDO_NOTIFICATIONS
|
||||
#include <QDBusConnection>
|
||||
|
@ -38,6 +39,11 @@ void Systray::showMessage(const QString & title, const QString & message, Messag
|
|||
method.setArguments(args);
|
||||
QDBusConnection::sessionBus().asyncCall(method);
|
||||
} else
|
||||
#endif
|
||||
#ifdef Q_OS_OSX
|
||||
if (canOsXSendUserNotification()) {
|
||||
sendOsXUserNotification(title, message);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
QSystemTrayIcon::showMessage(title, message, icon, millisecondsTimeoutHint);
|
||||
|
|
|
@ -21,6 +21,11 @@ class QIcon;
|
|||
|
||||
namespace OCC {
|
||||
|
||||
#ifdef Q_OS_OSX
|
||||
bool canOsXSendUserNotification();
|
||||
void sendOsXUserNotification(const QString &title, const QString &message);
|
||||
#endif
|
||||
|
||||
class Systray : public QSystemTrayIcon
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
27
src/gui/systray.mm
Normal file
27
src/gui/systray.mm
Normal file
|
@ -0,0 +1,27 @@
|
|||
#include <QString>
|
||||
#include <QDebug>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
namespace OCC {
|
||||
|
||||
bool canOsXSendUserNotification()
|
||||
{
|
||||
return NSClassFromString(@"NSUserNotificationCenter") != nil;
|
||||
}
|
||||
|
||||
void sendOsXUserNotification(const QString &title, const QString &message)
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << title << message;
|
||||
Class cuserNotificationCenter = NSClassFromString(@"NSUserNotificationCenter");
|
||||
id userNotificationCenter = [cuserNotificationCenter defaultUserNotificationCenter];
|
||||
|
||||
Class cuserNotification = NSClassFromString(@"NSUserNotification");
|
||||
id notification = [[cuserNotification alloc] init];
|
||||
[notification setTitle:[NSString stringWithUTF8String:title.toUtf8().data()]];
|
||||
[notification setInformativeText:[NSString stringWithUTF8String:message.toUtf8().data()]];
|
||||
|
||||
[userNotificationCenter deliverNotification:notification];
|
||||
[notification release];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue