Skip to content

Commit

Permalink
[processing] Use QgsDoubleSpinBox instead of QSpinBox
Browse files Browse the repository at this point in the history
Allows for simple calculations in spin box, adds a reset control
to reset widget to default value
  • Loading branch information
nyalldawson committed Nov 18, 2015
1 parent 86231d7 commit 53aa583
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
7 changes: 4 additions & 3 deletions python/plugins/processing/gui/ConfigDialog.py
Expand Up @@ -32,8 +32,9 @@
from PyQt4.QtCore import Qt, QEvent, QPyNullVariant
from PyQt4.QtGui import (QFileDialog, QDialog, QIcon, QStyle,
QStandardItemModel, QStandardItem, QMessageBox, QStyledItemDelegate,
QLineEdit, QSpinBox, QDoubleSpinBox, QWidget, QToolButton, QHBoxLayout,
QLineEdit, QWidget, QToolButton, QHBoxLayout,
QComboBox)
from qgis.gui import QgsDoubleSpinBox, QgsSpinBox

from processing.core.ProcessingConfig import ProcessingConfig, Setting
from processing.core.Processing import Processing
Expand Down Expand Up @@ -198,11 +199,11 @@ def createEditor(
else:
value = self.convertValue(index.model().data(index, Qt.EditRole))
if isinstance(value, (int, long)):
spnBox = QSpinBox(parent)
spnBox = QgsSpinBox(parent)
spnBox.setRange(-999999999, 999999999)
return spnBox
elif isinstance(value, float):
spnBox = QDoubleSpinBox(parent)
spnBox = QgsDoubleSpinBox(parent)
spnBox.setRange(-999999999.999999, 999999999.999999)
spnBox.setDecimals(6)
return spnBox
Expand Down
1 change: 1 addition & 0 deletions python/plugins/processing/gui/NumberInputPanel.py
Expand Up @@ -61,6 +61,7 @@ def __init__(self, number, minimum, maximum, isInteger):
self.spnValue.setMinimum(-99999999)

self.spnValue.setValue(float(number))
self.spnValue.setClearValue(float(number))

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

Expand Down
10 changes: 9 additions & 1 deletion python/plugins/processing/ui/widgetNumberSelector.ui
Expand Up @@ -21,7 +21,7 @@
<number>0</number>
</property>
<item>
<widget class="QDoubleSpinBox" name="spnValue">
<widget class="QgsDoubleSpinBox" name="spnValue">
<property name="decimals">
<number>6</number>
</property>
Expand All @@ -45,6 +45,14 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header>qgis.gui</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

0 comments on commit 53aa583

Please sign in to comment.