mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
When processing tasks are clicked in task manager, reopen the
algorithm dialog
This commit is contained in:
parent
7603487e6a
commit
b8defc113c
@ -64,6 +64,7 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
def __init__(self, alg):
|
||||
super().__init__()
|
||||
self.feedback_dialog = None
|
||||
self.task = None
|
||||
|
||||
self.setAlgorithm(alg)
|
||||
self.setMainWidget(self.getParametersPanel(alg, self))
|
||||
@ -71,6 +72,7 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
self.runAsBatchButton = QPushButton(QCoreApplication.translate("AlgorithmDialog", "Run as Batch Process…"))
|
||||
self.runAsBatchButton.clicked.connect(self.runAsBatch)
|
||||
self.buttonBox().addButton(self.runAsBatchButton, QDialogButtonBox.ResetRole) # reset role to ensure left alignment
|
||||
QgsApplication.taskManager().triggered.connect(self.taskTriggered)
|
||||
|
||||
def getParametersPanel(self, alg, parent):
|
||||
return ParametersPanel(parent, alg)
|
||||
@ -233,6 +235,7 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
self.cancelButton().setEnabled(self.algorithm().flags() & QgsProcessingAlgorithm.FlagCanCancel)
|
||||
|
||||
def on_complete(ok, results):
|
||||
self.task = None
|
||||
if ok:
|
||||
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
||||
feedback.pushInfo(self.tr('Results:'))
|
||||
@ -255,9 +258,9 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
# Make sure the Log tab is visible before executing the algorithm
|
||||
self.showLog()
|
||||
|
||||
task = QgsProcessingAlgRunnerTask(self.algorithm(), parameters, context, feedback)
|
||||
task.executed.connect(on_complete)
|
||||
QgsApplication.taskManager().addTask(task)
|
||||
self.task = QgsProcessingAlgRunnerTask(self.algorithm(), parameters, context, feedback)
|
||||
self.task.executed.connect(on_complete)
|
||||
QgsApplication.taskManager().addTask(self.task)
|
||||
else:
|
||||
self.feedback_dialog = self.createProgressDialog()
|
||||
self.feedback_dialog.show()
|
||||
@ -277,6 +280,13 @@ class AlgorithmDialog(QgsProcessingAlgorithmDialogBase):
|
||||
self.messageBar().pushMessage("", self.tr("Wrong or missing parameter value: {0}").format(e.parameter.description()),
|
||||
level=QgsMessageBar.WARNING, duration=5)
|
||||
|
||||
def taskTriggered(self, task):
|
||||
if task == self.task:
|
||||
self.show()
|
||||
self.raise_()
|
||||
self.setWindowState(self.windowState() & ~Qt.WindowMinimized | Qt.WindowActive)
|
||||
self.activateWindow()
|
||||
|
||||
def finish(self, successful, result, context, feedback):
|
||||
keepOpen = not successful or ProcessingConfig.getSetting(ProcessingConfig.KEEP_DIALOG_OPEN)
|
||||
|
||||
|
@ -88,9 +88,6 @@ class AlgorithmLocatorFilter(QgsLocatorFilter):
|
||||
prevMapTool = canvas.mapTool()
|
||||
dlg.show()
|
||||
dlg.exec_()
|
||||
# have to manually delete the dialog - otherwise it's owned by the
|
||||
# iface mainWindow and never deleted
|
||||
dlg.deleteLater()
|
||||
if canvas.mapTool() != prevMapTool:
|
||||
try:
|
||||
canvas.mapTool().reset()
|
||||
|
@ -300,7 +300,7 @@ class ProcessingToolbox(BASE, WIDGET):
|
||||
self.addRecentAlgorithms(True)
|
||||
# have to manually delete the dialog - otherwise it's owned by the
|
||||
# iface mainWindow and never deleted
|
||||
dlg.deleteLater()
|
||||
# dlg.deleteLater()
|
||||
else:
|
||||
feedback = MessageBarProgress()
|
||||
context = dataobjects.createContext(feedback)
|
||||
|
@ -154,7 +154,4 @@ def execAlgorithmDialog(algOrName, parameters={}):
|
||||
canvas.setMapTool(prevMapTool)
|
||||
|
||||
results = dlg.results()
|
||||
# have to manually delete the dialog - otherwise it's owned by the
|
||||
# iface mainWindow and never deleted
|
||||
dlg.deleteLater()
|
||||
return results
|
||||
|
Loading…
x
Reference in New Issue
Block a user