Skip to content

Commit 53aa583

Browse files
committedNov 18, 2015
[processing] Use QgsDoubleSpinBox instead of QSpinBox
Allows for simple calculations in spin box, adds a reset control to reset widget to default value
1 parent 86231d7 commit 53aa583

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed
 

‎python/plugins/processing/gui/ConfigDialog.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@
3232
from PyQt4.QtCore import Qt, QEvent, QPyNullVariant
3333
from PyQt4.QtGui import (QFileDialog, QDialog, QIcon, QStyle,
3434
QStandardItemModel, QStandardItem, QMessageBox, QStyledItemDelegate,
35-
QLineEdit, QSpinBox, QDoubleSpinBox, QWidget, QToolButton, QHBoxLayout,
35+
QLineEdit, QWidget, QToolButton, QHBoxLayout,
3636
QComboBox)
37+
from qgis.gui import QgsDoubleSpinBox, QgsSpinBox
3738

3839
from processing.core.ProcessingConfig import ProcessingConfig, Setting
3940
from processing.core.Processing import Processing
@@ -198,11 +199,11 @@ def createEditor(
198199
else:
199200
value = self.convertValue(index.model().data(index, Qt.EditRole))
200201
if isinstance(value, (int, long)):
201-
spnBox = QSpinBox(parent)
202+
spnBox = QgsSpinBox(parent)
202203
spnBox.setRange(-999999999, 999999999)
203204
return spnBox
204205
elif isinstance(value, float):
205-
spnBox = QDoubleSpinBox(parent)
206+
spnBox = QgsDoubleSpinBox(parent)
206207
spnBox.setRange(-999999999.999999, 999999999.999999)
207208
spnBox.setDecimals(6)
208209
return spnBox

‎python/plugins/processing/gui/NumberInputPanel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(self, number, minimum, maximum, isInteger):
6161
self.spnValue.setMinimum(-99999999)
6262

6363
self.spnValue.setValue(float(number))
64+
self.spnValue.setClearValue(float(number))
6465

6566
self.btnCalc.clicked.connect(self.showNumberInputDialog)
6667

‎python/plugins/processing/ui/widgetNumberSelector.ui

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<number>0</number>
2222
</property>
2323
<item>
24-
<widget class="QDoubleSpinBox" name="spnValue">
24+
<widget class="QgsDoubleSpinBox" name="spnValue">
2525
<property name="decimals">
2626
<number>6</number>
2727
</property>
@@ -45,6 +45,14 @@
4545
</item>
4646
</layout>
4747
</widget>
48+
<customwidgets>
49+
<customwidget>
50+
<class>QgsDoubleSpinBox</class>
51+
<extends>QDoubleSpinBox</extends>
52+
<header>qgis.gui</header>
53+
<container>1</container>
54+
</customwidget>
55+
</customwidgets>
4856
<resources/>
4957
<connections/>
5058
</ui>

0 commit comments

Comments
 (0)
Please sign in to comment.