Skip to content
Permalink
Browse files

[browser] Don't try to open links within the browser properties widget

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.
  • Loading branch information
nyalldawson committed Oct 31, 2018
1 parent 3f72e0c commit ab4601820cf5232e1ed76f74432bc2000935276c
Showing with 20 additions and 0 deletions.
  1. +16 −0 src/gui/qgsbrowserdockwidget_p.cpp
  2. +4 −0 src/gui/qgsbrowserdockwidget_p.h
@@ -38,6 +38,9 @@
#include "qgsproject.h"
#include "qgssettings.h"
#include "qgsmeshlayer.h"
#include "qgsgui.h"
#include "qgsnative.h"
#include <QDesktopServices>

#include <QDragEnterEvent>

@@ -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
@@ -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 )

@@ -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;
};

0 comments on commit ab46018

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