Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mac] display icon in notification #7734

Merged
merged 2 commits into from
Aug 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/gui/qgsgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions src/native/mac/qgsmacnative.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 10 additions & 1 deletion src/native/mac/qgsmacnative.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ - ( BOOL )userNotificationCenter:( NSUserNotificationCenter * )center shouldPres
{
public:
QgsUserNotificationCenterDelegate *_qgsUserNotificationCenter;
NSImage *_qgisIcon;
};

QgsMacNative::QgsMacNative()
Expand All @@ -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];
Expand Down Expand Up @@ -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
{
Expand Down