mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
action button has icon if action has icon
This commit is contained in:
parent
714cdb35e7
commit
48b72d892f
2 changed files with 39 additions and 9 deletions
|
|
@ -737,6 +737,22 @@ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
|
|||
font-size: 13pt;
|
||||
}
|
||||
|
||||
#ValidationActionButton {
|
||||
border: 1px solid transparent;
|
||||
border-radius: 0.2em;
|
||||
padding: 4px 6px 4px 6px;
|
||||
background: {color:bg-buttons};
|
||||
}
|
||||
|
||||
#ValidationActionButton:hover {
|
||||
background: {color:bg-button-hover};
|
||||
color: {color:font-hover};
|
||||
}
|
||||
|
||||
#ValidationActionButton:disabled {
|
||||
background: {color:bg-buttons-disabled};
|
||||
}
|
||||
|
||||
#ValidationErrorTitleFrame {
|
||||
background: {color:bg-inputs};
|
||||
border-left: 4px solid transparent;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ except Exception:
|
|||
|
||||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
from .widgets import ClickableFrame
|
||||
from .widgets import (
|
||||
ClickableFrame,
|
||||
IconValuePixmapLabel
|
||||
)
|
||||
|
||||
|
||||
class ValidationErrorInstanceList(QtWidgets.QListView):
|
||||
|
|
@ -142,22 +145,33 @@ class ValidationErrorTitleWidget(QtWidgets.QWidget):
|
|||
self._toggle_instance_btn.setArrowType(QtCore.Qt.RightArrow)
|
||||
|
||||
|
||||
class ActionButton(QtWidgets.QPushButton):
|
||||
class ActionButton(ClickableFrame):
|
||||
action_clicked = QtCore.Signal(str)
|
||||
|
||||
def __init__(self, action, parent):
|
||||
super(ActionButton, self).__init__(parent)
|
||||
|
||||
action_label = action.label or action.__name__
|
||||
self.setText(action_label)
|
||||
|
||||
# TODO handle icons
|
||||
# action.icon
|
||||
self.setObjectName("ValidationActionButton")
|
||||
|
||||
self.action = action
|
||||
self.clicked.connect(self._on_click)
|
||||
|
||||
def _on_click(self):
|
||||
action_label = action.label or action.__name__
|
||||
action_icon = getattr(action, "icon", None)
|
||||
label_widget = QtWidgets.QLabel(action_label, self)
|
||||
if action_icon:
|
||||
icon_label = IconValuePixmapLabel(action_icon, self)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(5, 0, 5, 0)
|
||||
layout.addWidget(label_widget, 1)
|
||||
layout.addWidget(icon_label, 0)
|
||||
|
||||
self.setSizePolicy(
|
||||
QtWidgets.QSizePolicy.Minimum,
|
||||
self.sizePolicy().verticalPolicy()
|
||||
)
|
||||
|
||||
def _mouse_release_callback(self):
|
||||
self.action_clicked.emit(self.action.id)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue