mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'develop' into enhancement/AY-1411_add_plug_in_details_tab
# Conflicts: # client/ayon_core/tools/utils/__init__.py # client/ayon_core/tools/utils/widgets.py
This commit is contained in:
commit
a871c7b9c3
4 changed files with 211 additions and 100 deletions
|
|
@ -739,6 +739,31 @@ OverlayMessageWidget QWidget {
|
|||
background: transparent;
|
||||
}
|
||||
|
||||
/* Hinted Line Edit */
|
||||
HintedLineEditInput {
|
||||
border-radius: 0.2em;
|
||||
border-top-right-radius: 0px;
|
||||
border-bottom-right-radius: 0px;
|
||||
border: 1px solid {color:border};
|
||||
}
|
||||
HintedLineEditInput:hover {
|
||||
border-color: {color:border-hover};
|
||||
}
|
||||
HintedLineEditInput:focus{
|
||||
border-color: {color:border-focus};
|
||||
}
|
||||
HintedLineEditInput:disabled {
|
||||
background: {color:bg-inputs-disabled};
|
||||
}
|
||||
HintedLineEditButton {
|
||||
border: none;
|
||||
border-radius: 0.2em;
|
||||
border-bottom-left-radius: 0px;
|
||||
border-top-left-radius: 0px;
|
||||
padding: 0px;
|
||||
qproperty-iconSize: 11px 11px;
|
||||
}
|
||||
|
||||
/* Password dialog*/
|
||||
#PasswordBtn {
|
||||
border: none;
|
||||
|
|
@ -969,17 +994,6 @@ PixmapButton:disabled {
|
|||
#PublishLogConsole {
|
||||
font-family: "Noto Sans Mono";
|
||||
}
|
||||
#VariantInputsWidget QLineEdit {
|
||||
border-bottom-right-radius: 0px;
|
||||
border-top-right-radius: 0px;
|
||||
}
|
||||
#VariantInputsWidget QToolButton {
|
||||
border-bottom-left-radius: 0px;
|
||||
border-top-left-radius: 0px;
|
||||
padding-top: 0.5em;
|
||||
padding-bottom: 0.5em;
|
||||
width: 0.5em;
|
||||
}
|
||||
#VariantInput[state="new"], #VariantInput[state="new"]:focus, #VariantInput[state="new"]:hover {
|
||||
border-color: {color:publisher:success};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from ayon_core.tools.publisher.constants import (
|
|||
INPUTS_LAYOUT_HSPACING,
|
||||
INPUTS_LAYOUT_VSPACING,
|
||||
)
|
||||
from ayon_core.tools.utils import HintedLineEdit
|
||||
|
||||
from .thumbnail_widget import ThumbnailWidget
|
||||
from .widgets import (
|
||||
|
|
@ -28,8 +29,6 @@ from .widgets import (
|
|||
from .create_context_widgets import CreateContextWidget
|
||||
from .precreate_widget import PreCreateWidget
|
||||
|
||||
SEPARATORS = ("---separator---", "---")
|
||||
|
||||
|
||||
class ResizeControlWidget(QtWidgets.QWidget):
|
||||
resized = QtCore.Signal()
|
||||
|
|
@ -168,25 +167,9 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
|
||||
product_variant_widget = QtWidgets.QWidget(creator_basics_widget)
|
||||
# Variant and product input
|
||||
variant_widget = ResizeControlWidget(product_variant_widget)
|
||||
variant_widget.setObjectName("VariantInputsWidget")
|
||||
|
||||
variant_input = QtWidgets.QLineEdit(variant_widget)
|
||||
variant_input.setObjectName("VariantInput")
|
||||
variant_input.setToolTip(VARIANT_TOOLTIP)
|
||||
|
||||
variant_hints_btn = QtWidgets.QToolButton(variant_widget)
|
||||
variant_hints_btn.setArrowType(QtCore.Qt.DownArrow)
|
||||
variant_hints_btn.setIconSize(QtCore.QSize(12, 12))
|
||||
|
||||
variant_hints_menu = QtWidgets.QMenu(variant_widget)
|
||||
variant_hints_group = QtWidgets.QActionGroup(variant_hints_menu)
|
||||
|
||||
variant_layout = QtWidgets.QHBoxLayout(variant_widget)
|
||||
variant_layout.setContentsMargins(0, 0, 0, 0)
|
||||
variant_layout.setSpacing(0)
|
||||
variant_layout.addWidget(variant_input, 1)
|
||||
variant_layout.addWidget(variant_hints_btn, 0, QtCore.Qt.AlignVCenter)
|
||||
variant_widget = HintedLineEdit(parent=product_variant_widget)
|
||||
variant_widget.set_text_widget_object_name("VariantInput")
|
||||
variant_widget.setToolTip(VARIANT_TOOLTIP)
|
||||
|
||||
product_name_input = QtWidgets.QLineEdit(product_variant_widget)
|
||||
product_name_input.setEnabled(False)
|
||||
|
|
@ -262,15 +245,12 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
prereq_timer.timeout.connect(self._invalidate_prereq)
|
||||
|
||||
create_btn.clicked.connect(self._on_create)
|
||||
variant_widget.resized.connect(self._on_variant_widget_resize)
|
||||
creator_basics_widget.resized.connect(self._on_creator_basics_resize)
|
||||
variant_input.returnPressed.connect(self._on_create)
|
||||
variant_input.textChanged.connect(self._on_variant_change)
|
||||
variant_widget.returnPressed.connect(self._on_create)
|
||||
variant_widget.textChanged.connect(self._on_variant_change)
|
||||
creators_view.selectionModel().currentChanged.connect(
|
||||
self._on_creator_item_change
|
||||
)
|
||||
variant_hints_btn.clicked.connect(self._on_variant_btn_click)
|
||||
variant_hints_menu.triggered.connect(self._on_variant_action)
|
||||
context_widget.folder_changed.connect(self._on_folder_change)
|
||||
context_widget.task_changed.connect(self._on_task_change)
|
||||
thumbnail_widget.thumbnail_created.connect(self._on_thumbnail_create)
|
||||
|
|
@ -291,10 +271,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
|
||||
self.product_name_input = product_name_input
|
||||
|
||||
self.variant_input = variant_input
|
||||
self.variant_hints_btn = variant_hints_btn
|
||||
self.variant_hints_menu = variant_hints_menu
|
||||
self.variant_hints_group = variant_hints_group
|
||||
self._variant_widget = variant_widget
|
||||
|
||||
self._creators_model = creators_model
|
||||
self._creators_sort_model = creators_sort_model
|
||||
|
|
@ -314,6 +291,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
self._last_current_context_folder_path = None
|
||||
self._last_current_context_task = None
|
||||
self._use_current_context = True
|
||||
self._current_creator_variant_hints = []
|
||||
|
||||
def get_current_folder_path(self):
|
||||
return self._controller.get_current_folder_path()
|
||||
|
|
@ -438,8 +416,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
|
||||
self._create_btn.setEnabled(prereq_available)
|
||||
|
||||
self.variant_input.setEnabled(prereq_available)
|
||||
self.variant_hints_btn.setEnabled(prereq_available)
|
||||
self._variant_widget.setEnabled(prereq_available)
|
||||
|
||||
tooltip = ""
|
||||
if creator_btn_tooltips:
|
||||
|
|
@ -611,35 +588,15 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
if not default_variant:
|
||||
default_variant = default_variants[0]
|
||||
|
||||
for action in tuple(self.variant_hints_menu.actions()):
|
||||
self.variant_hints_menu.removeAction(action)
|
||||
action.deleteLater()
|
||||
|
||||
for variant in default_variants:
|
||||
if variant in SEPARATORS:
|
||||
self.variant_hints_menu.addSeparator()
|
||||
elif variant:
|
||||
self.variant_hints_menu.addAction(variant)
|
||||
self._current_creator_variant_hints = list(default_variants)
|
||||
self._variant_widget.set_options(default_variants)
|
||||
|
||||
variant_text = default_variant or DEFAULT_VARIANT_VALUE
|
||||
# Make sure product name is updated to new plugin
|
||||
if variant_text == self.variant_input.text():
|
||||
if variant_text == self._variant_widget.text():
|
||||
self._on_variant_change()
|
||||
else:
|
||||
self.variant_input.setText(variant_text)
|
||||
|
||||
def _on_variant_widget_resize(self):
|
||||
self.variant_hints_btn.setFixedHeight(self.variant_input.height())
|
||||
|
||||
def _on_variant_btn_click(self):
|
||||
pos = self.variant_hints_btn.rect().bottomLeft()
|
||||
point = self.variant_hints_btn.mapToGlobal(pos)
|
||||
self.variant_hints_menu.popup(point)
|
||||
|
||||
def _on_variant_action(self, action):
|
||||
value = action.text()
|
||||
if self.variant_input.text() != value:
|
||||
self.variant_input.setText(value)
|
||||
self._variant_widget.setText(variant_text)
|
||||
|
||||
def _on_variant_change(self, variant_value=None):
|
||||
if not self._prereq_available:
|
||||
|
|
@ -652,7 +609,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
return
|
||||
|
||||
if variant_value is None:
|
||||
variant_value = self.variant_input.text()
|
||||
variant_value = self._variant_widget.text()
|
||||
|
||||
if not self._compiled_name_pattern.match(variant_value):
|
||||
self._create_btn.setEnabled(False)
|
||||
|
|
@ -707,20 +664,12 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
if _result:
|
||||
variant_hints |= set(_result.groups())
|
||||
|
||||
# Remove previous hints from menu
|
||||
for action in tuple(self.variant_hints_group.actions()):
|
||||
self.variant_hints_group.removeAction(action)
|
||||
self.variant_hints_menu.removeAction(action)
|
||||
action.deleteLater()
|
||||
|
||||
# Add separator if there are hints and menu already has actions
|
||||
if variant_hints and self.variant_hints_menu.actions():
|
||||
self.variant_hints_menu.addSeparator()
|
||||
|
||||
options = list(self._current_creator_variant_hints)
|
||||
if options:
|
||||
options.append("---")
|
||||
options.extend(variant_hints)
|
||||
# Add hints to actions
|
||||
for variant_hint in variant_hints:
|
||||
action = self.variant_hints_menu.addAction(variant_hint)
|
||||
self.variant_hints_group.addAction(action)
|
||||
self._variant_widget.set_options(options)
|
||||
|
||||
# Indicate product existence
|
||||
if not variant_value:
|
||||
|
|
@ -741,10 +690,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
self._create_btn.setEnabled(variant_is_valid)
|
||||
|
||||
def _set_variant_state_property(self, state):
|
||||
current_value = self.variant_input.property("state")
|
||||
if current_value != state:
|
||||
self.variant_input.setProperty("state", state)
|
||||
self.variant_input.style().polish(self.variant_input)
|
||||
self._variant_widget.set_text_widget_property("state", state)
|
||||
|
||||
def _on_first_show(self):
|
||||
width = self.width()
|
||||
|
|
@ -776,7 +722,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
index = indexes[0]
|
||||
creator_identifier = index.data(CREATOR_IDENTIFIER_ROLE)
|
||||
product_type = index.data(PRODUCT_TYPE_ROLE)
|
||||
variant = self.variant_input.text()
|
||||
variant = self._variant_widget.text()
|
||||
# Care about product name only if context change is enabled
|
||||
product_name = None
|
||||
folder_path = None
|
||||
|
|
@ -810,7 +756,7 @@ class CreateWidget(QtWidgets.QWidget):
|
|||
|
||||
if success:
|
||||
self._set_creator(self._selected_creator)
|
||||
self.variant_input.setText(variant)
|
||||
self._variant_widget.setText(variant)
|
||||
self._controller.emit_card_message("Creation finished...")
|
||||
self._last_thumbnail_path = None
|
||||
self._thumbnail_widget.set_current_thumbnails()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ from .widgets import (
|
|||
CustomTextComboBox,
|
||||
PlaceholderLineEdit,
|
||||
ElideLabel,
|
||||
HintedLineEdit,
|
||||
ExpandingTextEdit,
|
||||
BaseClickableFrame,
|
||||
ClickableFrame,
|
||||
|
|
@ -90,6 +91,7 @@ __all__ = (
|
|||
"CustomTextComboBox",
|
||||
"PlaceholderLineEdit",
|
||||
"ElideLabel",
|
||||
"HintedLineEdit",
|
||||
"ExpandingTextEdit",
|
||||
"BaseClickableFrame",
|
||||
"ClickableFrame",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
from typing import Optional, List, Set, Any
|
||||
|
||||
from qtpy import QtWidgets, QtCore, QtGui
|
||||
import qargparse
|
||||
|
|
@ -11,7 +12,7 @@ from ayon_core.style import (
|
|||
)
|
||||
from ayon_core.lib.attribute_definitions import AbstractAttrDef
|
||||
|
||||
from .lib import get_qta_icon_by_name_and_color
|
||||
from .lib import get_qta_icon_by_name_and_color, set_style_property
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -200,6 +201,157 @@ class ElideLabel(QtWidgets.QLabel):
|
|||
clipboard.setText(self._text)
|
||||
|
||||
|
||||
class _LocalCache:
|
||||
down_arrow_icon = None
|
||||
|
||||
|
||||
def get_down_arrow_icon() -> QtGui.QIcon:
|
||||
if _LocalCache.down_arrow_icon is not None:
|
||||
return _LocalCache.down_arrow_icon
|
||||
|
||||
normal_pixmap = QtGui.QPixmap(
|
||||
get_style_image_path("down_arrow")
|
||||
)
|
||||
on_pixmap = QtGui.QPixmap(
|
||||
get_style_image_path("down_arrow_on")
|
||||
)
|
||||
disabled_pixmap = QtGui.QPixmap(
|
||||
get_style_image_path("down_arrow_disabled")
|
||||
)
|
||||
icon = QtGui.QIcon(normal_pixmap)
|
||||
icon.addPixmap(on_pixmap, QtGui.QIcon.Active)
|
||||
icon.addPixmap(disabled_pixmap, QtGui.QIcon.Disabled)
|
||||
_LocalCache.down_arrow_icon = icon
|
||||
return icon
|
||||
|
||||
|
||||
# These are placeholders for adding style
|
||||
class HintedLineEditInput(PlaceholderLineEdit):
|
||||
pass
|
||||
|
||||
|
||||
class HintedLineEditButton(QtWidgets.QPushButton):
|
||||
pass
|
||||
|
||||
|
||||
class HintedLineEdit(QtWidgets.QWidget):
|
||||
SEPARATORS: Set[str] = {"---", "---separator---"}
|
||||
returnPressed = QtCore.Signal()
|
||||
textChanged = QtCore.Signal(str)
|
||||
textEdited = QtCore.Signal(str)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
options: Optional[List[str]] = None,
|
||||
parent: Optional[QtWidgets.QWidget] = None
|
||||
):
|
||||
super().__init__(parent)
|
||||
|
||||
text_input = HintedLineEditInput(self)
|
||||
options_button = HintedLineEditButton(self)
|
||||
options_button.setIcon(get_down_arrow_icon())
|
||||
|
||||
main_layout = QtWidgets.QHBoxLayout(self)
|
||||
main_layout.setContentsMargins(0, 0, 0, 0)
|
||||
main_layout.setSpacing(0)
|
||||
main_layout.addWidget(text_input, 1)
|
||||
main_layout.addWidget(options_button, 0)
|
||||
|
||||
# Expand line edit and button vertically so they have same height
|
||||
for widget in (text_input, options_button):
|
||||
w_size_policy = widget.sizePolicy()
|
||||
w_size_policy.setVerticalPolicy(
|
||||
QtWidgets.QSizePolicy.MinimumExpanding)
|
||||
widget.setSizePolicy(w_size_policy)
|
||||
|
||||
# Set size hint of this frame to fixed so size hint height is
|
||||
# used as fixed height
|
||||
size_policy = self.sizePolicy()
|
||||
size_policy.setVerticalPolicy(QtWidgets.QSizePolicy.Fixed)
|
||||
self.setSizePolicy(size_policy)
|
||||
|
||||
text_input.returnPressed.connect(self.returnPressed)
|
||||
text_input.textChanged.connect(self.textChanged)
|
||||
text_input.textEdited.connect(self.textEdited)
|
||||
options_button.clicked.connect(self._on_options_button_clicked)
|
||||
|
||||
self._text_input = text_input
|
||||
self._options_button = options_button
|
||||
self._options = None
|
||||
|
||||
# Set default state
|
||||
self.set_options(options)
|
||||
|
||||
def text(self) -> str:
|
||||
return self._text_input.text()
|
||||
|
||||
def setText(self, text: str):
|
||||
self._text_input.setText(text)
|
||||
|
||||
def setPlaceholderText(self, text: str):
|
||||
self._text_input.setPlaceholderText(text)
|
||||
|
||||
def placeholderText(self) -> str:
|
||||
return self._text_input.placeholderText()
|
||||
|
||||
def setReadOnly(self, state: bool):
|
||||
self._text_input.setReadOnly(state)
|
||||
|
||||
def setIcon(self, icon: QtGui.QIcon):
|
||||
self._options_button.setIcon(icon)
|
||||
|
||||
def setToolTip(self, text: str):
|
||||
self._text_input.setToolTip(text)
|
||||
|
||||
def set_button_tool_tip(self, text: str):
|
||||
self._options_button.setToolTip(text)
|
||||
|
||||
def set_options(self, options: Optional[List[str]] = None):
|
||||
self._options = options
|
||||
self._options_button.setEnabled(bool(options))
|
||||
|
||||
def sizeHint(self) -> QtCore.QSize:
|
||||
hint = super().sizeHint()
|
||||
tsz = self._text_input.sizeHint()
|
||||
bsz = self._options_button.sizeHint()
|
||||
hint.setHeight(max(tsz.height(), bsz.height()))
|
||||
return hint
|
||||
|
||||
# Adds ability to change style of the widgets
|
||||
# - because style change of the 'HintedLineEdit' may not propagate
|
||||
# correctly 'HintedLineEditInput' and 'HintedLineEditButton'
|
||||
def set_text_widget_object_name(self, name: str):
|
||||
self._text_input.setObjectName(name)
|
||||
|
||||
def set_text_widget_property(self, name: str, value: Any):
|
||||
set_style_property(self._text_input, name, value)
|
||||
|
||||
def set_button_widget_object_name(self, name: str):
|
||||
self._text_input.setObjectName(name)
|
||||
|
||||
def set_button_widget_property(self, name: str, value: Any):
|
||||
set_style_property(self._options_button, name, value)
|
||||
|
||||
def _on_options_button_clicked(self):
|
||||
if not self._options:
|
||||
return
|
||||
|
||||
menu = QtWidgets.QMenu(self)
|
||||
menu.triggered.connect(self._on_option_action)
|
||||
for option in self._options:
|
||||
if option in self.SEPARATORS:
|
||||
menu.addSeparator()
|
||||
else:
|
||||
menu.addAction(option)
|
||||
|
||||
rect = self._options_button.rect()
|
||||
pos = self._options_button.mapToGlobal(rect.bottomLeft())
|
||||
menu.exec_(pos)
|
||||
|
||||
def _on_option_action(self, action):
|
||||
self.setText(action.text())
|
||||
|
||||
|
||||
class ExpandingTextEdit(QtWidgets.QTextEdit):
|
||||
"""QTextEdit which does not have sroll area but expands height."""
|
||||
|
||||
|
|
@ -302,6 +454,8 @@ class ExpandBtnLabel(QtWidgets.QLabel):
|
|||
"""Label showing expand icon meant for ExpandBtn."""
|
||||
state_changed = QtCore.Signal()
|
||||
|
||||
branch_closed_path = get_style_image_path("branch_closed")
|
||||
branch_open_path = get_style_image_path("branch_open")
|
||||
|
||||
def __init__(self, parent):
|
||||
super(ExpandBtnLabel, self).__init__(parent)
|
||||
|
|
@ -312,14 +466,10 @@ class ExpandBtnLabel(QtWidgets.QLabel):
|
|||
self._collapsed = True
|
||||
|
||||
def _create_collapsed_pixmap(self):
|
||||
return QtGui.QPixmap(
|
||||
get_style_image_path("branch_closed")
|
||||
)
|
||||
return QtGui.QPixmap(self.branch_closed_path)
|
||||
|
||||
def _create_expanded_pixmap(self):
|
||||
return QtGui.QPixmap(
|
||||
get_style_image_path("branch_open")
|
||||
)
|
||||
return QtGui.QPixmap(self.branch_open_path)
|
||||
|
||||
@property
|
||||
def collapsed(self):
|
||||
|
|
@ -387,15 +537,14 @@ class ExpandBtn(ClickableFrame):
|
|||
|
||||
|
||||
class ClassicExpandBtnLabel(ExpandBtnLabel):
|
||||
right_arrow_path = get_style_image_path("right_arrow")
|
||||
down_arrow_path = get_style_image_path("down_arrow")
|
||||
|
||||
def _create_collapsed_pixmap(self):
|
||||
return QtGui.QPixmap(
|
||||
get_style_image_path("right_arrow")
|
||||
)
|
||||
return QtGui.QPixmap(self.right_arrow_path)
|
||||
|
||||
def _create_expanded_pixmap(self):
|
||||
return QtGui.QPixmap(
|
||||
get_style_image_path("down_arrow")
|
||||
)
|
||||
return QtGui.QPixmap(self.down_arrow_path)
|
||||
|
||||
|
||||
class ClassicExpandBtn(ExpandBtn):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue