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