2
"""Contains misc utiltiies"""
3
__docformat__ = "restructuredtext"
6
import mrv.maya.ui as ui
8
def concat_url(root, path):
9
if not root.endswith("/"):
13
def handleUnsavedModifications():
14
"""Ask the user whether he wants to handle his unsaved modifications.
15
This may cause the current file to be saved, or the modifications to be
17
:return: True if the changes have been handled properly, or False if the
18
caller should not proceed"""
19
if not mrv.maya.Scene.isModified():
22
save = "Save and Proceed"
24
discard = "Discard Modifications"
25
msg = "The currently loaded scene contains unsaved modifications.\n"
26
msg += "Would you like to discard them, or save the scene before proceeding ?"
27
answer = ui.ChoiceDialog( t="Unsaved Modifications",
29
c=[save, discard, abort],
34
if mrv.maya.Scene.name().endswith("untitled"):
37
maya.cmds.layoutDialog(ui=lambda *args: layout.FileSaveFinder(defaultRoots=True))
39
# still no valid name ?
40
if mrv.maya.Scene.name().endswith("untitled"):
42
# END handle untitled file
44
elif answer == discard:
45
mrv.maya.Scene.new(force=True)
53
class FrameDecorator(ui.FrameLayout):
54
"""A simple helper to wrap a box around a layout or control."""
55
def __new__(cls, name, layoutCreator):
56
"""Provide the name of the decorator, which will be wrapped around the layoutCreator,
57
which will be called to create the layout. It will be kept and mayde availale
58
through the 'layout' member, the currently available layout will not be changed."""
59
self = super(FrameDecorator, cls).__new__(cls, label=name, borderStyle="etchedOut")
60
self.layout = layoutCreator()
61
self.setParentActive();