From 95d68e9172d1a9eef9b208af4eef67e7a437fee9 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 25 Sep 2018 13:33:51 +1000 Subject: [PATCH] [processing] Default to hiding help button for algorithms And require that showing help is opt-in. Apart from a handful of built-in providers, most providers will not have help pages available within the QGIS documentation (including model and script algorithms). Accordingly, we should hide the help button by default and only show it for these selected providers. Note that 3rd party algorithms can still specify custom helpUrl urls, in which case the button WILL be shown. --- .../processing/models/qgsprocessingmodelalgorithm.sip.in | 2 ++ .../auto_generated/processing/qgsprocessingprovider.sip.in | 4 ++-- python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py | 3 +++ .../processing/algs/grass7/Grass7AlgorithmProvider.py | 3 +++ python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py | 3 +++ python/plugins/processing/algs/saga/SagaAlgorithmProvider.py | 3 +++ src/core/processing/models/qgsprocessingmodelalgorithm.cpp | 5 +++++ src/core/processing/models/qgsprocessingmodelalgorithm.h | 1 + src/core/processing/qgsprocessingprovider.cpp | 2 +- src/core/processing/qgsprocessingprovider.h | 4 ++-- src/gui/processing/qgsprocessingalgorithmdialogbase.cpp | 5 +++++ 11 files changed, 30 insertions(+), 5 deletions(-) diff --git a/python/core/auto_generated/processing/models/qgsprocessingmodelalgorithm.sip.in b/python/core/auto_generated/processing/models/qgsprocessingmodelalgorithm.sip.in index ef4f0da03b01..5c754e41a422 100644 --- a/python/core/auto_generated/processing/models/qgsprocessingmodelalgorithm.sip.in +++ b/python/core/auto_generated/processing/models/qgsprocessingmodelalgorithm.sip.in @@ -47,6 +47,8 @@ Constructor for QgsProcessingModelAlgorithm. virtual QString shortDescription() const; + virtual QString helpUrl() const; + virtual Flags flags() const; diff --git a/python/core/auto_generated/processing/qgsprocessingprovider.sip.in b/python/core/auto_generated/processing/qgsprocessingprovider.sip.in index fb4b9ce5fddb..8cbc8b7fedbf 100644 --- a/python/core/auto_generated/processing/qgsprocessingprovider.sip.in +++ b/python/core/auto_generated/processing/qgsprocessingprovider.sip.in @@ -60,8 +60,8 @@ string should not be localised. virtual QString helpId() const; %Docstring Returns the provider help id string, used for creating QgsHelp urls for algorithms -belong to this provider. By default, this returns the provider's id(). This string -should not be localised. +belong to this provider. By default, this returns the an empty string, meaning that +no QgsHelp url should be created for the provider's algorithms. .. seealso:: :py:func:`id` %End diff --git a/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py index 6de644825ac1..871ad7a3e6f9 100644 --- a/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py +++ b/python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py @@ -132,6 +132,9 @@ def longName(self): def id(self): return 'gdal' + def helpId(self): + return 'gdal' + def icon(self): return QgsApplication.getThemeIcon("/providerGdal.svg") diff --git a/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py b/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py index 2ee74750fd54..e94efc65f969 100644 --- a/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py +++ b/python/plugins/processing/algs/grass7/Grass7AlgorithmProvider.py @@ -128,6 +128,9 @@ def longName(self): def id(self): return 'grass7' + def helpId(self): + return 'grass7' + def icon(self): return QgsApplication.getThemeIcon("/providerGrass.svg") diff --git a/python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py b/python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py index c63f0b6b539b..9d4326f7797d 100644 --- a/python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py +++ b/python/plugins/processing/algs/qgis/QgisAlgorithmProvider.py @@ -289,6 +289,9 @@ def getAlgs(self): def id(self): return 'qgis' + def helpId(self): + return 'qgis' + def name(self): return 'QGIS' diff --git a/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py b/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py index c6540e6644ca..8f2aa4c9e442 100755 --- a/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py +++ b/python/plugins/processing/algs/saga/SagaAlgorithmProvider.py @@ -128,6 +128,9 @@ def longName(self): def id(self): return 'saga' + def helpId(self): + return 'saga' + def defaultVectorFileExtension(self, hasGeometry=True): return 'shp' if hasGeometry else 'dbf' diff --git a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp index 48ba83b84c6a..c50d921b0371 100644 --- a/src/core/processing/models/qgsprocessingmodelalgorithm.cpp +++ b/src/core/processing/models/qgsprocessingmodelalgorithm.cpp @@ -81,6 +81,11 @@ QString QgsProcessingModelAlgorithm::shortDescription() const return mHelpContent.value( QStringLiteral( "SHORT_DESCRIPTION" ) ).toString(); } +QString QgsProcessingModelAlgorithm::helpUrl() const +{ + return QString(); +} + QgsProcessingAlgorithm::Flags QgsProcessingModelAlgorithm::flags() const { // TODO - check child algorithms, if they all support threading, then the model supports threading... diff --git a/src/core/processing/models/qgsprocessingmodelalgorithm.h b/src/core/processing/models/qgsprocessingmodelalgorithm.h index d979353d84eb..b3e0643c6da1 100644 --- a/src/core/processing/models/qgsprocessingmodelalgorithm.h +++ b/src/core/processing/models/qgsprocessingmodelalgorithm.h @@ -52,6 +52,7 @@ class CORE_EXPORT QgsProcessingModelAlgorithm : public QgsProcessingAlgorithm QString svgIconPath() const override; QString shortHelpString() const override; QString shortDescription() const override; + QString helpUrl() const override; Flags flags() const override; bool canExecute( QString *errorMessage SIP_OUT = nullptr ) const override; diff --git a/src/core/processing/qgsprocessingprovider.cpp b/src/core/processing/qgsprocessingprovider.cpp index ee049247cb42..c3e78d426e0c 100644 --- a/src/core/processing/qgsprocessingprovider.cpp +++ b/src/core/processing/qgsprocessingprovider.cpp @@ -43,7 +43,7 @@ QString QgsProcessingProvider::svgIconPath() const QString QgsProcessingProvider::helpId() const { - return id(); + return QString(); } QString QgsProcessingProvider::longName() const diff --git a/src/core/processing/qgsprocessingprovider.h b/src/core/processing/qgsprocessingprovider.h index d66f299b8a6a..3f31347e8dcf 100644 --- a/src/core/processing/qgsprocessingprovider.h +++ b/src/core/processing/qgsprocessingprovider.h @@ -72,8 +72,8 @@ class CORE_EXPORT QgsProcessingProvider : public QObject /** * Returns the provider help id string, used for creating QgsHelp urls for algorithms - * belong to this provider. By default, this returns the provider's id(). This string - * should not be localised. + * belong to this provider. By default, this returns the an empty string, meaning that + * no QgsHelp url should be created for the provider's algorithms. * \see id() */ virtual QString helpId() const; diff --git a/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp b/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp index 46a107b2cb8f..e488fa2a830a 100644 --- a/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp +++ b/src/gui/processing/qgsprocessingalgorithmdialogbase.cpp @@ -143,6 +143,11 @@ void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *alg textShortHelp->setHtml( algHelp ); connect( textShortHelp, &QTextBrowser::anchorClicked, this, &QgsProcessingAlgorithmDialogBase::linkClicked ); } + + if ( algorithm->helpUrl().isEmpty() && algorithm->provider()->helpId().isEmpty() ) + { + mButtonBox->removeButton( mButtonBox->button( QDialogButtonBox::Help ) ); + } } QgsProcessingAlgorithm *QgsProcessingAlgorithmDialogBase::algorithm()