Skip to content

ayon_dialog

Ayon Marvelous Designer tools dialog module.

MDBtnToolsWidget

Bases: QWidget

Widget containing buttons which are clickable.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
class MDBtnToolsWidget(QtWidgets.QWidget):
    """Widget containing buttons which are clickable."""
    tool_required = QtCore.Signal(str)

    def __init__(self, parent=None):  # noqa: ANN001
        """Ayon Marvelous Designer tools widget.

        Args:
            parent (QMainWindow, optional): Parent widget. Defaults to None.
        """
        super(MDBtnToolsWidget, self).__init__(parent)  # noqa: UP008

        load_btn = QtWidgets.QPushButton("Load...", self)
        manage_btn = QtWidgets.QPushButton("Manage...", self)
        publish_btn = QtWidgets.QPushButton("Publish...", self)
        workfile_btn = QtWidgets.QPushButton("Workfile...", self)

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(load_btn, 0)
        layout.addWidget(manage_btn, 0)
        layout.addWidget(publish_btn, 0)
        layout.addWidget(workfile_btn, 0)
        layout.addStretch(1)

        load_btn.clicked.connect(self._on_load)
        manage_btn.clicked.connect(self._on_manage)
        publish_btn.clicked.connect(self._on_publish)
        workfile_btn.clicked.connect(self._on_workfile)

    def _on_load(self) -> None:
        self.tool_required.emit("loader")

    def _on_publish(self) -> None:
        self.tool_required.emit("publisher")

    def _on_manage(self) -> None:
        self.tool_required.emit("sceneinventory")

    def _on_workfile(self) -> None:
        self.tool_required.emit("workfiles")

__init__(parent=None)

Ayon Marvelous Designer tools widget.

Parameters:

Name Type Description Default
parent QMainWindow

Parent widget. Defaults to None.

None
Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
def __init__(self, parent=None):  # noqa: ANN001
    """Ayon Marvelous Designer tools widget.

    Args:
        parent (QMainWindow, optional): Parent widget. Defaults to None.
    """
    super(MDBtnToolsWidget, self).__init__(parent)  # noqa: UP008

    load_btn = QtWidgets.QPushButton("Load...", self)
    manage_btn = QtWidgets.QPushButton("Manage...", self)
    publish_btn = QtWidgets.QPushButton("Publish...", self)
    workfile_btn = QtWidgets.QPushButton("Workfile...", self)

    layout = QtWidgets.QVBoxLayout(self)
    layout.setContentsMargins(0, 0, 0, 0)
    layout.addWidget(load_btn, 0)
    layout.addWidget(manage_btn, 0)
    layout.addWidget(publish_btn, 0)
    layout.addWidget(workfile_btn, 0)
    layout.addStretch(1)

    load_btn.clicked.connect(self._on_load)
    manage_btn.clicked.connect(self._on_manage)
    publish_btn.clicked.connect(self._on_publish)
    workfile_btn.clicked.connect(self._on_workfile)

MDToolsDialog

Bases: QDialog

Dialog with tool buttons that will stay opened until user close it.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
class MDToolsDialog(QtWidgets.QDialog):
    """Dialog with tool buttons that will stay opened until user close it."""
    def __init__(self, *args, **kwargs):  # noqa: ANN002, ANN003
        """Ayon Marvelous Designer tools dialog."""
        super(MDToolsDialog, self).__init__(*args, **kwargs)  # noqa: UP008

        self.setWindowTitle("Ayon tools")
        icon = QtGui.QIcon(resources.get_ayon_icon_filepath())
        self.setWindowIcon(icon)

        self.setWindowFlags(
            QtCore.Qt.Window
            | QtCore.Qt.WindowStaysOnTopHint
            | QtCore.Qt.WindowMinimizeButtonHint
            | QtCore.Qt.WindowMaximizeButtonHint
            | QtCore.Qt.WindowCloseButtonHint
        )
        self.setFocusPolicy(QtCore.Qt.StrongFocus)

        tools_widget = MDBtnToolsWidget(self)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(tools_widget)

        tools_widget.tool_required.connect(self._on_tool_require)
        self._tools_widget = tools_widget

        self._first_show = True

    def sizeHint(self) -> QtCore.QSize:  # noqa: N802
        """Override size hint to make dialog wider.

        Returns:
            QSize: Size hint object with modified width.
        """
        result = super().sizeHint()
        result.setWidth(result.width() * 2)
        return result

    def showEvent(self, event: QtGui.QShowEvent) -> None:  # noqa: N802
        """Handle show event for the dialog.

        Applies stylesheet on first show to ensure proper styling.

        Args:
            event: The show event from Qt framework.
        """
        super().showEvent(event)
        if self._first_show:
            self.setStyleSheet(style.load_stylesheet())
            self._first_show = False

    def closeEvent(self, event: QtGui.QCloseEvent) -> None:  # noqa: N802
        """Handle close event for the dialog.

        Cleans up the dialog reference in WindowCache upon closing.

        Args:
            event: The close event from Qt framework.
        """
        super().closeEvent(event)
        utility_api.ResetWidgetRegistry()

    def _on_tool_require(self, tool_name: str) -> None:
        host_tools.show_tool_by_name(tool_name, parent=self)

