Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Display execution dialog log in unthreaded mode if "keep open" option…
… is activated. Also make algorithm error messages non-modal, less obtrusive.

git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@341 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
cpolymeris@gmail.com committed Aug 10, 2012
1 parent f6f6124 commit 12c014e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/sextante/gui/AlgorithmExecutionDialog.py
Expand Up @@ -69,7 +69,9 @@ def __init__(self, alg, mainWidget):
self.verticalLayout.addWidget(self.tabWidget)
self.logText = QTextEdit()
self.logText.readOnly = True
if SextanteConfig.getSetting(SextanteConfig.USE_THREADS):
useThreads = SextanteConfig.getSetting(SextanteConfig.USE_THREADS)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if useThreads or keepOpen:
self.tabWidget.addTab(self.logText, "Log")
self.webView = QtWebKit.QWebView()
cssUrl = QtCore.QUrl(os.path.join(os.path.dirname(__file__), "help", "help.css"))
Expand Down Expand Up @@ -213,8 +215,8 @@ def accept(self):
self.algEx.start()
self.setInfo("<b>Algorithm %s started</b>" % self.alg.name)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(True)
self.tabWidget.setCurrentIndex(1) # log tab
else:
self.setInfo("<b>Algorithm %s starting...</b>" % self.alg.name)
if iterateParam:
UnthreadedAlgorithmExecutor.runalgIterating(self.alg, iterateParam, self)
else:
Expand All @@ -235,6 +237,7 @@ def accept(self):
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Cancel).setEnabled(False)
self.tabWidget.setCurrentIndex(1) # log tab
else:
QMessageBox.critical(self, "Unable to execute algorithm", "Wrong or missing parameter values")

Expand All @@ -259,13 +262,13 @@ def finish(self):
def error(self, msg):
self.algEx.finished.disconnect()
QApplication.restoreOverrideCursor()
self.setInfo(msg, True)
QMessageBox.critical(self, "Error", msg)
keepOpen = SextanteConfig.getSetting(SextanteConfig.KEEP_DIALOG_OPEN)
if not keepOpen:
self.setInfo(msg, True)
if not SextanteConfig.USE_THREADS and not keepOpen:
QMessageBox.critical(self, "Error", msg)
self.close()
else:
self.progressLabel.setText("")
self.progressLabel.setText("Error: " + msg)
self.progress.setValue(0)
self.buttonBox.button(QtGui.QDialogButtonBox.Ok).setEnabled(True)
self.buttonBox.button(QtGui.QDialogButtonBox.Close).setEnabled(True)
Expand All @@ -291,10 +294,8 @@ def cancel(self):
@pyqtSlot(str, bool)
def setInfo(self, msg, error = False):
if error:
#SextanteLog.addToLog(SextanteLog.LOG_ERROR, msg)
self.logText.append('<span style="color:red">' + msg + '</span>')
else:
#SextanteLog.addToLog(SextanteLog.LOG_INFO, msg)
self.logText.append(msg)

@pyqtSlot(str)
Expand Down

0 comments on commit 12c014e

Please sign in to comment.