Skip to content

Commit e32478e

Browse files
committed
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
1 parent 35edc18 commit e32478e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/app/qgisapp.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
11311131
mTray = new QSystemTrayIcon();
11321132
mTray->setIcon( QIcon( QgsApplication::appIconPath() ) );
11331133
mTray->show();
1134+
#ifdef Q_OS_MAC
1135+
// We only want the system notifications, no need for constant menubar icon
1136+
mTray->hide();
1137+
#endif
1138+
11341139

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

@@ -11433,7 +11438,15 @@ void QgisApp::onTaskCompleteShowNotify( long taskId, int status )
1143311438
if ( task )
1143411439
{
1143511440
QString description = task->description();
11441+
#ifdef Q_OS_MAC
11442+
// Menubar icon is hidden on macOS, by default. Show to enable notification bubbles
11443+
mTray->show();
11444+
#endif
1143611445
mTray->showMessage( "Task Complete", description );
11446+
#ifdef Q_OS_MAC
11447+
// Re-hide menubar icon
11448+
mTray->hide();
11449+
#endif
1143711450
}
1143811451
}
1143911452
}

0 commit comments

Comments
 (0)