-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Spectra: move view range selections to visual settings
- Loading branch information
1 parent
aa28309
commit 414d52e
Showing
4 changed files
with
122 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from AnyQt.QtWidgets import QLineEdit | ||
|
||
from orangewidget.utils.visual_settings_dlg import _add_control, _set_control_value | ||
|
||
from orangecontrib.spectroscopy.widgets.gui import FloatOrEmptyValidator, floatornone, str_or_empty | ||
|
||
|
||
class FloatOrUndefined: | ||
pass | ||
|
||
|
||
class FloatOrEmptyLineEdit(QLineEdit): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
validator = FloatOrEmptyValidator(self, allow_empty=True) | ||
self.setValidator(validator) | ||
|
||
def setValue(self, value): | ||
self.setText(str_or_empty(value)) | ||
|
||
|
||
@_add_control.register(FloatOrUndefined) | ||
def _(_: FloatOrUndefined, value, key, signal): | ||
line_edit = FloatOrEmptyLineEdit() | ||
line_edit.setValue(value) | ||
line_edit.textChanged.connect(lambda text: signal.emit(key, floatornone(text))) | ||
return line_edit | ||
|
||
|
||
@_set_control_value.register(FloatOrEmptyLineEdit) | ||
def _(edit: QLineEdit, value: str): | ||
edit.setValue(value) |