From 7cb0be0806dca76c96dce752da6b3dd2fef0e70a Mon Sep 17 00:00:00 2001 From: Alexander Bruy Date: Wed, 2 Oct 2013 17:05:34 +0300 Subject: [PATCH] [processing] use QtDesigner ui file for Edit rendering styles dialog --- .../gui/EditRenderingStylesDialog.py | 69 +++++---------- .../processing/ui/DlgRenderingStyles.ui | 87 +++++++++++++++++++ .../processing/ui/ui_DlgRenderingStyles.py | 52 +++++++++++ 3 files changed, 162 insertions(+), 46 deletions(-) create mode 100644 python/plugins/processing/ui/DlgRenderingStyles.ui create mode 100644 python/plugins/processing/ui/ui_DlgRenderingStyles.py diff --git a/python/plugins/processing/gui/EditRenderingStylesDialog.py b/python/plugins/processing/gui/EditRenderingStylesDialog.py index f4deee0afb0..b80be8e9e2d 100644 --- a/python/plugins/processing/gui/EditRenderingStylesDialog.py +++ b/python/plugins/processing/gui/EditRenderingStylesDialog.py @@ -27,54 +27,30 @@ __revision__ = '$Format:%H$' from PyQt4.QtCore import * from PyQt4.QtGui import * -from PyQt4 import QtCore, QtGui + from processing.gui.RenderingStyles import RenderingStyles from processing.gui.RenderingStyleFilePanel import RenderingStyleFilePanel from processing.outputs.OutputRaster import OutputRaster from processing.outputs.OutputVector import OutputVector +from processing.ui.ui_DlgRenderingStyles import Ui_DlgRenderingStyles -class EditRenderingStylesDialog(QtGui.QDialog): + +class EditRenderingStylesDialog(QDialog, Ui_DlgRenderingStyles): def __init__(self, alg): - QtGui.QDialog.__init__(self) - self.setModal(True) - self.alg = alg - self.setupUi() + QDialog.__init__(self) + self.setupUi(self) + + self.alg = alg + + self.setModal(True) + self.tblStyles.horizontalHeader().setResizeMode(QHeaderView.Stretch) + self.setWindowTitle(self.alg.name) - def setupUi(self): self.valueItems = {} self.dependentItems = {} - self.resize(650, 450) - self.buttonBox = QtGui.QDialogButtonBox() - self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel - | QtGui.QDialogButtonBox.Ok) - self.tableWidget = QtGui.QTableWidget() - self.tableWidget.setSelectionMode(QtGui.QAbstractItemView.NoSelection) - self.tableWidget.setColumnCount(2) - self.tableWidget.setColumnWidth(0, 300) - self.tableWidget.setColumnWidth(1, 300) - self.tableWidget.setHorizontalHeaderItem(0, - QtGui.QTableWidgetItem('Output')) - self.tableWidget.setHorizontalHeaderItem(1, - QtGui.QTableWidgetItem('Style')) - self.tableWidget.verticalHeader().setVisible(False) - self.tableWidget.horizontalHeader().setResizeMode( - QtGui.QHeaderView.Stretch) self.setTableContent() - self.setWindowTitle(self.alg.name) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setSpacing(2) - self.verticalLayout.setMargin(0) - self.verticalLayout.addWidget(self.tableWidget) - self.verticalLayout.addWidget(self.buttonBox) - self.setLayout(self.verticalLayout) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'), - self.okPressed) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'), - self.cancelPressed) - QtCore.QMetaObject.connectSlotsByName(self) def setTableContent(self): numOutputs = 0 @@ -82,16 +58,16 @@ class EditRenderingStylesDialog(QtGui.QDialog): if isinstance(output, (OutputVector, OutputRaster)): if not output.hidden: numOutputs += 1 - self.tableWidget.setRowCount(numOutputs) + self.tblStyles.setRowCount(numOutputs) i = 0 for output in self.alg.outputs: if isinstance(output, (OutputVector, OutputRaster)): if not output.hidden: - item = QtGui.QTableWidgetItem(output.description + '<' + item = QTableWidgetItem(output.description + '<' + output.__module__.split('.')[-1] + '>') - item.setFlags(QtCore.Qt.ItemIsEnabled) - self.tableWidget.setItem(i, 0, item) + item.setFlags(Qt.ItemIsEnabled) + self.tblStyles.setItem(i, 0, item) item = RenderingStyleFilePanel() style = \ RenderingStyles.getStyle(self.alg.commandLineName(), @@ -99,16 +75,17 @@ class EditRenderingStylesDialog(QtGui.QDialog): if style: item.setText(str(style)) self.valueItems[output.name] = item - self.tableWidget.setCellWidget(i, 1, item) - self.tableWidget.setRowHeight(i, 22) + self.tblStyles.setCellWidget(i, 1, item) + self.tblStyles.setRowHeight(i, 22) i += 1 - def okPressed(self): + def accepted(self): styles = {} for key in self.valueItems.keys(): styles[key] = str(self.valueItems[key].getValue()) RenderingStyles.addAlgStylesAndSave(self.alg.commandLineName(), styles) - self.close() - def cancelPressed(self): - self.close() + QDialog.accept(self) + + def rejected(self): + QDialog.reject(self) diff --git a/python/plugins/processing/ui/DlgRenderingStyles.ui b/python/plugins/processing/ui/DlgRenderingStyles.ui new file mode 100644 index 00000000000..e96519354f5 --- /dev/null +++ b/python/plugins/processing/ui/DlgRenderingStyles.ui @@ -0,0 +1,87 @@ + + + DlgRenderingStyles + + + + 0 + 0 + 550 + 400 + + + + Dialog + + + + 2 + + + 0 + + + + + false + + + + Output + + + + + Style + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DlgRenderingStyles + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DlgRenderingStyles + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/python/plugins/processing/ui/ui_DlgRenderingStyles.py b/python/plugins/processing/ui/ui_DlgRenderingStyles.py new file mode 100644 index 00000000000..e4a829b6d32 --- /dev/null +++ b/python/plugins/processing/ui/ui_DlgRenderingStyles.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- + +# Form implementation generated from reading ui file 'python/plugins/processing/ui/DlgRenderingStyles.ui' +# +# Created: Wed Oct 2 17:04:59 2013 +# by: PyQt4 UI code generator 4.9.1 +# +# WARNING! All changes made in this file will be lost! + +from PyQt4 import QtCore, QtGui + +try: + _fromUtf8 = QtCore.QString.fromUtf8 +except AttributeError: + _fromUtf8 = lambda s: s + +class Ui_DlgRenderingStyles(object): + def setupUi(self, DlgRenderingStyles): + DlgRenderingStyles.setObjectName(_fromUtf8("DlgRenderingStyles")) + DlgRenderingStyles.resize(550, 400) + self.verticalLayout = QtGui.QVBoxLayout(DlgRenderingStyles) + self.verticalLayout.setSpacing(2) + self.verticalLayout.setMargin(0) + self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) + self.tblStyles = QtGui.QTableWidget(DlgRenderingStyles) + self.tblStyles.setObjectName(_fromUtf8("tblStyles")) + self.tblStyles.setColumnCount(2) + self.tblStyles.setRowCount(0) + item = QtGui.QTableWidgetItem() + self.tblStyles.setHorizontalHeaderItem(0, item) + item = QtGui.QTableWidgetItem() + self.tblStyles.setHorizontalHeaderItem(1, item) + self.tblStyles.verticalHeader().setVisible(False) + self.verticalLayout.addWidget(self.tblStyles) + self.buttonBox = QtGui.QDialogButtonBox(DlgRenderingStyles) + self.buttonBox.setOrientation(QtCore.Qt.Horizontal) + self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) + self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.verticalLayout.addWidget(self.buttonBox) + + self.retranslateUi(DlgRenderingStyles) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), DlgRenderingStyles.accept) + QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), DlgRenderingStyles.reject) + QtCore.QMetaObject.connectSlotsByName(DlgRenderingStyles) + + def retranslateUi(self, DlgRenderingStyles): + DlgRenderingStyles.setWindowTitle(QtGui.QApplication.translate("DlgRenderingStyles", "Dialog", None, QtGui.QApplication.UnicodeUTF8)) + item = self.tblStyles.horizontalHeaderItem(0) + item.setText(QtGui.QApplication.translate("DlgRenderingStyles", "Output", None, QtGui.QApplication.UnicodeUTF8)) + item = self.tblStyles.horizontalHeaderItem(1) + item.setText(QtGui.QApplication.translate("DlgRenderingStyles", "Style", None, QtGui.QApplication.UnicodeUTF8)) +