mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
set the placeholder on widgets
This commit is contained in:
parent
3782105fc0
commit
29dbc8b8cf
3 changed files with 17 additions and 6 deletions
|
|
@ -640,11 +640,15 @@ class EnumAttrWidget(_BaseAttrDefWidget):
|
|||
return self.attr_def.multiselection
|
||||
|
||||
def _ui_init(self):
|
||||
placeholder = self.attr_def.placeholder
|
||||
if self.multiselection:
|
||||
input_widget = MultiSelectionComboBox(self)
|
||||
input_widget = MultiSelectionComboBox(
|
||||
self, placeholder=placeholder
|
||||
)
|
||||
|
||||
else:
|
||||
input_widget = CustomTextComboBox(self)
|
||||
input_widget.set_placeholder(placeholder)
|
||||
combo_delegate = QtWidgets.QStyledItemDelegate(input_widget)
|
||||
input_widget.setItemDelegate(combo_delegate)
|
||||
self._combo_delegate = combo_delegate
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class MultiSelectionComboBox(QtWidgets.QComboBox):
|
|||
self._block_mouse_release_timer = QtCore.QTimer(self, singleShot=True)
|
||||
self._initial_mouse_pos = None
|
||||
self._separator = separator
|
||||
self._placeholder_text = placeholder
|
||||
self._placeholder_text = placeholder or ""
|
||||
delegate = ComboItemDelegate(self)
|
||||
self.setItemDelegate(delegate)
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ class MultiSelectionComboBox(QtWidgets.QComboBox):
|
|||
return self._placeholder_text
|
||||
|
||||
def set_placeholder_text(self, text):
|
||||
self._placeholder_text = text
|
||||
self._placeholder_text = text or ""
|
||||
self._update_size_hint()
|
||||
|
||||
def set_custom_text(self, text):
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class ComboBox(QtWidgets.QComboBox):
|
|||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ComboBox, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
delegate = QtWidgets.QStyledItemDelegate()
|
||||
self.setItemDelegate(delegate)
|
||||
self.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
|
|
@ -63,7 +63,7 @@ class ComboBox(QtWidgets.QComboBox):
|
|||
|
||||
def wheelEvent(self, event):
|
||||
if self.hasFocus():
|
||||
return super(ComboBox, self).wheelEvent(event)
|
||||
return super().wheelEvent(event)
|
||||
|
||||
|
||||
class CustomTextComboBox(ComboBox):
|
||||
|
|
@ -71,7 +71,14 @@ class CustomTextComboBox(ComboBox):
|
|||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._custom_text = None
|
||||
super(CustomTextComboBox, self).__init__(*args, **kwargs)
|
||||
self._placeholder = placeholder
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def set_placeholder(self, placeholder: Optional[str]):
|
||||
if placeholder == self._placeholder:
|
||||
return
|
||||
self.lineEdit().setPlaceholderText(placeholder)
|
||||
self.repaint()
|
||||
|
||||
def set_custom_text(self, text=None):
|
||||
if self._custom_text != text:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue