mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #2981 from pypeclub/bugfix/OP-2990_Settings-UI-Version-input-widget-is-broken-on-some-linux-dist
Settings UI: Fix version completer on linux
This commit is contained in:
commit
a9f2292f10
1 changed files with 20 additions and 9 deletions
|
|
@ -97,6 +97,9 @@ class CompleterView(QtWidgets.QListView):
|
|||
QtCore.Qt.FramelessWindowHint
|
||||
| QtCore.Qt.Tool
|
||||
)
|
||||
|
||||
# Open the widget unactivated
|
||||
self.setAttribute(QtCore.Qt.WA_ShowWithoutActivating)
|
||||
delegate = QtWidgets.QStyledItemDelegate()
|
||||
self.setItemDelegate(delegate)
|
||||
|
||||
|
|
@ -225,10 +228,18 @@ class SettingsLineEdit(PlaceholderLineEdit):
|
|||
def __init__(self, *args, **kwargs):
|
||||
super(SettingsLineEdit, self).__init__(*args, **kwargs)
|
||||
|
||||
self._completer = None
|
||||
# Timer which will get started on focus in and stopped on focus out
|
||||
# - callback checks if line edit or completer have focus
|
||||
# and hide completer if not
|
||||
focus_timer = QtCore.QTimer()
|
||||
focus_timer.setInterval(50)
|
||||
|
||||
focus_timer.timeout.connect(self._on_focus_timer)
|
||||
self.textChanged.connect(self._on_text_change)
|
||||
|
||||
self._completer = None
|
||||
self._focus_timer = focus_timer
|
||||
|
||||
def _on_text_change(self, text):
|
||||
if self._completer is not None:
|
||||
self._completer.set_text_filter(text)
|
||||
|
|
@ -240,19 +251,19 @@ class SettingsLineEdit(PlaceholderLineEdit):
|
|||
new_point = self.mapToGlobal(point)
|
||||
self._completer.move(new_point)
|
||||
|
||||
def _on_focus_timer(self):
|
||||
if not self.hasFocus() and not self._completer.hasFocus():
|
||||
self._completer.hide()
|
||||
self._focus_timer.stop()
|
||||
|
||||
def focusInEvent(self, event):
|
||||
super(SettingsLineEdit, self).focusInEvent(event)
|
||||
self.focused_in.emit()
|
||||
|
||||
if self._completer is None:
|
||||
return
|
||||
self._completer.show()
|
||||
self._update_completer()
|
||||
|
||||
def focusOutEvent(self, event):
|
||||
super(SettingsLineEdit, self).focusOutEvent(event)
|
||||
if self._completer is not None:
|
||||
self._completer.hide()
|
||||
self._focus_timer.start()
|
||||
self._completer.show()
|
||||
self._update_completer()
|
||||
|
||||
def paintEvent(self, event):
|
||||
super(SettingsLineEdit, self).paintEvent(event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue