From 3c7ca7269310959112c27da90a0af6ff698e15e7 Mon Sep 17 00:00:00 2001 From: Benjamin Jillich <43751992+amzn-jillich@users.noreply.github.com> Date: Mon, 3 May 2021 18:45:35 +0200 Subject: [PATCH] [LYN-3269] EMotionFX Editor save changed files prompts users to save files to the cache (#469) * The asset source filename is now displayed instead of the product filename. * Fixed a stylesheet issue with screen scaling on 4K monitors for the saved changed files window. * Cleaned up surrounding code. --- .../Source/SaveChangedFilesManager.cpp | 41 ++++++++++++------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.cpp index 4824821a61..28a4fb9c92 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/SaveChangedFilesManager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -398,33 +399,49 @@ namespace EMStudio const size_t numDirtyFiles = dirtyFileNames.size(); mTableWidget->setRowCount(static_cast(numDirtyFiles)); - AZStd::string extension, typeString, filenameText, path, filenameOnly; for (size_t i = 0; i < numDirtyFiles; ++i) { SaveDirtyFilesCallback::ObjectPointer object = mObjects[i]; + QString labelText; if (dirtyFileNames[i].empty()) { - filenameText = ""; + labelText = ""; } else { - AzFramework::StringFunc::Path::GetFullPath(dirtyFileNames[i].c_str(), path); - AzFramework::StringFunc::Path::GetFullFileName(dirtyFileNames[i].c_str(), filenameOnly); - - filenameText = AZStd::string::format("%s%s", path.c_str(), filenameOnly.c_str()); + const AZStd::string& productFilename = dirtyFileNames[i]; + + // Get the asset source name from the product filename. + bool sourceAssetFound = false; + AZStd::string sourceAssetFilename; + AzToolsFramework::AssetSystemRequestBus::BroadcastResult(sourceAssetFound, + &AzToolsFramework::AssetSystemRequestBus::Events::GetFullSourcePathFromRelativeProductPath, + productFilename, + sourceAssetFilename); + + const AZStd::string usedFilename = sourceAssetFound ? sourceAssetFilename : dirtyFileNames[i]; + + // Separate the path from the filename, so that we can display the filename in bold. + AZStd::string fullPath; + AzFramework::StringFunc::Path::GetFullPath(usedFilename.c_str(), fullPath); + AzFramework::StringFunc::RelativePath::Normalize(fullPath); // Add trailing slash in case it is missing + AZStd::string fullFilename; + AzFramework::StringFunc::Path::GetFullFileName(usedFilename.c_str(), fullFilename); + labelText = QString("%1%2").arg(fullPath.c_str(), fullFilename.c_str()); } // create the checkbox QCheckBox* checkbox = new QCheckBox(""); - checkbox->setStyleSheet("background: transparent; padding-left: 3px; max-width: 13px;"); + checkbox->setStyleSheet("background: transparent;"); checkbox->setChecked(true); // create the filename table item QLabel* filenameLabel = new QLabel(); - filenameLabel->setToolTip(filenameText.c_str()); - filenameLabel->setText(filenameText.c_str()); + filenameLabel->setToolTip(labelText); + filenameLabel->setText(labelText); + QString typeString; if (object.mMotion) { typeString = "Motion"; @@ -445,12 +462,8 @@ namespace EMStudio { typeString = "Workspace"; } - else - { - typeString = ""; - } - QTableWidgetItem* itemType = new QTableWidgetItem(typeString.c_str()); + QTableWidgetItem* itemType = new QTableWidgetItem(typeString); const int row = static_cast(i); itemType->setData(Qt::UserRole, row);