Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Enhancement: Add a warning when a workfile will be saved in different…
Browse files Browse the repository at this point in the history
… context
  • Loading branch information
Cyprien CAILLOT committed Sep 11, 2024
1 parent d9731d0 commit 456b777
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions openpype/tools/workfiles/save_as_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
registered_host,
legacy_io,
)
from openpype.pipeline.context_tools import (
get_current_task_name,
get_current_asset_name
)
from openpype.pipeline.workfile import get_last_workfile_with_version
from openpype.pipeline.template_data import get_template_data_with_names
from openpype.tools.utils import PlaceholderLineEdit
Expand Down Expand Up @@ -243,6 +247,24 @@ def __init__(

# Preview widget
preview_label = QtWidgets.QLabel("Preview filename", inputs_widget)
current_task_name = get_current_task_name()
target_task_name = self.data.get("task").get("name")
current_asset_name = get_current_asset_name()
target_asset_name = self.data.get("asset")
task_warning_label = QtWidgets.QLabel(
"<font color='red'>Warning: You are saving to a different task "
"than the current one. "
"Current task: {}. Target task: {}"
"</font>".format(current_task_name, target_task_name),
alignment=QtCore.Qt.AlignHCenter
)
asset_warning_label = QtWidgets.QLabel(
"<font color='red'>Warning: You are saving to a different asset "
"than the current one. "
"Current asset: {}. Target asset: {}"
"</font>".format(current_asset_name, target_asset_name),
alignment=QtCore.Qt.AlignHCenter
)

# Subversion input
subversion = SubversionLineEdit(inputs_widget)
Expand Down Expand Up @@ -290,6 +312,10 @@ def __init__(
subversion.setVisible(False)
inputs_layout.addRow("Extension:", ext_combo)
inputs_layout.addRow("Preview:", preview_label)
if current_asset_name != target_asset_name:
inputs_layout.addRow(asset_warning_label)
if current_task_name != target_task_name:
inputs_layout.addRow(task_warning_label)

# Build layout
main_layout = QtWidgets.QVBoxLayout(self)
Expand Down Expand Up @@ -324,6 +350,8 @@ def __init__(
self.last_version_check = last_version_check

self.preview_label = preview_label
self.task_warning_label = task_warning_label
self.asset_warning_label = asset_warning_label
self.subversion = subversion
self.ext_combo = ext_combo
self._ext_delegate = ext_delegate
Expand Down

0 comments on commit 456b777

Please sign in to comment.