Skip to content

Commit

Permalink
Merge pull request #3960 from Autodesk/bailp/EMSUSD-1718/hide-prefs-f…
Browse files Browse the repository at this point in the history
…or-units

EMSUSD-1718 automatically close prefs when changing units
  • Loading branch information
seando-adsk authored Oct 17, 2024
2 parents 3e504e7 + ce29fc9 commit 3d22346
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions lib/mayaUsd/fileio/jobs/readJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,34 @@ void UsdMaya_ReadJob::_ConvertUpAxisAndUnitsByChangingMayaPrefs(
{
bool success = true;

// Close preference window if needed.
{
static const char* closePrefsCmd
= "global string $gPreferenceWindow;\n"
"if (`window -query -exists $gPreferenceWindow`) {\n"
" if (`window -query -visible $gPreferenceWindow`) {\n"
" string $title = getMayaUsdLibString(\"kAboutToChangePrefsTitle\");\n"
" string $body = getMayaUsdLibString(\"kAboutToChangePrefs\");\n"
" string $ok = getMayaUsdLibString(\"kSavePrefsChange\");\n"
" string $cancel = getMayaUsdLibString(\"kDiscardPrefsChange\");\n"
" string $result = `confirmDialog -title $title -message $body\n"
" -button $ok -button $cancel\n"
" -defaultButton $ok\n"
" -cancelButton $cancel`;\n"
" if ($result == $ok) {\n"
" savePrefsChanges;\n"
" }\n"
" else {\n"
" cancelPrefsChanges;\n"
" }\n"
" }\n"
"}\n";

if (!MGlobal::executeCommand(closePrefsCmd)) {
MGlobal::displayWarning("Failed to close the Maya preferences windows.");
}
}

// Set up-axis preferences if needed.
if (conversion.needUpAxisConversion) {
const bool rotateView = true;
Expand Down
7 changes: 7 additions & 0 deletions lib/mayaUsd/resources/scripts/mayaUsdLibRegisterStrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ def unregisterPluginResource(pluginId, stringId):
return
cmds.displayString(fullId, delete=True)

# readJob.cpp
register("kAboutToChangePrefs", "The USD import is about to change the Maya preferences.\n" +
"Save your changes in the preferences window?")
register("kAboutToChangePrefsTitle", "Save Preferences")
register("kSavePrefsChange", "Save Preferences")
register("kDiscardPrefsChange", "Discard Preferences")


def registerPluginResource(pluginId, stringId, resourceStr):
'''See registerPluginResource.mel in Maya.
Expand Down

0 comments on commit 3d22346

Please sign in to comment.