Navigation Menu

Skip to content

Commit

Permalink
Show only notifications for macOS system tray, not constant menubar icon
Browse files Browse the repository at this point in the history
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 e32478e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
}
}
}
Expand Down

3 comments on commit e32478e

@nirvn
Copy link
Contributor

@nirvn nirvn commented on e32478e Mar 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.