Skip to content
Permalink
Browse files

[processing] Add api to allow providers to report warnings which should

be shown to users when using that provider

This can be used to return a translated warning message which should be
shown to users of this provider. It's intended for use in cases such as
a provider which relies on a 3rd-party backend, where the version of the
backend software is not officially supported, or for alerting users to
providers in a "beta" or "untrustworthy" state.

(cherry picked from commit 61454c6)
  • Loading branch information
nyalldawson committed Dec 5, 2019
1 parent 6838c18 commit d6afeb62573570c0f59c4fa8e38d44ce57aab6b2
@@ -105,6 +105,18 @@ Returns ``True`` if the provider can be activated, or ``False`` if it cannot be
missing external dependencies).

.. seealso:: :py:func:`isActive`
%End

virtual QString warningMessage() const;
%Docstring
Returns an optional warning message to show users when running algorithms from this provider.

This can be used to return a translated warning message which should be shown to users
of this provider. It's intended for use in cases such as a provider which relies on a 3rd-party
backend, where the version of the backend software is not officially supported, or for
alerting users to providers in a "beta" or "untrustworthy" state.

.. versionadded:: 3.10.1
%End

virtual bool isActive() const;
@@ -202,6 +202,9 @@ def runAlgorithm(self):

self.clearProgress()
self.feedback.pushVersionInfo(self.algorithm().provider())
if self.algorithm().provider().warningMessage():
self.feedback.reportError(self.algorithm().provider().warningMessage())

self.setProgressText(QCoreApplication.translate('AlgorithmDialog', 'Processing algorithm…'))

self.setInfo(
@@ -115,6 +115,18 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
*/
virtual bool canBeActivated() const { return true; }

/**
* Returns an optional warning message to show users when running algorithms from this provider.
*
* This can be used to return a translated warning message which should be shown to users
* of this provider. It's intended for use in cases such as a provider which relies on a 3rd-party
* backend, where the version of the backend software is not officially supported, or for
* alerting users to providers in a "beta" or "untrustworthy" state.
*
* \since QGIS 3.10.1
*/
virtual QString warningMessage() const { return QString(); }

/**
* Returns TRUE if the provider is active and able to run algorithms.
*/
@@ -155,6 +155,12 @@ void QgsProcessingAlgorithmDialogBase::setAlgorithm( QgsProcessingAlgorithm *alg
{
mButtonBox->removeButton( mButtonBox->button( QDialogButtonBox::Help ) );
}

const QString warning = algorithm->provider()->warningMessage();
if ( !warning.isEmpty() )
{
mMessageBar->pushMessage( warning, Qgis::Warning, 0 );
}
}

QgsProcessingAlgorithm *QgsProcessingAlgorithmDialogBase::algorithm()

0 comments on commit d6afeb6

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