Navigation Menu

Skip to content

Commit

Permalink
[browser] Don't try to open links within the browser properties widget
Browse files Browse the repository at this point in the history
Instead open them externally. Fixes clicking on the path link
within metadata tries to open layer files instead the text
widget instead of showing them in the desktop file browser.

(cherry picked from commit ab46018)
  • Loading branch information
nyalldawson committed Nov 1, 2018
1 parent 92e18bf commit 755df79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/gui/qgsbrowserdockwidget_p.cpp
Expand Up @@ -38,6 +38,9 @@
#include "qgsproject.h"
#include "qgssettings.h"
#include "qgsmeshlayer.h"
#include "qgsgui.h"
#include "qgsnative.h"
#include <QDesktopServices>

#include <QDragEnterEvent>

Expand Down Expand Up @@ -115,6 +118,10 @@ QgsBrowserLayerProperties::QgsBrowserLayerProperties( QWidget *parent )

mUriLabel = new QgsBrowserPropertiesWrapLabel( QString(), this );
mHeaderGridLayout->addItem( new QWidgetItem( mUriLabel ), 1, 1 );

// we don't want links to open in the little widget, open them externally instead
mMetadataTextBrowser->setOpenLinks( false );
connect( mMetadataTextBrowser, &QTextBrowser::anchorClicked, this, &QgsBrowserLayerProperties::urlClicked );
}

class ProjectionSettingRestorer
Expand Down Expand Up @@ -249,6 +256,15 @@ void QgsBrowserLayerProperties::setCondensedMode( bool condensedMode )
}
}

void QgsBrowserLayerProperties::urlClicked( const QUrl &url )
{
QFileInfo file( url.toLocalFile() );
if ( file.exists() && !file.isDir() )
QgsGui::instance()->nativePlatformInterface()->openFileExplorerAndSelectFile( url.toLocalFile() );
else
QDesktopServices::openUrl( url );
}

QgsBrowserDirectoryProperties::QgsBrowserDirectoryProperties( QWidget *parent )
: QgsBrowserPropertiesWidget( parent )

Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsbrowserdockwidget_p.h
Expand Up @@ -123,6 +123,10 @@ class QgsBrowserLayerProperties : public QgsBrowserPropertiesWidget, private Ui:
*/
void setCondensedMode( bool condensedMode ) override;

private slots:

void urlClicked( const QUrl &url );

private:
QgsBrowserPropertiesWrapLabel *mUriLabel = nullptr;
};
Expand Down

0 comments on commit 755df79

Please sign in to comment.