__init__(*args, **kwargs)

Ayon Marvelous Designer tools dialog.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
def __init__(self, *args, **kwargs):  # noqa: ANN002, ANN003
    """Ayon Marvelous Designer tools dialog."""
    super(MDToolsDialog, self).__init__(*args, **kwargs)  # noqa: UP008

    self.setWindowTitle("Ayon tools")
    icon = QtGui.QIcon(resources.get_ayon_icon_filepath())
    self.setWindowIcon(icon)

    self.setWindowFlags(
        QtCore.Qt.Window
        | QtCore.Qt.WindowStaysOnTopHint
        | QtCore.Qt.WindowMinimizeButtonHint
        | QtCore.Qt.WindowMaximizeButtonHint
        | QtCore.Qt.WindowCloseButtonHint
    )
    self.setFocusPolicy(QtCore.Qt.StrongFocus)

    tools_widget = MDBtnToolsWidget(self)

    layout = QtWidgets.QVBoxLayout(self)
    layout.addWidget(tools_widget)

    tools_widget.tool_required.connect(self._on_tool_require)
    self._tools_widget = tools_widget

    self._first_show = True

closeEvent(event)

Handle close event for the dialog.

Cleans up the dialog reference in WindowCache upon closing.

Parameters:

Name Type Description Default
event QCloseEvent

The close event from Qt framework.

required
Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
106
107
108
109
110
111
112
113
114
115
def closeEvent(self, event: QtGui.QCloseEvent) -> None:  # noqa: N802
    """Handle close event for the dialog.

    Cleans up the dialog reference in WindowCache upon closing.

    Args:
        event: The close event from Qt framework.
    """
    super().closeEvent(event)
    utility_api.ResetWidgetRegistry()

showEvent(event)

Handle show event for the dialog.

Applies stylesheet on first show to ensure proper styling.

Parameters:

Name Type Description Default
event QShowEvent

The show event from Qt framework.

required
Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
def showEvent(self, event: QtGui.QShowEvent) -> None:  # noqa: N802
    """Handle show event for the dialog.

    Applies stylesheet on first show to ensure proper styling.

    Args:
        event: The show event from Qt framework.
    """
    super().showEvent(event)
    if self._first_show:
        self.setStyleSheet(style.load_stylesheet())
        self._first_show = False

sizeHint()

Override size hint to make dialog wider.

Returns:

Name Type Description
QSize QSize

Size hint object with modified width.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
83
84
85
86
87
88
89
90
91
def sizeHint(self) -> QtCore.QSize:  # noqa: N802
    """Override size hint to make dialog wider.

    Returns:
        QSize: Size hint object with modified width.
    """
    result = super().sizeHint()
    result.setWidth(result.width() * 2)
    return result

WindowCache

Cached objects and methods to be used in global scope.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
class WindowCache:
    """Cached objects and methods to be used in global scope."""
    dialog: MDToolsDialog | None = None
    _popup = None
    _first_show = True

    @classmethod
    def show_dialog(cls) -> None:
        """Show the tools dialog window.

        Creates a new dialog instance if none exists, then shows, raises,
        and activates the dialog window.
        """
        with qt_app_context():
            if cls.dialog is None:
                cls.dialog = MDToolsDialog()

            cls.dialog.show()
            cls.dialog.raise_()
            cls.dialog.activateWindow()

show_dialog() classmethod

Show the tools dialog window.

Creates a new dialog instance if none exists, then shows, raises, and activates the dialog window.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@classmethod
def show_dialog(cls) -> None:
    """Show the tools dialog window.

    Creates a new dialog instance if none exists, then shows, raises,
    and activates the dialog window.
    """
    with qt_app_context():
        if cls.dialog is None:
            cls.dialog = MDToolsDialog()

        cls.dialog.show()
        cls.dialog.raise_()
        cls.dialog.activateWindow()

show_tools_dialog()

Show the Marvelous Designer tools dialog.

Creates and shows the tools dialog if it doesn't exist or isn't visible. The dialog provides access to Ayon tools like loader, publisher, scene inventory, and workfiles management.

Source code in client/ayon_marvelousdesigner/api/ayon_dialog.py
143
144
145
146
147
148
149
150
151
def show_tools_dialog() -> None:
    """Show the Marvelous Designer tools dialog.

    Creates and shows the tools dialog if it doesn't exist or isn't visible.
    The dialog provides access to Ayon tools like loader, publisher, scene
    inventory, and workfiles management.
    """
    if not WindowCache.dialog or not WindowCache.dialog.isVisible():
        WindowCache.show_dialog()