mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[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.
This commit is contained in:
parent
3f72e0cd41
commit
ab4601820c
@ -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;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user