mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
implemented expand button showing icon and having clicked signal
This commit is contained in:
parent
13aa752c40
commit
b2f09495c4
2 changed files with 65 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ from .widgets import (
|
|||
PlaceholderLineEdit,
|
||||
BaseClickableFrame,
|
||||
ClickableFrame,
|
||||
ExpandBtn,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -9,4 +10,5 @@ __all__ = (
|
|||
"PlaceholderLineEdit",
|
||||
"BaseClickableFrame",
|
||||
"ClickableFrame",
|
||||
"ExpandBtn"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,10 @@ import logging
|
|||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
from avalon.vendor import qtawesome, qargparse
|
||||
from openpype.style import get_objected_colors
|
||||
from openpype.style import (
|
||||
get_objected_colors,
|
||||
get_style_image_path
|
||||
)
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -60,6 +63,65 @@ class ClickableFrame(BaseClickableFrame):
|
|||
self.clicked.emit()
|
||||
|
||||
|
||||
class ExpandBtnLabel(QtWidgets.QLabel):
|
||||
"""Label showing expand icon meant for ExpandBtn."""
|
||||
def __init__(self, parent):
|
||||
super(ExpandBtnLabel, self).__init__(parent)
|
||||
self._source_collapsed_pix = QtGui.QPixmap(
|
||||
get_style_image_path("branch_closed")
|
||||
)
|
||||
self._source_expanded_pix = QtGui.QPixmap(
|
||||
get_style_image_path("branch_open")
|
||||
)
|
||||
|
||||
self._current_image = self._source_collapsed_pix
|
||||
self._collapsed = True
|
||||
|
||||
def set_collapsed(self, collapsed):
|
||||
if self._collapsed == collapsed:
|
||||
return
|
||||
self._collapsed = collapsed
|
||||
if collapsed:
|
||||
self._current_image = self._source_collapsed_pix
|
||||
else:
|
||||
self._current_image = self._source_expanded_pix
|
||||
self._set_resized_pix()
|
||||
|
||||
def resizeEvent(self, event):
|
||||
self._set_resized_pix()
|
||||
super(ExpandBtnLabel, self).resizeEvent(event)
|
||||
|
||||
def _set_resized_pix(self):
|
||||
size = int(self.fontMetrics().height() / 2)
|
||||
if size < 1:
|
||||
size = 1
|
||||
size += size % 2
|
||||
self.setPixmap(
|
||||
self._current_image.scaled(
|
||||
size,
|
||||
size,
|
||||
QtCore.Qt.KeepAspectRatio,
|
||||
QtCore.Qt.SmoothTransformation
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class ExpandBtn(ClickableFrame):
|
||||
def __init__(self, parent=None):
|
||||
super(ExpandBtn, self).__init__(parent)
|
||||
|
||||
pixmap_label = ExpandBtnLabel(self)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.addWidget(pixmap_label)
|
||||
|
||||
self._pixmap_label = pixmap_label
|
||||
|
||||
def set_collapsed(self, collapsed):
|
||||
self._pixmap_label.set_collapsed(collapsed)
|
||||
|
||||
|
||||
class ImageButton(QtWidgets.QPushButton):
|
||||
"""PushButton with icon and size of font.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue