Skip to content
Permalink
Browse files

[processing] use QgsMessage bar in algorithm dialogs

  • Loading branch information
volaya committed Oct 5, 2016
1 parent 56225c4 commit 5464c4501b214ca2da0911967c92bd21e67226b8
@@ -29,9 +29,10 @@

from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtWidgets import QMessageBox, QApplication, QPushButton, QWidget, QVBoxLayout
from qgis.PyQt.QtGui import QCursor, QColor, QPalette
from qgis.PyQt.QtGui import QCursor, QColor, QPalette, QSizePolicy

from qgis.core import QgsMapLayerRegistry
from qgis.gui import QgsMessageBar

from processing.core.ProcessingLog import ProcessingLog
from processing.core.ProcessingConfig import ProcessingConfig
@@ -71,6 +72,10 @@ def __init__(self, alg):

self.setMainWidget(ParametersPanel(self, alg))

self.bar = QgsMessageBar()
self.bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
self.layout().insertWidget(0, self.bar)

self.cornerWidget = QWidget()
layout = QVBoxLayout()
layout.setContentsMargins(0, 0, 0, 5)
@@ -179,13 +184,11 @@ def accept(self):
palette = e.widget.palette()
palette.setColor(QPalette.Base, QColor(255, 255, 0))
e.widget.setPalette(palette)
self.lblProgress.setText(
self.tr('<b>Missing parameter value: %s</b>') % e.parameter.description)
return
except:
QMessageBox.critical(self,
self.tr('Unable to execute algorithm'),
self.tr('Wrong or missing parameter values'))
pass
self.bar.clearWidgets()
self.bar.pushMessage("", "Wrong or missing parameter value: %s" % e.parameter.description,
level=QgsMessageBar.WARNING, duration=5)

def finish(self):
keepOpen = ProcessingConfig.getSetting(ProcessingConfig.KEEP_DIALOG_OPEN)
@@ -35,6 +35,7 @@
from qgis.PyQt.QtWidgets import QTableWidgetItem, QComboBox, QLineEdit, QHeaderView, QFileDialog, QMessageBox

from qgis.core import QgsApplication
from qgis.gui import QgsMessageBar

from processing.gui.BatchOutputSelectionPanel import BatchOutputSelectionPanel
from processing.gui.GeometryPredicateSelectionPanel import GeometryPredicateSelectionPanel
@@ -88,8 +89,8 @@ def __init__(self, parent, alg):
self.fillParameterValues)

self.initWidgets()


def layerRegistryChanged(self):
pass

@@ -192,8 +193,9 @@ def save(self):
continue
wrapper = self.wrappers[row][col]
if not self.setParamValue(param, wrapper, alg):
self.parent.lblProgress.setText(
self.tr('<b>Missing parameter value: %s (row %d)</b>') % (param.description, row + 1))
self.parent.bar.pushMessage("", self.tr('Wrong or missing parameter value: %s (row %d)')
% (param.description, row + 1),
level=QgsMessageBar.WARNING, duration=5)
return
algParams[param.name] = param.getValueAsCommandLineParameter()
col += 1
@@ -206,8 +208,9 @@ def save(self):
algOutputs[out.name] = text.strip()
col += 1
else:
self.parent.lblProgress.setText(
self.tr('<b>Wrong or missing parameter value: %s (row %d)</b>') % (out.description, row + 1))
self.parent.bar.pushMessage("", self.tr('Wrong or missing output value: %s (row %d)')
% (out.description, row + 1),
level=QgsMessageBar.WARNING, duration=5)
return
toSave.append({self.PARAMETERS: algParams, self.OUTPUTS: algOutputs})

@@ -267,7 +270,7 @@ def fillParameterValues(self, column):
wrapper = self.wrappers[0][column]
for row in range(1, self.tblParameters.rowCount()):
self.wrappers[row][column].setValue(wrapper.value())

def toggleAdvancedMode(self, checked):
for column, param in enumerate(self.alg.parameters):
if param.isAdvanced:
@@ -38,6 +38,8 @@
from qgis.PyQt.QtWidgets import QMessageBox, QVBoxLayout, QLabel, QLineEdit, QWidget
from qgis.PyQt.QtGui import QPalette, QColor

from qgis.gui import QgsMessageBar


class PreconfiguredAlgorithmDialog(AlgorithmDialog):

@@ -77,8 +79,9 @@ def accept(self):
palette = e.widget.palette()
palette.setColor(QPalette.Base, QColor(255, 255, 0))
e.widget.setPalette(palette)
self.lblProgress.setText(
self.tr('<b>Missing parameter value: %s</b>') % e.parameter.description)
self.parent.bar.pushMessage("", self.tr('Missing parameter value: %s')
% e.parameter.description,
level=QgsMessageBar.WARNING, duration=5)
return
except:
QMessageBox.critical(self,

0 comments on commit 5464c45

Please sign in to comment.
You can’t perform that action at this time.