Skip to content
Permalink
Browse files

Show only notifications for macOS system tray, not constant menubar icon

Otherwise, a menubar QGIS icon is shown, but contains no child actions.

This method of showing notifications should probably be moved to an
abstract call. However, on macOS, the showMessage() icon and timeout
are ignored.

Better to use a direct Obj-C++ method for macOS notifications:
https://wiki.qt.io/How_to_use_OS_X_Notification_Center
  • Loading branch information
dakcarto committed Mar 8, 2017
1 parent 35edc18 commit e32478e8f7e91fda0707bea9340c38fcd6c325a3
Showing with 13 additions and 0 deletions.
  1. +13 −0 src/app/qgisapp.cpp
@@ -1131,6 +1131,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mTray = new QSystemTrayIcon();
mTray->setIcon( QIcon( QgsApplication::appIconPath() ) );
mTray->show();
#ifdef Q_OS_MAC
// We only want the system notifications, no need for constant menubar icon
mTray->hide();
#endif


connect( QgsApplication::taskManager(), &QgsTaskManager::statusChanged, this, &QgisApp::onTaskCompleteShowNotify );

@@ -11433,7 +11438,15 @@ void QgisApp::onTaskCompleteShowNotify( long taskId, int status )
if ( task )
{
QString description = task->description();
#ifdef Q_OS_MAC
// Menubar icon is hidden on macOS, by default. Show to enable notification bubbles
mTray->show();
#endif
mTray->showMessage( "Task Complete", description );
#ifdef Q_OS_MAC
// Re-hide menubar icon
mTray->hide();
#endif
}
}
}

3 comments on commit e32478e

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Mar 9, 2017

That's a bit of an issue on linux too. @NathanW2 could the ifdef be removed for that less intrusive behavior to be on all platforms?

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 replied Mar 9, 2017

At l;east on WIndows if you hide the icon it doesn't show the notification. Can someone test this on linux for me and if it's good to hide on linux ifdef that and I will handle the hide/show case on WIndows.

@dakcarto

This comment has been minimized.

Copy link
Member Author

@dakcarto dakcarto replied Mar 10, 2017

@nirvn wrote:

That's a bit of an issue on linux too. ...

At least on KDE, and from what @elpaso showed me this morning, the 'tray' icon really only shows up in the notifications center, which is appropriate (I think). So, all Linux variants may not benefit from the less intrusive approach; in fact, it may be undesired. Not sure of the best approach there.

@nirvn, can you share a screen snap of the issue you see on Linux, and describe the OS variant?

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