From b0666050f53e5382eae29a5cc6d2511e755703df Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 9 Jan 2024 12:06:44 +1000 Subject: [PATCH] Allow clicking processing output file/folder/html names in the log to open the containing folder and preselect the generated file --- .../processing/qgsprocessingalgorithmdialogbase.cpp | 13 +++++++++++++ .../processing/qgsprocessingalgorithmdialogbase.h | 1 + .../processing/qgsprocessingalgorithmdialogbase.ui | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp b/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp index 10208d3b7aae..196e97fe5163 100644 --- a/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp +++ b/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp @@ -27,6 +27,7 @@ #include "qgspanelwidget.h" #include "qgsjsonutils.h" #include "qgsunittypes.h" +#include "qgsnative.h" #include #include #include @@ -119,6 +120,9 @@ QgsProcessingAlgorithmDialogBase::QgsProcessingAlgorithmDialogBase( QWidget *par QgsGui::enableAutoGeometryRestore( this ); + txtLog->setOpenLinks( false ); + connect( txtLog, &QTextBrowser::anchorClicked, this, &QgsProcessingAlgorithmDialogBase::urlClicked ); + const QgsSettings settings; splitter->restoreState( settings.value( QStringLiteral( "/Processing/dialogBaseSplitter" ), QByteArray() ).toByteArray() ); mSplitterState = splitter->saveState(); @@ -584,6 +588,15 @@ void QgsProcessingAlgorithmDialogBase::closeClicked() close(); } +void QgsProcessingAlgorithmDialogBase::urlClicked( const QUrl &url ) +{ + const QFileInfo file( url.toLocalFile() ); + if ( file.exists() && !file.isDir() ) + QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( url.toLocalFile() ); + else + QDesktopServices::openUrl( url ); +} + QgsProcessingContext::LogLevel QgsProcessingAlgorithmDialogBase::logLevel() const { return mLogLevel; diff --git a/src/gui/processing/qgsprocessingalgorithmdialogbase.h b/src/gui/processing/qgsprocessingalgorithmdialogbase.h index 275752a7cc7a..02b6e26ec03b 100644 --- a/src/gui/processing/qgsprocessingalgorithmdialogbase.h +++ b/src/gui/processing/qgsprocessingalgorithmdialogbase.h @@ -452,6 +452,7 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, public QgsPr void linkClicked( const QUrl &url ); void taskTriggered( QgsTask *task ); void closeClicked(); + void urlClicked( const QUrl &url ); private: diff --git a/src/ui/processing/qgsprocessingalgorithmdialogbase.ui b/src/ui/processing/qgsprocessingalgorithmdialogbase.ui index 824e243c53dd..a30e43813377 100644 --- a/src/ui/processing/qgsprocessingalgorithmdialogbase.ui +++ b/src/ui/processing/qgsprocessingalgorithmdialogbase.ui @@ -84,7 +84,7 @@ 0 - + true