Skip to content
Permalink
Browse files

[FEATURE][native] Add badge count support for the linux platform

  • Loading branch information
nirvn committed Sep 7, 2018
1 parent 1002824 commit 5030121e8a25674749666ffd9efccfd5e71469ff
@@ -1335,6 +1335,10 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
{
QgsGui::instance()->nativePlatformInterface()->hideApplicationProgress();
} );
connect( QgsApplication::taskManager(), &QgsTaskManager::countActiveTasksChanged, this, []( int count )
{
QgsGui::instance()->nativePlatformInterface()->setApplicationBadgeCount( count );
} );

if ( !( QgsGui::nativePlatformInterface()->capabilities() & QgsNative::NativeDesktopNotifications ) )
{
@@ -102,6 +102,22 @@ void QgsLinuxNative::hideApplicationProgress()
QDBusConnection::sessionBus().send( message );
}

void QgsLinuxNative::setApplicationBadgeCount( int count )
{
// the badge will only be shown when the count is greater than one
const QVariantMap properties
{
{ QStringLiteral( "count-visible" ), count > 1 },
{ QStringLiteral( "count" ), static_cast< long long >( count ) }
};

QDBusMessage message = QDBusMessage::createSignal( QStringLiteral( "/org/qgis/UnityLauncher" ),
QStringLiteral( "com.canonical.Unity.LauncherEntry" ),
QStringLiteral( "Update" ) );
message.setArguments( {mDesktopFile, properties} );
QDBusConnection::sessionBus().send( message );
}

/**
* Automatic marshaling of a QImage for org.freedesktop.Notifications.Notify
*
@@ -42,6 +42,7 @@ class NATIVE_EXPORT QgsLinuxNative : public QgsNative
void showUndefinedApplicationProgress() override;
void setApplicationProgress( double progress ) override;
void hideApplicationProgress() override;
void setApplicationBadgeCount( int count ) override;
NotificationResult showDesktopNotification( const QString &summary, const QString &body, const NotificationSettings &settings = NotificationSettings() ) override;
private:
QString mDesktopFile;
@@ -63,6 +63,11 @@ void QgsNative::hideApplicationProgress()

}

void QgsNative::setApplicationBadgeCount( int )
{

}

QgsNative::NotificationResult QgsNative::showDesktopNotification( const QString &, const QString &, const NotificationSettings & )
{
NotificationResult result;
@@ -124,6 +124,13 @@ class NATIVE_EXPORT QgsNative
*/
virtual void hideApplicationProgress();

/**
* Shows an application badge count.
*
* The default implementation does nothing.
* \since QGIS 3.4
*/
virtual void setApplicationBadgeCount( int count );

/**
* Notification settings, for use with showDesktopNotification().

0 comments on commit 5030121

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