Skip to content

Commit

Permalink
[processing] Disable runAsBatch/runAsSingle buttons during algorithm …
Browse files Browse the repository at this point in the history
…execution
  • Loading branch information
gacarrillor committed Mar 7, 2020
1 parent 237f1f7 commit 0153dc8
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
Expand Up @@ -254,6 +254,12 @@ Displays an info ``message`` in the dialog's log.
void resetGui();
%Docstring
Resets the dialog's gui, ready for another algorithm execution.
%End

virtual void resetAdditionalGui();
%Docstring
For subclasses to register their own GUI controls to be reset, ready
for another algorithm execution.
%End

void updateRunButtonVisibility();
Expand All @@ -265,6 +271,12 @@ Sets visibility for mutually exclusive buttons Run and Change Parameters.
%Docstring
Blocks run and changeParameters buttons and parameters tab while the
algorithm is running.
%End

virtual void blockAdditionalControlsWhileRunning();
%Docstring
For subclasses to register their own GUI controls to be blocked while
the algorithm is running.
%End

QgsMessageBar *messageBar();
Expand Down
8 changes: 8 additions & 0 deletions python/plugins/processing/gui/AlgorithmDialog.py
Expand Up @@ -101,6 +101,14 @@ def runAsBatch(self):
dlg.show()
dlg.exec_()

def resetAdditionalGui(self):
if not self.in_place:
self.runAsBatchButton.setEnabled(True)

def blockAdditionalControlsWhileRunning(self):
if not self.in_place:
self.runAsBatchButton.setEnabled(False)

def setParameters(self, parameters):
self.mainWidget().setParameters(parameters)

Expand Down
6 changes: 6 additions & 0 deletions python/plugins/processing/gui/BatchAlgorithmDialog.py
Expand Up @@ -87,6 +87,12 @@ def runAsSingle(self):
dlg.show()
dlg.exec_()

def resetAdditionalGui(self):
self.btnRunSingle.setEnabled(True)

def blockAdditionalControlsWhileRunning(self):
self.btnRunSingle.setEnabled(False)

def runAlgorithm(self):
alg_parameters = []

Expand Down
12 changes: 12 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.cpp
Expand Up @@ -583,6 +583,7 @@ void QgsProcessingAlgorithmDialogBase::resetGui()
mButtonClose->setEnabled( true );
mTabWidget->setTabEnabled( 0, true ); // Enable Parameters tab
updateRunButtonVisibility();
resetAdditionalGui();
}

void QgsProcessingAlgorithmDialogBase::updateRunButtonVisibility()
Expand All @@ -593,11 +594,22 @@ void QgsProcessingAlgorithmDialogBase::updateRunButtonVisibility()
mButtonChangeParameters->setVisible( !runButtonVisible && mExecutedAnyResult );
}

void QgsProcessingAlgorithmDialogBase::resetAdditionalGui()
{

}

void QgsProcessingAlgorithmDialogBase::blockControlsWhileRunning()
{
mButtonRun->setEnabled( false );
mButtonChangeParameters->setEnabled( false );
mTabWidget->setTabEnabled( 0, false ); // Disable Parameters tab
blockAdditionalControlsWhileRunning();
}

void QgsProcessingAlgorithmDialogBase::blockAdditionalControlsWhileRunning()
{

}

QgsMessageBar *QgsProcessingAlgorithmDialogBase::messageBar()
Expand Down
12 changes: 12 additions & 0 deletions src/gui/processing/qgsprocessingalgorithmdialogbase.h
Expand Up @@ -299,6 +299,12 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
*/
void resetGui();

/**
* For subclasses to register their own GUI controls to be reset, ready
* for another algorithm execution.
*/
virtual void resetAdditionalGui();

/**
* Sets visibility for mutually exclusive buttons Run and Change Parameters.
*/
Expand All @@ -310,6 +316,12 @@ class GUI_EXPORT QgsProcessingAlgorithmDialogBase : public QDialog, private Ui::
*/
void blockControlsWhileRunning();

/**
* For subclasses to register their own GUI controls to be blocked while
* the algorithm is running.
*/
virtual void blockAdditionalControlsWhileRunning();

/**
* Returns the dialog's message bar.
*/
Expand Down

0 comments on commit 0153dc8

Please sign in to comment.