Skip to content

Commit

Permalink
Update tests and change defaults for UISlider classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcornall committed Jan 3, 2025
1 parent 1545425 commit 0545d59
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
12 changes: 8 additions & 4 deletions eqt/ui/UIFormWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ def getWidgetState(self, widget, role=None):
widget_state['value'] = widget.isChecked()
elif isinstance(widget, QtWidgets.QComboBox):
widget_state['value'] = widget.currentIndex()
elif isinstance(widget, UISliderWidget) or isinstance(widget, UISliderLEditWidget):
widget_state['value'] = widget.getValue()
elif isinstance(widget, QtWidgets.QSlider):
elif isinstance(widget, UISliderWidget) or isinstance(widget, QtWidgets.QSlider):
widget_state['value'] = widget.value()
elif isinstance(widget, (QtWidgets.QDoubleSpinBox, QtWidgets.QSpinBox)):
widget_state['value'] = widget.value()
Expand All @@ -338,6 +336,9 @@ def getWidgetState(self, widget, role=None):
widget_state['value'] = widget.isChecked()
elif isinstance(widget, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit)):
widget_state['value'] = widget.toPlainText()
elif isinstance(widget, UISliderLEditWidget) or isinstance(widget, QtWidgets.QWidget):
widget_state['value'] = widget.getValue()
# isinstance(QWidget) must be last due to other QtWidgets inheriting from it
widget_state['enabled'] = widget.isEnabled()
widget_state['visible'] = widget.isVisible()
widget_state['widget_row'] = self.getWidgetRow(name, role)
Expand Down Expand Up @@ -411,7 +412,7 @@ def applyWidgetState(self, name, state, role=None):
widget.setChecked(value)
elif isinstance(widget, QtWidgets.QComboBox):
widget.setCurrentIndex(value)
elif isinstance(widget, (UISliderWidget, UISliderLEditWidget, QtWidgets.QSlider)):
elif isinstance(widget, (UISliderWidget, QtWidgets.QSlider)):
widget.setValue(value)
elif isinstance(widget, (QtWidgets.QDoubleSpinBox, QtWidgets.QSpinBox)):
widget.setValue(value)
Expand All @@ -423,6 +424,9 @@ def applyWidgetState(self, name, state, role=None):
widget.setChecked(value)
elif isinstance(widget, (QtWidgets.QTextEdit, QtWidgets.QPlainTextEdit)):
widget.setPlainText(value)
elif isinstance(widget, (UISliderLEditWidget, QtWidgets.QWidget)):
widget.setValue(value)
# isinstance(QWidget) must be last due to other QtWidgets inheriting from it

def applyWidgetStates(self, states):
'''
Expand Down
2 changes: 1 addition & 1 deletion eqt/ui/UISliderLEditWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UISliderLEditWidget(QWidget):
step_size : float
scale_factor : float
'''
def __init__(self, minimum=0.0, maximum=1.0, step_size=1.0, scale_factor=1.0,
def __init__(self, minimum=0.0, maximum=10.0, step_size=1.0, scale_factor=1.0,
tick_interval=1.0):
QWidget.__init__(self)

Expand Down
5 changes: 1 addition & 4 deletions eqt/ui/UISliderWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UISliderWidget(QSlider):
step_size : float
scale_factor : float
'''
def __init__(self, line_edit, max_label, minimum=0.0, maximum=1.0, scale_factor=1.0,
def __init__(self, line_edit, max_label, minimum=0.0, maximum=10.0, scale_factor=1.0,
step_size=1.0, tick_interval=1.0):
QSlider.__init__(self)

Expand Down Expand Up @@ -63,9 +63,6 @@ def __init__(self, line_edit, max_label, minimum=0.0, maximum=1.0, scale_factor=
self.max_label.setAlignment(QtCore.Qt.AlignRight)
self.max_label.setText(str(self.maximum))

def getValue(self):
return self.getLineEditValue()

def getSliderValue(self):
return self.value()

Expand Down
2 changes: 1 addition & 1 deletion test/test__formUI_status_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def test_getWidgetState_returns_UISliderLEditWidget_value(self):
self.form.getWidgetState('uiSliderLEditWidget_field')['value'], initial_slider_value)

final_slider_value = 1
self.form.getWidget('UISliderLEditWidget').setValue(final_slider_value)
self.form.getWidget('uiSliderLEditWidget').setValue(final_slider_value)

self.assertEqual(
self.form.getWidgetState('uiSliderLEditWidget_field')['value'], final_slider_value)
Expand Down

0 comments on commit 0545d59

Please sign in to comment.