Skip to content
Permalink
Browse files

[FEATURE] Add linux native progress report API (#7549)

Works on: 
- Unity
- Gnome-Shell (dash to dock extension)
- KDA Plasma
  • Loading branch information
nirvn committed Aug 8, 2018
1 parent 56e605b commit 9664103f22e43412dbb59ba83f29f6b0b59d92e0
Showing with 57 additions and 0 deletions.
  1. +51 −0 src/native/linux/qgslinuxnative.cpp
  2. +6 −0 src/native/linux/qgslinuxnative.h
@@ -17,6 +17,7 @@

#include "qgslinuxnative.h"

#include <QCoreApplication>
#include <QUrl>
#include <QString>
#include <QtDBus/QtDBus>
@@ -28,6 +29,12 @@ QgsNative::Capabilities QgsLinuxNative::capabilities() const
return NativeDesktopNotifications;
}

void QgsLinuxNative::initializeMainWindow( QWindow * )
{
// Hardcoded desktop file value matching our official .deb packages
mDesktopFile = QStringLiteral( "qgis.desktop" );
}

void QgsLinuxNative::openFileExplorerAndSelectFile( const QString &path )
{
if ( !QDBusConnection::sessionBus().isConnected() )
@@ -48,6 +55,50 @@ void QgsLinuxNative::openFileExplorerAndSelectFile( const QString &path )
}
}

void QgsLinuxNative::showUndefinedApplicationProgress()
{
const QVariantMap properties
{
{ QStringLiteral( "progress-visible" ), true },
{ QStringLiteral( "progress" ), 0.0 }
};

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

void QgsLinuxNative::setApplicationProgress( double progress )
{
const QVariantMap properties
{
{ QStringLiteral( "progress-visible" ), true },
{ QStringLiteral( "progress" ), progress / 100.0 }
};

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

void QgsLinuxNative::hideApplicationProgress()
{
const QVariantMap properties
{
{ QStringLiteral( "progress-visible" ), false },
};

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
*
@@ -34,8 +34,14 @@ class NATIVE_EXPORT QgsLinuxNative : public QgsNative
{
public:
QgsNative::Capabilities capabilities() const override;
void initializeMainWindow( QWindow *window ) override;
void openFileExplorerAndSelectFile( const QString &path ) override;
void showUndefinedApplicationProgress() override;
void setApplicationProgress( double progress ) override;
void hideApplicationProgress() override;
NotificationResult showDesktopNotification( const QString &summary, const QString &body, const NotificationSettings &settings = NotificationSettings() ) override;
private:
QString mDesktopFile;
};

#endif // QGSLINUXNATIVE_H

1 comment on commit 9664103

@nirvn

This comment has been minimized.

Copy link
Contributor Author

@nirvn nirvn commented on 9664103 Aug 8, 2018

Build broken due to qgsnative initializeMainWindow change in an earlier commit, fixing now.

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