Dynamically set range of spinbox for config value

This commit is contained in:
Kovid Goyal 2024-08-25 20:35:32 +05:30
parent cfba2cbdd5
commit 1b6465d2ac
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -96,6 +96,7 @@ class ConfigWidget(QWidget):
if opt.type == 'number': if opt.type == 'number':
c = QSpinBox if isinstance(opt.default, numbers.Integral) else QDoubleSpinBox c = QSpinBox if isinstance(opt.default, numbers.Integral) else QDoubleSpinBox
widget = c(self) widget = c(self)
widget.setRange(min(widget.minimum(), 20 * val), max(widget.maximum(), 20 * val))
widget.setValue(val) widget.setValue(val)
elif opt.type == 'string': elif opt.type == 'string':
widget = QLineEdit(self) widget = QLineEdit(self)