Skip to content
Permalink
Browse files

[mac] display icon in notification (#7734)

there is 2 icons in notifications, one from the app itself and one set from the notification
the icon application seems not to be set correctly on mac for now
only the windon icon is set in main.cpp with myApp.setWindowIcon
the icon defined in application plist does not seem to be correctly set
...so in this PR we set the notification icon to be the QGIS one, so it looks nicer
  • Loading branch information
3nids committed Aug 28, 2018
1 parent 5c7f13b commit 2810c92f0161cd28bd054e0c8f301ae1f00f8927
Showing with 16 additions and 2 deletions.
  1. +3 −1 src/gui/qgsgui.cpp
  2. +3 −0 src/native/mac/qgsmacnative.h
  3. +10 −1 src/native/mac/qgsmacnative.mm
@@ -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)
@@ -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;
@@ -42,6 +42,7 @@ - ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPres
{
public:
QgsUserNotificationCenterDelegate *_qgsUserNotificationCenter;
NSImage *_qgisIcon;
};

QgsMacNative::QgsMacNative()
@@ -57,6 +58,11 @@ - ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPres
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 @@ - ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPres
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
{

0 comments on commit 2810c92

Please sign in to comment.
You can’t perform that action at this time.