Merge pull request #128 from aardschok/PLN-112

Add warning dialog for import
This commit is contained in:
Wijnand Koreman 2018-07-06 12:02:34 +02:00 committed by GitHub
commit fccae0aeee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -101,6 +101,10 @@ class ImportMayaLoader(api.Loader):
from avalon import maya
from avalon.maya import lib
choice = self.display_warning()
if choice is False:
return
asset = context['asset']
namespace = namespace or lib.unique_namespace(
@ -119,3 +123,25 @@ class ImportMayaLoader(api.Loader):
# We do not containerize imported content, it remains unmanaged
return
def display_warning(self):
"""Show warning to ensure the user can't import models by accident
Returns:
bool
"""
from avalon.vendor.Qt import QtWidgets
accept = QtWidgets.QMessageBox.Ok
buttons = accept | QtWidgets.QMessageBox.Cancel
message = "Are you sure you want import this"
state = QtWidgets.QMessageBox.warning(None,
"Are you sure?",
message,
buttons=buttons,
defaultButton=accept)
return state == accept