mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
implemented combobox that can have custom text
This commit is contained in:
parent
77ffca938a
commit
81469cbc54
2 changed files with 24 additions and 0 deletions
|
|
@ -11,6 +11,28 @@ from openpype.style import (
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomTextComboBox(QtWidgets.QComboBox):
|
||||
"""Combobox which can have different text showed."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._custom_text = None
|
||||
super(CustomTextComboBox, self).__init__(*args, **kwargs)
|
||||
|
||||
def set_custom_text(self, text=None):
|
||||
if self._custom_text != text:
|
||||
self._custom_text = text
|
||||
self.repaint()
|
||||
|
||||
def paintEvent(self, event):
|
||||
painter = QtWidgets.QStylePainter(self)
|
||||
option = QtWidgets.QStyleOptionComboBox()
|
||||
self.initStyleOption(option)
|
||||
if self._custom_text is not None:
|
||||
option.currentText = self._custom_text
|
||||
painter.drawComplexControl(QtWidgets.QStyle.CC_ComboBox, option)
|
||||
painter.drawControl(QtWidgets.QStyle.CE_ComboBoxLabel, option)
|
||||
|
||||
|
||||
class PlaceholderLineEdit(QtWidgets.QLineEdit):
|
||||
"""Set placeholder color of QLineEdit in Qt 5.12 and higher."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue