Skip to content
Permalink
Browse files
Wrap and expose system tray notifications (#4286)
* Wrap and expose system tray notifications

* System tray notifications: renamed to showSystemNotification and const
  • Loading branch information
elpaso authored and m-kuhn committed Mar 20, 2017
1 parent 5adbc64 commit f60dc81102bef487390d27da9cbaf1c7c198eb4b
Showing with 27 additions and 10 deletions.
  1. +15 −10 src/app/qgisapp.cpp
  2. +12 −0 src/app/qgisapp.h
@@ -11621,16 +11621,7 @@ void QgisApp::onTaskCompleteShowNotify( long taskId, int status )
QgsTask *task = QgsApplication::taskManager()->task( taskId );
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
showSystemNotification( tr( "Task complete" ), task->description() );
}
}
}
@@ -12344,6 +12335,20 @@ QMenu *QgisApp::createPopupMenu()
return menu;
}


void QgisApp::showSystemNotification( const QString title, const QString message )
{
#ifdef Q_OS_MAC
// Menubar icon is hidden on macOS, by default. Show to enable notification bubbles
mTray->show();
#endif
mTray->showMessage( title, message );
#ifdef Q_OS_MAC
// Re-hide menubar icon
mTray->hide();
#endif
}

void QgisApp::osmDownloadDialog()
{
QgsOSMDownloadDialog dlg;
@@ -349,6 +349,18 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
QgsVectorLayerTools *vectorLayerTools() { return mVectorLayerTools; }

/** Notify the user by using the system tray notifications
*
* @note usage of the system tray notifications should be limited
* to long running tasks and to when the user needs to be notified
* about interaction with OS services, like the password manager.
*
* @param title
* @param message
*/
void showSystemNotification( const QString title, const QString message );


//! Actions to be inserted in menus and toolbars
QAction *actionNewProject() { return mActionNewProject; }
QAction *actionOpenProject() { return mActionOpenProject; }

0 comments on commit f60dc81

Please sign in to comment.