Skip to content

Commit

Permalink
Allow processing dialog to override default processing context settings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 16, 2023
1 parent 1dc81b5 commit 7cd6b61
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Expand Up @@ -340,6 +340,15 @@ Formats an input ``string`` for display in the log tab.
Returns ``True`` if the dialog is all finalized and can be safely deleted.

.. versionadded:: 3.26
%End

void applyContextOverrides( QgsProcessingContext *context );
%Docstring
Applies any defined overrides for Processing context settings to the specified ``context``.

This allows the dialog to override default Processing settings for an individual algorithm execution.

.. versionadded:: 3.32
%End

signals:
Expand Down
5 changes: 3 additions & 2 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -161,13 +161,14 @@ def processingContext(self):
if self.context is None:
self.feedback = self.createFeedback()
self.context = dataobjects.createContext(self.feedback)
self.context.setLogLevel(self.logLevel())

self.applyContextOverrides(self.context)
return self.context

def runAlgorithm(self):
self.feedback = self.createFeedback()
self.context = dataobjects.createContext(self.feedback)
self.context.setLogLevel(self.logLevel())
self.applyContextOverrides(self.context)

checkCRS = ProcessingConfig.getSetting(ProcessingConfig.WARN_UNMATCHING_CRS)
try:
Expand Down
8 changes: 8 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -826,6 +826,14 @@ bool QgsProcessingAlgorithmDialogBase::isFinalized()
return true;
}

void QgsProcessingAlgorithmDialogBase::applyContextOverrides( QgsProcessingContext *context )
{
if ( !context )
return;

context->setLogLevel( logLevel() );
}

void QgsProcessingAlgorithmDialogBase::setInfo( const QString &message, bool isError, bool escapeHtml, bool isWarning )
{
constexpr int MESSAGE_COUNT_LIMIT = 10000;
Expand Down
9 changes: 9 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.h
Expand Up @@ -390,6 +390,15 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, public QgsPr
*/
virtual bool isFinalized();

/**
* Applies any defined overrides for Processing context settings to the specified \a context.
*
* This allows the dialog to override default Processing settings for an individual algorithm execution.
*
* \since QGIS 3.32
*/
void applyContextOverrides( QgsProcessingContext *context );

signals:

/**
Expand Down

0 comments on commit 7cd6b61

Please sign in to comment.