mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
Added dialog to confirm before deleting files
This commit is contained in:
parent
465101c639
commit
de2a6c3324
1 changed files with 37 additions and 2 deletions
|
|
@ -1,10 +1,10 @@
|
|||
import unreal
|
||||
|
||||
from openpype.hosts.unreal.api.tools_ui import qt_app_context
|
||||
from openpype.hosts.unreal.api.pipeline import delete_asset_if_unused
|
||||
from openpype.pipeline import InventoryAction
|
||||
|
||||
|
||||
|
||||
class DeleteUnusedAssets(InventoryAction):
|
||||
"""Delete all the assets that are not used in any level.
|
||||
"""
|
||||
|
|
@ -14,7 +14,9 @@ class DeleteUnusedAssets(InventoryAction):
|
|||
color = "red"
|
||||
order = 1
|
||||
|
||||
def process(self, containers):
|
||||
dialog = None
|
||||
|
||||
def _delete_unused_assets(self, containers):
|
||||
allowed_families = ["model", "rig"]
|
||||
|
||||
for container in containers:
|
||||
|
|
@ -29,3 +31,36 @@ class DeleteUnusedAssets(InventoryAction):
|
|||
)
|
||||
|
||||
delete_asset_if_unused(container, asset_content)
|
||||
|
||||
def _show_confirmation_dialog(self, containers):
|
||||
from qtpy import QtCore
|
||||
from openpype.widgets import popup
|
||||
from openpype.style import load_stylesheet
|
||||
|
||||
dialog = popup.Popup()
|
||||
dialog.setWindowFlags(
|
||||
QtCore.Qt.Window
|
||||
| QtCore.Qt.WindowStaysOnTopHint
|
||||
)
|
||||
dialog.setFocusPolicy(QtCore.Qt.StrongFocus)
|
||||
dialog.setWindowTitle("Delete all unused assets")
|
||||
dialog.setMessage(
|
||||
"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.on_clicked.connect(
|
||||
lambda: self._delete_unused_assets(containers)
|
||||
)
|
||||
|
||||
dialog.show()
|
||||
dialog.raise_()
|
||||
dialog.activateWindow()
|
||||
dialog.setStyleSheet(load_stylesheet())
|
||||
|
||||
self.dialog = dialog
|
||||
|
||||
def process(self, containers):
|
||||
with qt_app_context():
|
||||
self._show_confirmation_dialog(containers)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue