diff --git a/src/gui/qgsgui.cpp b/src/gui/qgsgui.cpp index bff0eee7b54..cffa25fa029 100644 --- a/src/gui/qgsgui.cpp +++ b/src/gui/qgsgui.cpp @@ -115,7 +115,9 @@ QgsGui::~QgsGui() QgsGui::QgsGui() { #ifdef Q_OS_MAC - mNative = new QgsMacNative(); + QgsMacNative *macNative = new QgsMacNative(); + macNative->setIconPath( QgsApplication::iconsPath() + QStringLiteral( "qgis-icon-macos.png" ) ); + mNative = macNative; #elif defined (Q_OS_WIN) mNative = new QgsWinNative(); #elif defined(Q_OS_LINUX) diff --git a/src/native/mac/qgsmacnative.h b/src/native/mac/qgsmacnative.h index 350a9731e35..1593ef8e673 100644 --- a/src/native/mac/qgsmacnative.h +++ b/src/native/mac/qgsmacnative.h @@ -29,6 +29,9 @@ class NATIVE_EXPORT QgsMacNative : public QgsNative explicit QgsMacNative(); ~QgsMacNative() override; + //! reset the application icon used in the notification + void setIconPath( const QString &iconPath = QString() ); + virtual const char *currentAppLocalizedName(); void currentAppActivateIgnoringOtherApps() override; void openFileExplorerAndSelectFile( const QString &path ) override; diff --git a/src/native/mac/qgsmacnative.mm b/src/native/mac/qgsmacnative.mm index a880eeb5de7..42164616604 100644 --- a/src/native/mac/qgsmacnative.mm +++ b/src/native/mac/qgsmacnative.mm @@ -42,6 +42,7 @@ class QgsMacNative::QgsUserNotificationCenter { public: QgsUserNotificationCenterDelegate *_qgsUserNotificationCenter; + NSImage *_qgisIcon; }; QgsMacNative::QgsMacNative() @@ -57,6 +58,11 @@ QgsMacNative::~QgsMacNative() delete mQgsUserNotificationCenter; } +void QgsMacNative::setIconPath( const QString &iconPath ) +{ + mQgsUserNotificationCenter->_qgisIcon = QtMac::toNSImage( QPixmap( iconPath ) ); +} + const char *QgsMacNative::currentAppLocalizedName() { return [[[NSRunningApplication currentApplication] localizedName] UTF8String]; @@ -92,7 +98,10 @@ QgsNative::NotificationResult QgsMacNative::showDesktopNotification( const QStri NSImage *image = nil; if ( settings.image.isNull() ) { - image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; + // image application (qgis.icns) seems not to be set for now, although present in the plist + // whenever fixed, try following line (and remove corresponding code in QgsMacNative::QgsUserNotificationCenter) + // image = [[NSImage imageNamed:@"NSApplicationIcon"] retain] + image = mQgsUserNotificationCenter->_qgisIcon; } else {