mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
Nicer formatting for log in algorithm dialog
This commit is contained in:
parent
29f50b72ee
commit
b40f409de2
@ -220,9 +220,11 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
|
||||
self.setInfo(
|
||||
self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.displayName()))
|
||||
self.tr('<b>Algorithm \'{0}\' starting...</b>').format(self.alg.displayName()), escape_html=False)
|
||||
|
||||
feedback.pushInfo(self.tr('Input parameters:\n{}\n'.format(pformat(parameters))))
|
||||
feedback.pushInfo(self.tr('Input parameters:'))
|
||||
feedback.pushCommandInfo(pformat(parameters))
|
||||
feedback.pushInfo('')
|
||||
start_time = time.time()
|
||||
|
||||
if self.iterateParam:
|
||||
@ -239,7 +241,9 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
self.buttonCancel.setEnabled(self.alg.flags() & QgsProcessingAlgorithm.FlagCanCancel)
|
||||
result = executeAlgorithm(self.alg, parameters, context, feedback)
|
||||
feedback.pushInfo(self.tr('Execution completed in {0:0.2f} seconds'.format(time.time() - start_time)))
|
||||
feedback.pushInfo(self.tr('Results:\n{}\n'.format(pformat(result))))
|
||||
feedback.pushInfo(self.tr('Results:'))
|
||||
feedback.pushCommandInfo(pformat(result))
|
||||
feedback.pushInfo('')
|
||||
|
||||
self.buttonCancel.setEnabled(False)
|
||||
self.finish(result, context, feedback)
|
||||
@ -270,7 +274,7 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
return
|
||||
|
||||
self.executed = True
|
||||
self.setInfo(self.tr('Algorithm {0} finished').format(self.alg.displayName()))
|
||||
self.setInfo(self.tr('Algorithm \'{0}\' finished').format(self.alg.displayName()), escape_html=False)
|
||||
QApplication.restoreOverrideCursor()
|
||||
|
||||
if not keepOpen:
|
||||
@ -280,4 +284,4 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
if self.alg.hasHtmlOutputs():
|
||||
self.setInfo(
|
||||
self.tr('HTML output has been generated by this algorithm.'
|
||||
'\nOpen the results dialog to check it.'))
|
||||
'\nOpen the results dialog to check it.'), escape_html=False)
|
||||
|
@ -28,6 +28,7 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
import os
|
||||
import webbrowser
|
||||
import html
|
||||
|
||||
from qgis.PyQt import uic
|
||||
from qgis.PyQt.QtCore import Qt, QCoreApplication, QByteArray, QUrl
|
||||
@ -186,26 +187,28 @@ class AlgorithmDialogBase(BASE, WIDGET):
|
||||
self.btnRun.setEnabled(True)
|
||||
self.btnClose.setEnabled(True)
|
||||
|
||||
def setInfo(self, msg, error=False):
|
||||
def setInfo(self, msg, error=False, escape_html=True):
|
||||
if error:
|
||||
self.txtLog.append('<span style="color:red"><br>%s<br></span>' % msg)
|
||||
self.txtLog.append('<span style="color:red"><br>{}<br></span>'.format(msg, quote=False))
|
||||
elif escape_html:
|
||||
self.txtLog.append(html.escape(msg))
|
||||
else:
|
||||
self.txtLog.append(msg)
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
def setCommand(self, cmd):
|
||||
if self.showDebug:
|
||||
self.setInfo('<code>%s<code>' % cmd)
|
||||
self.txtLog.append('<code>{}<code>'.format(html.escape(cmd, quote=False)))
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
def setDebugInfo(self, msg):
|
||||
if self.showDebug:
|
||||
self.setInfo('<span style="color:blue">%s</span>' % msg)
|
||||
self.txtLog.append('<span style="color:blue">{}</span>'.format(html.escape(msg, quote=False)))
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
def setConsoleInfo(self, msg):
|
||||
if self.showDebug:
|
||||
self.setCommand('<span style="color:darkgray">%s</span>' % msg)
|
||||
self.txtLog.append('<code><span style="color:darkgray">{}</span></code>'.format(html.escape(msg, quote=False)))
|
||||
QCoreApplication.processEvents()
|
||||
|
||||
def setPercentage(self, value):
|
||||
|
@ -126,12 +126,12 @@ class BatchAlgorithmDialog(AlgorithmDialogBase):
|
||||
|
||||
for count, parameters in enumerate(self.alg_parameters):
|
||||
self.setText(self.tr('\nProcessing algorithm {0}/{1}...').format(count + 1, len(self.alg_parameters)))
|
||||
self.setInfo(self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.displayName()))
|
||||
self.setInfo(self.tr('<b>Algorithm {0} starting...</b>').format(self.alg.displayName()), escape_html=False)
|
||||
ret, results = execute(self.alg, parameters, context, self.feedback)
|
||||
if ret and not self.canceled:
|
||||
if self.load[count]:
|
||||
handleAlgorithmResults(self.alg, context, self.feedback, False)
|
||||
self.setInfo(self.tr('Algorithm {0} correctly executed...').format(self.alg.displayName()))
|
||||
self.setInfo(self.tr('Algorithm {0} correctly executed...').format(self.alg.displayName()), escape_html=False)
|
||||
else:
|
||||
QApplication.restoreOverrideCursor()
|
||||
return
|
||||
|
Loading…
x
Reference in New Issue
Block a user