Skip to content
Permalink
Browse files

Implement openFileExplorerAndSelectFile for Linux

  • Loading branch information
nirvn committed Aug 3, 2018
1 parent 65ae32a commit 1fc6aabdcd15e4f5db4da8590968ec6c8fd689f8
@@ -405,7 +405,7 @@ void QgsMapSaveDialog::onAccepted()
connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [ = ]
{
QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as image" ), tr( "Successfully saved map to <a href=\"%1\">%2</a>" )
.arg( QUrl::fromLocalFile( QFileInfo( fileNameAndFilter.first ).path() ).toString(), QDir::toNativeSeparators( fileNameAndFilter.first ) ) );
.arg( QUrl::fromLocalFile( fileNameAndFilter.first ).toString(), QDir::toNativeSeparators( fileNameAndFilter.first ) ) );
} );
connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [ = ]( int error )
{
@@ -456,7 +456,7 @@ void QgsMapSaveDialog::onAccepted()
connect( mapRendererTask, &QgsMapRendererTask::renderingComplete, [ = ]
{
QgisApp::instance()->messageBar()->pushSuccess( tr( "Save as PDF" ), tr( "Successfully saved map to <a href=\"%1\">%2</a>" )
.arg( QUrl::fromLocalFile( QFileInfo( fileName ).path() ).toString(), QDir::toNativeSeparators( fileName ) ) );
.arg( QUrl::fromLocalFile( fileName ).toString(), QDir::toNativeSeparators( fileName ) ) );
} );
connect( mapRendererTask, &QgsMapRendererTask::errorOccurred, [ = ]( int )
{
@@ -137,6 +137,10 @@ TARGET_LINK_LIBRARIES(qgis_native
"${NATIVE_LINK_LIBS}"
)

IF (UNIX)
TARGET_LINK_LIBRARIES(qgis_native Qt5DBus)
ENDIF (UNIX)

IF (WIN32)
TARGET_LINK_LIBRARIES(qgis_native shell32)
ENDIF (WIN32)
@@ -16,3 +16,28 @@
***************************************************************************/

#include "qgslinuxnative.h"

#include <QUrl>
#include <QString>
#include <QtDBus/QtDBus>
#include <QtDebug>

void QgsLinuxNative::openFileExplorerAndSelectFile( const QString &path )
{
if ( !QDBusConnection::sessionBus().isConnected() )
{
QgsNative::openFileExplorerAndSelectFile( path );
return;
}

QDBusInterface iface( QStringLiteral( "org.freedesktop.FileManager1" ),
QStringLiteral( "/org/freedesktop/FileManager1" ),
QStringLiteral( "org.freedesktop.FileManager1" ),
QDBusConnection::sessionBus() );

iface.call( QDBus::NoBlock, QStringLiteral( "ShowItems" ), QStringList( QUrl::fromLocalFile( path ).toString() ), QStringLiteral( "QGIS" ) );
if ( iface.lastError().type() != QDBusError::NoError )
{
QgsNative::openFileExplorerAndSelectFile( path );
}
}
@@ -23,6 +23,7 @@
class NATIVE_EXPORT QgsLinuxNative : public QgsNative
{
public:
void openFileExplorerAndSelectFile( const QString &path ) override;
};

#endif // QGSLINUXNATIVE_H

0 comments on commit 1fc6aab

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