Skip to content

Commit

Permalink
Merge pull request #3 from ynput/enhancement/move-dialogs-from-widgets
Browse files Browse the repository at this point in the history
Move dialogs from widgets to tools/utils
  • Loading branch information
iLLiCiTiT authored Feb 8, 2024
2 parents 7532d35 + 1327bff commit 8745c2c
Show file tree
Hide file tree
Showing 18 changed files with 326 additions and 476 deletions.
5 changes: 2 additions & 3 deletions client/ayon_core/hosts/blender/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,12 @@ def uninstall():


def show_message(title, message):
from ayon_core.widgets.message_window import Window
from ayon_core.tools.utils import show_message_dialog
from .ops import BlenderApplication

BlenderApplication.get_app()

Window(
parent=None,
show_message_dialog(
title=title,
message=message,
level="warning")
Expand Down
8 changes: 4 additions & 4 deletions client/ayon_core/hosts/fusion/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,15 @@ def _on_repair():
return

from . import menu
from ayon_core.widgets import popup
from ayon_core.tools.utils import SimplePopup
from ayon_core.style import load_stylesheet
dialog = popup.Popup(parent=menu.menu)
dialog = SimplePopup(parent=menu.menu)
dialog.setWindowTitle("Fusion comp has invalid configuration")

msg = "Comp preferences mismatches '{}'".format(asset_doc["name"])
msg += "\n" + "\n".join(invalid)
dialog.setMessage(msg)
dialog.setButtonText("Repair")
dialog.set_message(msg)
dialog.set_button_text("Repair")
dialog.on_clicked.connect(_on_repair)
dialog.show()
dialog.raise_()
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/fusion/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ def _on_show_scene_inventory():
frame.ActivateFrame() # raise comp window
host_tools.show_scene_inventory()

from ayon_core.widgets import popup
from ayon_core.tools.utils import SimplePopup
from ayon_core.style import load_stylesheet
dialog = popup.Popup(parent=menu.menu)
dialog = SimplePopup(parent=menu.menu)
dialog.setWindowTitle("Fusion comp has outdated content")
dialog.setMessage("There are outdated containers in "
dialog.set_message("There are outdated containers in "
"your Fusion comp.")
dialog.on_clicked.connect(_on_show_scene_inventory)
dialog.show()
Expand Down
15 changes: 7 additions & 8 deletions client/ayon_core/hosts/houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import uuid
import logging
from contextlib import contextmanager
import json

import six
Expand All @@ -24,7 +23,7 @@
from ayon_core.pipeline.create import CreateContext
from ayon_core.pipeline.template_data import get_template_data
from ayon_core.pipeline.context_tools import get_current_project_asset
from ayon_core.widgets import popup
from ayon_core.tools.utils import PopupUpdateKeys, SimplePopup
from ayon_core.tools.utils.host_tools import get_tool_by_name

import hou
Expand Down Expand Up @@ -209,12 +208,12 @@ def validate_fps():
if parent is None:
pass
else:
dialog = popup.PopupUpdateKeys(parent=parent)
dialog = PopupUpdateKeys(parent=parent)
dialog.setModal(True)
dialog.setWindowTitle("Houdini scene does not match project FPS")
dialog.setMessage("Scene %i FPS does not match project %i FPS" %
dialog.set_message("Scene %i FPS does not match project %i FPS" %
(current_fps, fps))
dialog.setButtonText("Fix")
dialog.set_button_text("Fix")

# on_show is the Fix button clicked callback
dialog.on_clicked_state.connect(lambda: set_scene_fps(fps))
Expand Down Expand Up @@ -950,11 +949,11 @@ def update_houdini_vars_context_dialog():

# TODO: Use better UI!
parent = hou.ui.mainQtWindow()
dialog = popup.Popup(parent=parent)
dialog = SimplePopup(parent=parent)
dialog.setModal(True)
dialog.setWindowTitle("Houdini scene has outdated asset variables")
dialog.setMessage(message)
dialog.setButtonText("Fix")
dialog.set_message(message)
dialog.set_button_text("Fix")

# on_show is the Fix button clicked callback
dialog.on_clicked.connect(update_houdini_vars_context)
Expand Down
29 changes: 15 additions & 14 deletions client/ayon_core/hosts/houdini/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,20 +305,21 @@ def _show_outdated_content_popup():
if parent is None:
log.info("Skipping outdated content pop-up "
"because Houdini window can't be found.")
else:
from ayon_core.widgets import popup

# Show outdated pop-up
def _on_show_inventory():
from ayon_core.tools.utils import host_tools
host_tools.show_scene_inventory(parent=parent)

dialog = popup.Popup(parent=parent)
dialog.setWindowTitle("Houdini scene has outdated content")
dialog.setMessage("There are outdated containers in "
"your Houdini scene.")
dialog.on_clicked.connect(_on_show_inventory)
dialog.show()
return

from ayon_core.tools.utils import SimplePopup

# Show outdated pop-up
def _on_show_inventory():
from ayon_core.tools.utils import host_tools
host_tools.show_scene_inventory(parent=parent)

dialog = SimplePopup(parent=parent)
dialog.setWindowTitle("Houdini scene has outdated content")
dialog.set_message("There are outdated containers in "
"your Houdini scene.")
dialog.on_clicked.connect(_on_show_inventory)
dialog.show()


def on_open():
Expand Down
8 changes: 4 additions & 4 deletions client/ayon_core/hosts/max/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,12 @@ def check_colorspace():
project_name, "max", project_settings)
if max_config_data and color_mgr.Mode != rt.Name("OCIO_Custom"):
if not is_headless():
from ayon_core.widgets import popup
dialog = popup.Popup(parent=parent)
from ayon_core.tools.utils import SimplePopup
dialog = SimplePopup(parent=parent)
dialog.setWindowTitle("Warning: Wrong OCIO Mode")
dialog.setMessage("This scene has wrong OCIO "
dialog.set_message("This scene has wrong OCIO "
"Mode setting.")
dialog.setButtonText("Fix")
dialog.set_button_text("Fix")
dialog.setStyleSheet(load_stylesheet())
dialog.on_clicked.connect(reset_colorspace)
dialog.show()
Expand Down
26 changes: 11 additions & 15 deletions client/ayon_core/hosts/maya/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2667,31 +2667,29 @@ def validate_fps():
"""

expected_fps = get_fps_for_current_context()
current_fps = mel.eval('currentTimeUnitToFPS()')
current_fps = mel.eval("currentTimeUnitToFPS()")

fps_match = current_fps == expected_fps
if not fps_match and not IS_HEADLESS:
from ayon_core.widgets import popup
from ayon_core.tools.utils import PopupUpdateKeys

parent = get_main_window()

dialog = popup.PopupUpdateKeys(parent=parent)
dialog = PopupUpdateKeys(parent=parent)
dialog.setModal(True)
dialog.setWindowTitle("Maya scene does not match project FPS")
dialog.setMessage(
dialog.set_message(
"Scene {} FPS does not match project {} FPS".format(
current_fps, expected_fps
)
)
dialog.setButtonText("Fix")
dialog.set_button_text("Fix")

# Set new text for button (add optional argument for the popup?)
toggle = dialog.widgets["toggle"]
update = toggle.isChecked()
dialog.on_clicked_state.connect(
lambda: set_scene_fps(expected_fps, update)
)
def on_click(update):
set_scene_fps(expected_fps, update)

dialog.on_clicked_state.connect(on_click)
dialog.show()

return False
Expand Down Expand Up @@ -3284,17 +3282,15 @@ def update_content_on_context_change():

def show_message(title, msg):
from qtpy import QtWidgets
from ayon_core.widgets import message_window
from ayon_core.tools.utils import show_message_dialog

# Find maya main window
top_level_widgets = {w.objectName(): w for w in
QtWidgets.QApplication.topLevelWidgets()}

parent = top_level_widgets.get("MayaWindow", None)
if parent is None:
pass
else:
message_window.message(title=title, message=msg, parent=parent)
if parent is not None:
show_message_dialog(title=title, message=msg, parent=parent)


def iter_shader_edits(relationships, shader_nodes, nodes_by_id, label=None):
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ def on_save():
def on_open():
"""On scene open let's assume the containers have changed."""

from ayon_core.widgets import popup
from ayon_core.tools.utils import SimplePopup

# Validate FPS after update_task_from_path to
# ensure it is using correct FPS for the asset
Expand All @@ -604,9 +604,9 @@ def on_open():
def _on_show_inventory():
host_tools.show_scene_inventory(parent=parent)

dialog = popup.Popup(parent=parent)
dialog = SimplePopup(parent=parent)
dialog.setWindowTitle("Maya scene has outdated content")
dialog.setMessage("There are outdated containers in "
dialog.set_message("There are outdated containers in "
"your Maya scene.")
dialog.on_clicked.connect(_on_show_inventory)
dialog.show()
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/hosts/maya/plugins/load/load_look.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
)
import ayon_core.hosts.maya.api.plugin
from ayon_core.hosts.maya.api import lib
from ayon_core.widgets.message_window import ScrollMessageBox

from ayon_core.hosts.maya.api.lib import get_reference_node

from ayon_core.tools.utils import ScrollMessageBox


class LookLoader(ayon_core.hosts.maya.api.plugin.ReferenceLoader):
"""Specific loader for lookdev"""
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_core/hosts/substancepainter/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def on_open():
log.info("Running callback on open..")

if any_outdated_containers():
from ayon_core.widgets import popup
from ayon_core.tools.utils import SimplePopup

log.warning("Scene has outdated content.")

Expand All @@ -301,9 +301,9 @@ def _on_show_inventory():
from ayon_core.tools.utils import host_tools
host_tools.show_scene_inventory(parent=parent)

dialog = popup.Popup(parent=parent)
dialog = SimplePopup(parent=parent)
dialog.setWindowTitle("Substance scene has outdated content")
dialog.setMessage("There are outdated containers in "
dialog.set_message("There are outdated containers in "
"your Substance scene.")
dialog.on_clicked.connect(_on_show_inventory)
dialog.show()
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_core/hosts/unreal/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def add_implementation_envs(self, env, app):

from .lib import get_compatible_integration

from ayon_core.widgets.message_window import Window
from ayon_core.tools.utils import show_message_dialog

pattern = re.compile(r'^\d+-\d+$')

Expand All @@ -34,7 +34,7 @@ def add_implementation_envs(self, env, app):
"Unreal application key in the settings must be in format"
"'5-0' or '5-1'"
)
Window(
show_message_dialog(
parent=None,
title="Unreal application name format",
message=msg,
Expand Down
5 changes: 2 additions & 3 deletions client/ayon_core/hosts/unreal/api/rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from ayon_core.settings import get_project_settings
from ayon_core.pipeline import Anatomy
from ayon_core.hosts.unreal.api import pipeline
from ayon_core.widgets.message_window import Window
from ayon_core.tools.utils import show_message_dialog


queue = None
Expand Down Expand Up @@ -40,8 +40,7 @@ def start_rendering():
assets = unreal.EditorUtilityLibrary.get_selected_assets()

if not assets:
Window(
parent=None,
show_message_dialog(
title="No assets selected",
message="No assets selected. Select a render instance.",
level="warning")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ def _delete_unused_assets(self, containers):

def _show_confirmation_dialog(self, containers):
from qtpy import QtCore
from ayon_core.widgets import popup
from ayon_core.tools.utils import SimplePopup
from ayon_core.style import load_stylesheet

dialog = popup.Popup()
dialog = SimplePopup()
dialog.setWindowFlags(
QtCore.Qt.Window
| QtCore.Qt.WindowStaysOnTopHint
)
dialog.setFocusPolicy(QtCore.Qt.StrongFocus)
dialog.setWindowTitle("Delete all unused assets")
dialog.setMessage(
dialog.set_message(
"You are about to delete all the assets in the project that \n"
"are not used in any level. Are you sure you want to continue?"
)
dialog.setButtonText("Delete")
dialog.set_button_text("Delete")

dialog.on_clicked.connect(
lambda: self._delete_unused_assets(containers)
Expand Down
11 changes: 11 additions & 0 deletions client/ayon_core/tools/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
from .thumbnail_paint_widget import ThumbnailPainterWidget
from .sliders import NiceSlider
from .nice_checkbox import NiceCheckbox
from .dialogs import (
show_message_dialog,
ScrollMessageBox,
SimplePopup,
PopupUpdateKeys,
)


__all__ = (
Expand Down Expand Up @@ -110,4 +116,9 @@
"NiceSlider",

"NiceCheckbox",

"show_message_dialog",
"ScrollMessageBox",
"SimplePopup",
"PopupUpdateKeys",
)
Loading

0 comments on commit 8745c2c

Please sign in to comment.