added placeholder widget fixing color of placeholder

This commit is contained in:
iLLiCiTiT 2021-11-18 12:13:08 +01:00
parent b50f91dc3f
commit 3a6e1bff54

View file

@ -7,6 +7,7 @@ from Qt import QtWidgets, QtCore, QtGui
from avalon.vendor import qtawesome, qargparse
from avalon import style
from openpype.style import get_objected_colors
from .models import AssetModel, RecursiveSortFilterProxyModel
from .views import AssetsView
@ -15,6 +16,28 @@ from .delegates import AssetDelegate
log = logging.getLogger(__name__)
class PlaceholderLineEdit(QtWidgets.QLineEdit):
"""Set placeholder color of QLineEdit in Qt 5.12 and higher."""
def __init__(self, *args, **kwargs):
super(PlaceholderLineEdit, self).__init__(*args, **kwargs)
self._first_show = True
def showEvent(self, event):
super(PlaceholderLineEdit, self).showEvent(event)
if self._first_show:
self._first_show = False
filter_palette = self.palette()
if hasattr(filter_palette, "PlaceholderText"):
color_obj = get_objected_colors()["font"]
color = color_obj.get_qcolor()
color.setAlpha(67)
filter_palette.setColor(
filter_palette.PlaceholderText,
color
)
self.setPalette(filter_palette)
class AssetWidget(QtWidgets.QWidget):
"""A Widget to display a tree of assets with filter