Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] gui.lineEdit: Restore changed state tracking #1630

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions Orange/widgets/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,18 +779,31 @@ def __init__(self, parent, callback, focusInCallback=None):
self.callback = callback
self.focusInCallback = focusInCallback
self.returnPressed.connect(self.returnPressedHandler)
# did the text change between focus enter and leave
self.__changed = False
self.textEdited.connect(self.__textEdited)

def __textEdited(self):
self.__changed = True

def returnPressedHandler(self):
if hasattr(self, "cback") and self.cback:
self.cback(self.text())
if self.callback:
self.callback()
if self.__changed:
self.__changed = False
if hasattr(self, "cback") and self.cback:
self.cback(self.text())
if self.callback:
self.callback()

def setText(self, text):
self.__changed = False
super().setText(text)

def focusOutEvent(self, *e):
super().focusOutEvent(*e)
self.returnPressedHandler()

def focusInEvent(self, *e):
self.__changed = False
if self.focusInCallback:
self.focusInCallback()
return super().focusInEvent(*e)
Expand Down Expand Up @@ -839,24 +852,16 @@ def lineEdit(widget, master, value, label=None, labelWidth=None,
b = widgetBox(widget, box, orientation, addToLayout=False)
if label is not None:
widgetLabel(b, label, labelWidth)
hasHBox = _is_horizontal(orientation)
else:
b = widget
hasHBox = False

baseClass = misc.pop("baseClass", None)
if baseClass:
ledit = baseClass(b)
if b is not widget:
b.layout().addWidget(ledit)
elif focusInCallback or callback and not callbackOnType:
if not hasHBox:
outer = hBox(b, addToLayout=(b is not widget))
if b is widget:
b = outer
else:
outer = b
ledit = LineEditWFocusOut(outer, callback, focusInCallback)
ledit = LineEditWFocusOut(b, callback, focusInCallback)
else:
ledit = QtGui.QLineEdit(b)
if b is not widget:
Expand Down