mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
created new file for help widget
This commit is contained in:
parent
dbbf5eb446
commit
24c62754f5
2 changed files with 99 additions and 100 deletions
|
|
@ -3,7 +3,6 @@ import re
|
|||
import traceback
|
||||
import copy
|
||||
|
||||
import qtawesome
|
||||
try:
|
||||
import commonmark
|
||||
except Exception:
|
||||
|
|
@ -16,11 +15,7 @@ from openpype.pipeline.create import (
|
|||
SUBSET_NAME_ALLOWED_SYMBOLS,
|
||||
TaskNotSetError,
|
||||
)
|
||||
from openpype.tools.utils import (
|
||||
ErrorMessageBox,
|
||||
MessageOverlayObject,
|
||||
ClickableFrame,
|
||||
)
|
||||
from openpype.tools.utils import ErrorMessageBox
|
||||
|
||||
from .widgets import (
|
||||
IconValuePixmapLabel,
|
||||
|
|
@ -193,100 +188,6 @@ class CreatorShortDescWidget(QtWidgets.QWidget):
|
|||
self._description_label.setText(description)
|
||||
|
||||
|
||||
class HelpButton(ClickableFrame):
|
||||
resized = QtCore.Signal(int)
|
||||
question_mark_icon_name = "fa.question"
|
||||
help_icon_name = "fa.question-circle"
|
||||
hide_icon_name = "fa.angle-left"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HelpButton, self).__init__(*args, **kwargs)
|
||||
self.setObjectName("CreateDialogHelpButton")
|
||||
|
||||
question_mark_label = QtWidgets.QLabel(self)
|
||||
help_widget = QtWidgets.QWidget(self)
|
||||
|
||||
help_question = QtWidgets.QLabel(help_widget)
|
||||
help_label = QtWidgets.QLabel("Help", help_widget)
|
||||
hide_icon = QtWidgets.QLabel(help_widget)
|
||||
|
||||
help_layout = QtWidgets.QHBoxLayout(help_widget)
|
||||
help_layout.setContentsMargins(0, 0, 5, 0)
|
||||
help_layout.addWidget(help_question, 0)
|
||||
help_layout.addWidget(help_label, 0)
|
||||
help_layout.addStretch(1)
|
||||
help_layout.addWidget(hide_icon, 0)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(question_mark_label, 0)
|
||||
layout.addWidget(help_widget, 1)
|
||||
|
||||
help_widget.setVisible(False)
|
||||
|
||||
self._question_mark_label = question_mark_label
|
||||
self._help_widget = help_widget
|
||||
self._help_question = help_question
|
||||
self._hide_icon = hide_icon
|
||||
|
||||
self._expanded = None
|
||||
self.set_expanded()
|
||||
|
||||
def set_expanded(self, expanded=None):
|
||||
if self._expanded is expanded:
|
||||
if expanded is not None:
|
||||
return
|
||||
expanded = False
|
||||
self._expanded = expanded
|
||||
self._help_widget.setVisible(expanded)
|
||||
self._update_content()
|
||||
|
||||
def _update_content(self):
|
||||
width = self.get_icon_width()
|
||||
if self._expanded:
|
||||
question_mark_pix = QtGui.QPixmap(width, width)
|
||||
question_mark_pix.fill(QtCore.Qt.transparent)
|
||||
|
||||
else:
|
||||
question_mark_icon = qtawesome.icon(
|
||||
self.question_mark_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
question_mark_pix = question_mark_icon.pixmap(width, width)
|
||||
|
||||
hide_icon = qtawesome.icon(
|
||||
self.hide_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
help_question_icon = qtawesome.icon(
|
||||
self.help_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
self._question_mark_label.setPixmap(question_mark_pix)
|
||||
self._question_mark_label.setMaximumWidth(width)
|
||||
self._hide_icon.setPixmap(hide_icon.pixmap(width, width))
|
||||
self._help_question.setPixmap(help_question_icon.pixmap(width, width))
|
||||
|
||||
def get_icon_width(self):
|
||||
metrics = self.fontMetrics()
|
||||
return metrics.height()
|
||||
|
||||
def set_pos_and_size(self, pos_x, pos_y, width, height):
|
||||
update_icon = self.height() != height
|
||||
self.move(pos_x, pos_y)
|
||||
self.resize(width, height)
|
||||
|
||||
if update_icon:
|
||||
self._update_content()
|
||||
self.updateGeometry()
|
||||
|
||||
def showEvent(self, event):
|
||||
super(HelpButton, self).showEvent(event)
|
||||
self.resized.emit(self.height())
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super(HelpButton, self).resizeEvent(event)
|
||||
self.resized.emit(self.height())
|
||||
|
||||
|
||||
class CreateWidget(QtWidgets.QWidget):
|
||||
def __init__(self, controller, parent=None):
|
||||
super(CreateWidget, self).__init__(parent)
|
||||
|
|
|
|||
98
openpype/tools/publisher/widgets/help_widget.py
Normal file
98
openpype/tools/publisher/widgets/help_widget.py
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
import qtawesome
|
||||
from Qt import QtWidgets, QtCore, QtGui
|
||||
|
||||
from openpype.tools.utils import ClickableFrame
|
||||
|
||||
|
||||
class HelpButton(ClickableFrame):
|
||||
resized = QtCore.Signal(int)
|
||||
question_mark_icon_name = "fa.question"
|
||||
help_icon_name = "fa.question-circle"
|
||||
hide_icon_name = "fa.angle-left"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(HelpButton, self).__init__(*args, **kwargs)
|
||||
self.setObjectName("CreateDialogHelpButton")
|
||||
|
||||
question_mark_label = QtWidgets.QLabel(self)
|
||||
help_widget = QtWidgets.QWidget(self)
|
||||
|
||||
help_question = QtWidgets.QLabel(help_widget)
|
||||
help_label = QtWidgets.QLabel("Help", help_widget)
|
||||
hide_icon = QtWidgets.QLabel(help_widget)
|
||||
|
||||
help_layout = QtWidgets.QHBoxLayout(help_widget)
|
||||
help_layout.setContentsMargins(0, 0, 5, 0)
|
||||
help_layout.addWidget(help_question, 0)
|
||||
help_layout.addWidget(help_label, 0)
|
||||
help_layout.addStretch(1)
|
||||
help_layout.addWidget(hide_icon, 0)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
layout.setSpacing(0)
|
||||
layout.addWidget(question_mark_label, 0)
|
||||
layout.addWidget(help_widget, 1)
|
||||
|
||||
help_widget.setVisible(False)
|
||||
|
||||
self._question_mark_label = question_mark_label
|
||||
self._help_widget = help_widget
|
||||
self._help_question = help_question
|
||||
self._hide_icon = hide_icon
|
||||
|
||||
self._expanded = None
|
||||
self.set_expanded()
|
||||
|
||||
def set_expanded(self, expanded=None):
|
||||
if self._expanded is expanded:
|
||||
if expanded is not None:
|
||||
return
|
||||
expanded = False
|
||||
self._expanded = expanded
|
||||
self._help_widget.setVisible(expanded)
|
||||
self._update_content()
|
||||
|
||||
def _update_content(self):
|
||||
width = self.get_icon_width()
|
||||
if self._expanded:
|
||||
question_mark_pix = QtGui.QPixmap(width, width)
|
||||
question_mark_pix.fill(QtCore.Qt.transparent)
|
||||
|
||||
else:
|
||||
question_mark_icon = qtawesome.icon(
|
||||
self.question_mark_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
question_mark_pix = question_mark_icon.pixmap(width, width)
|
||||
|
||||
hide_icon = qtawesome.icon(
|
||||
self.hide_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
help_question_icon = qtawesome.icon(
|
||||
self.help_icon_name, color=QtCore.Qt.white
|
||||
)
|
||||
self._question_mark_label.setPixmap(question_mark_pix)
|
||||
self._question_mark_label.setMaximumWidth(width)
|
||||
self._hide_icon.setPixmap(hide_icon.pixmap(width, width))
|
||||
self._help_question.setPixmap(help_question_icon.pixmap(width, width))
|
||||
|
||||
def get_icon_width(self):
|
||||
metrics = self.fontMetrics()
|
||||
return metrics.height()
|
||||
|
||||
def set_pos_and_size(self, pos_x, pos_y, width, height):
|
||||
update_icon = self.height() != height
|
||||
self.move(pos_x, pos_y)
|
||||
self.resize(width, height)
|
||||
|
||||
if update_icon:
|
||||
self._update_content()
|
||||
self.updateGeometry()
|
||||
|
||||
def showEvent(self, event):
|
||||
super(HelpButton, self).showEvent(event)
|
||||
self.resized.emit(self.height())
|
||||
|
||||
def resizeEvent(self, event):
|
||||
super(HelpButton, self).resizeEvent(event)
|
||||
self.resized.emit(self.height())
|
||||
Loading…
Add table
Add a link
Reference in a new issue