Skip to content

Commit 60bf80c

Browse files
committed
[processing] use QtDesigner .ui for Autofill dialog
1 parent a763e28 commit 60bf80c

File tree

3 files changed

+197
-43
lines changed

3 files changed

+197
-43
lines changed

python/plugins/processing/gui/AutofillDialog.py

+21-43
Original file line numberDiff line numberDiff line change
@@ -25,63 +25,41 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28-
from PyQt4 import QtGui, QtCore
2928
from PyQt4.QtCore import *
3029
from PyQt4.QtGui import *
3130

31+
from processing.ui.ui_DlgAutofill import Ui_DlgAutofill
3232

33-
class AutofillDialog(QtGui.QDialog):
33+
34+
class AutofillDialog(QDialog, Ui_DlgAutofill):
3435

3536
DO_NOT_AUTOFILL = 0
3637
FILL_WITH_NUMBERS = 1
3738
FILL_WITH_PARAMETER = 2
3839

3940
def __init__(self, alg):
40-
QtGui.QDialog.__init__(self)
41+
QDialog.__init__(self)
42+
self.setupUi(self)
4143

42-
self.verticalLayout = QtGui.QVBoxLayout(self)
43-
self.verticalLayout.setSpacing(40)
44-
self.verticalLayout.setMargin(20)
45-
self.horizontalLayout = QtGui.QHBoxLayout(self)
46-
self.horizontalLayout.setSpacing(2)
47-
self.horizontalLayout.setMargin(0)
48-
self.label = QtGui.QLabel('Autofill mode')
49-
self.horizontalLayout.addWidget(self.label)
50-
self.typeCombo = QtGui.QComboBox()
51-
self.typeCombo.addItem('Do not autofill')
52-
self.typeCombo.addItem('Fill with numbers')
53-
self.typeCombo.addItem('Fill with parameter values')
54-
self.horizontalLayout.addWidget(self.typeCombo)
55-
self.verticalLayout.addLayout(self.horizontalLayout)
56-
self.horizontalLayout2 = QtGui.QHBoxLayout(self)
57-
self.horizontalLayout2.setSpacing(2)
58-
self.horizontalLayout2.setMargin(0)
59-
self.label2 = QtGui.QLabel('Parameter to use')
60-
self.horizontalLayout2.addWidget(self.label2)
61-
self.fieldCombo = QtGui.QComboBox()
62-
for param in alg.parameters:
63-
self.fieldCombo.addItem(param.description)
64-
self.horizontalLayout2.addWidget(self.fieldCombo)
65-
self.verticalLayout.addLayout(self.horizontalLayout2)
44+
self.cmbFillType.currentIndexChanged.connect(self.toggleParameters)
6645

67-
self.buttonBox = QtGui.QDialogButtonBox(self)
68-
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
69-
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
70-
| QtGui.QDialogButtonBox.Ok)
71-
QObject.connect(self.buttonBox, QtCore.SIGNAL('accepted()'),
72-
self.okPressed)
73-
QObject.connect(self.buttonBox, QtCore.SIGNAL('rejected()'),
74-
self.cancelPressed)
75-
self.verticalLayout.addWidget(self.buttonBox)
46+
for param in alg.parameters:
47+
self.cmbParameters.addItem(param.description)
7648

77-
self.setLayout(self.verticalLayout)
49+
def toggleParameters(self, index):
50+
if index == self.FILL_WITH_PARAMETER:
51+
self.lblParameters.setEnabled(True)
52+
self.cmbParameters.setEnabled(True)
53+
else:
54+
self.lblParameters.setEnabled(False)
55+
self.cmbParameters.setEnabled(False)
7856

79-
def okPressed(self):
80-
self.mode = self.typeCombo.currentIndex()
81-
self.param = self.fieldCombo.currentIndex()
82-
self.close()
57+
def accept(self):
58+
self.mode = self.cmbFillType.currentIndex()
59+
self.param = self.cmbParameters.currentIndex()
60+
QDialog.accept(self)
8361

