mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[processing] use QgsMessage bar in algorithm dialogs
This commit is contained in:
parent
56225c4d8c
commit
5464c4501b
@ -29,9 +29,10 @@ __revision__ = '$Format:%H$'
|
||||
|
||||
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 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
|
||||
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 @@ class AlgorithmDialog(AlgorithmDialogBase):
|
||||
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.QtGui import QIcon
|
||||
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 @@ class BatchPanel(BASE, WIDGET):
|
||||
self.fillParameterValues)
|
||||
|
||||
self.initWidgets()
|
||||
|
||||
|
||||
|
||||
|
||||
def layerRegistryChanged(self):
|
||||
pass
|
||||
|
||||
@ -192,8 +193,9 @@ class BatchPanel(BASE, WIDGET):
|
||||
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 @@ class BatchPanel(BASE, WIDGET):
|
||||
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 @@ class BatchPanel(BASE, WIDGET):
|
||||
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 processing.core.alglist import algList
|
||||
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 @@ class PreconfiguredAlgorithmDialog(AlgorithmDialog):
|
||||
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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user