mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Implement openFileExplorerAndSelectFile for Linux
This commit is contained in:
parent
65ae32aadd
commit
1fc6aabdcd
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user