84-
def cancelPressed(self):
62+
def reject(self):
8563
self.mode = None
8664
self.param = None
87-
self.close()
65+
QDialog.reject(self)
+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>DlgAutofill</class>
4+
<widget class="QDialog" name="DlgAutofill">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>104</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Autofill settings</string>
15+
</property>
16+
<layout class="QGridLayout" name="gridLayout">
17+
<item row="0" column="0">
18+
<widget class="QLabel" name="label">
19+
<property name="text">
20+
<string>Autofill mode</string>
21+
</property>
22+
</widget>
23+
</item>
24+
<item row="0" column="1">
25+
<widget class="QComboBox" name="cmbFillType">
26+
<item>
27+
<property name="text">
28+
<string>Do not autofill</string>
29+
</property>
30+
</item>
31+
<item>
32+
<property name="text">
33+
<string>Fill with numbers</string>
34+
</property>
35+
</item>
36+
<item>
37+
<property name="text">
38+
<string>Fill with parameter values</string>
39+
</property>
40+
</item>
41+
</widget>
42+
</item>
43+
<item row="1" column="0">
44+
<widget class="QLabel" name="lblParameters">
45+
<property name="enabled">
46+
<bool>false</bool>
47+
</property>
48+
<property name="text">
49+
<string>Parameter to use</string>
50+
</property>
51+
</widget>
52+
</item>
53+
<item row="1" column="1">
54+
<widget class="QComboBox" name="cmbParameters">
55+
<property name="enabled">
56+
<bool>false</bool>
57+
</property>
58+
<property name="sizePolicy">
59+
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
60+
<horstretch>0</horstretch>
61+
<verstretch>0</verstretch>
62+
</sizepolicy>
63+
</property>
64+
</widget>
65+
</item>
66+
<item row="2" column="0" colspan="2">
67+
<widget class="QDialogButtonBox" name="buttonBox">
68+
<property name="orientation">
69+
<enum>Qt::Horizontal</enum>
70+
</property>
71+
<property name="standardButtons">
72+
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
73+
</property>
74+
</widget>
75+
</item>
76+
</layout>
77+
</widget>
78+
<resources/>
79+
<connections>
80+
<connection>
81+
<sender>buttonBox</sender>
82+
<signal>accepted()</signal>
83+
<receiver>DlgAutofill</receiver>
84+
<slot>accept()</slot>
85+
<hints>
86+
<hint type="sourcelabel">
87+
<x>248</x>
88+
<y>254</y>
89+
</hint>
90+
<hint type="destinationlabel">
91+
<x>157</x>
92+
<y>274</y>
93+
</hint>
94+
</hints>
95+
</connection>
96+
<connection>
97+
<sender>buttonBox</sender>
98+
<signal>rejected()</signal>
99+
<receiver>DlgAutofill</receiver>
100+
<slot>reject()</slot>
101+
<hints>
102+
<hint type="sourcelabel">
103+
<x>316</x>
104+
<y>260</y>
105+
</hint>
106+
<hint type="destinationlabel">
107+
<x>286</x>
108+
<y>274</y>
109+
</hint>
110+
</hints>
111+
</connection>
112+
</connections>
113+
</ui>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# -*- coding: utf-8 -*-
2+
3+
# Form implementation generated from reading ui file 'python/plugins/processing/ui/DlgAutofill.ui'
4+
#
5+
# Created: Wed Oct 2 20:49:45 2013
6+
# by: PyQt4 UI code generator 4.9.1
7+
#
8+
# WARNING! All changes made in this file will be lost!
9+
10+
from PyQt4 import QtCore, QtGui
11+
12+
try:
13+
_fromUtf8 = QtCore.QString.fromUtf8
14+
except AttributeError:
15+
_fromUtf8 = lambda s: s
16+
17+
class Ui_DlgAutofill(object):
18+
def setupUi(self, DlgAutofill):
19+
DlgAutofill.setObjectName(_fromUtf8("DlgAutofill"))
20+
DlgAutofill.resize(400, 104)
21+
self.gridLayout = QtGui.QGridLayout(DlgAutofill)
22+
self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
23+
self.label = QtGui.QLabel(DlgAutofill)
24+
self.label.setObjectName(_fromUtf8("label"))
25+
self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
26+
self.cmbFillType = QtGui.QComboBox(DlgAutofill)
27+
self.cmbFillType.setObjectName(_fromUtf8("cmbFillType"))
28+
self.cmbFillType.addItem(_fromUtf8(""))
29+
self.cmbFillType.addItem(_fromUtf8(""))
30+
self.cmbFillType.addItem(_fromUtf8(""))
31+
self.gridLayout.addWidget(self.cmbFillType, 0, 1, 1, 1)
32+
self.lblParameters = QtGui.QLabel(DlgAutofill)
33+
self.lblParameters.setEnabled(False)
34+
self.lblParameters.setObjectName(_fromUtf8("lblParameters"))
35+
self.gridLayout.addWidget(self.lblParameters, 1, 0, 1, 1)
36+
self.cmbParameters = QtGui.QComboBox(DlgAutofill)
37+
self.cmbParameters.setEnabled(False)
38+
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed)
39+
sizePolicy.setHorizontalStretch(0)
40+
sizePolicy.setVerticalStretch(0)
41+
sizePolicy.setHeightForWidth(self.cmbParameters.sizePolicy().hasHeightForWidth())
42+
self.cmbParameters.setSizePolicy(sizePolicy)
43+
self.cmbParameters.setObjectName(_fromUtf8("cmbParameters"))
44+
self.gridLayout.addWidget(self.cmbParameters, 1, 1, 1, 1)
45+
self.buttonBox = QtGui.QDialogButtonBox(DlgAutofill)
46+
self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
47+
self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok)
48+
self.buttonBox.setObjectName(_fromUtf8("buttonBox"))
49+
self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 2)
50+
51+
self.retranslateUi(DlgAutofill)
52+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), DlgAutofill.accept)
53+
QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), DlgAutofill.reject)
54+
QtCore.QMetaObject.connectSlotsByName(DlgAutofill)
55+
56+
def retranslateUi(self, DlgAutofill):
57+
DlgAutofill.setWindowTitle(QtGui.QApplication.translate("DlgAutofill", "Autofill settings", None, QtGui.QApplication.UnicodeUTF8))
58+
self.label.setText(QtGui.QApplication.translate("DlgAutofill", "Autofill mode", None, QtGui.QApplication.UnicodeUTF8))
59+
self.cmbFillType.setItemText(0, QtGui.QApplication.translate("DlgAutofill", "Do not autofill", None, QtGui.QApplication.UnicodeUTF8))
60+
self.cmbFillType.setItemText(1, QtGui.QApplication.translate("DlgAutofill", "Fill with numbers", None, QtGui.QApplication.UnicodeUTF8))
61+
self.cmbFillType.setItemText(2, QtGui.QApplication.translate("DlgAutofill", "Fill with parameter values", None, QtGui.QApplication.UnicodeUTF8))
62+
self.lblParameters.setText(QtGui.QApplication.translate("DlgAutofill", "Parameter to use", None, QtGui.QApplication.UnicodeUTF8))
63+

0 commit comments

Comments
 (0)