Implemented helper method of QFileDialog::getSaveFileName to prevent user from saving files with invalid names.

Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
Chris Galvan
2021-08-27 11:24:05 -05:00
parent 9e5ef08229
commit d590a91fe7
14 changed files with 127 additions and 49 deletions
@@ -24,6 +24,7 @@
#include <AzCore/Serialization/SerializeContext.h>
#include <AzCore/std/numeric.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzQtComponents/Components/Widgets/FileDialog.h>
#include <AzToolsFramework/API/ComponentEntitySelectionBus.h>
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
#include <AzToolsFramework/API/EditorPythonRunnerRequestsBus.h>
@@ -31,7 +32,6 @@
#include <AzToolsFramework/Entity/EditorEntityInfoBus.h>
#include <AzToolsFramework/Maths/TransformUtils.h>
#include <AzToolsFramework/UI/UICore/WidgetHelpers.h>
#include <QFileDialog>
#include <QMessageBox>
#include <WhiteBox/EditorWhiteBoxColliderBus.h>
#include <WhiteBox/WhiteBoxBus.h>
@@ -513,7 +513,7 @@ namespace WhiteBox
WhiteBoxPathAtProjectRoot(GetEntity()->GetName(), ObjExtension);
const QString fileFilter = AZStd::string::format("*.%s", ObjExtension).c_str();
const QString absoluteSaveFilePath = QFileDialog::getSaveFileName(
const QString absoluteSaveFilePath = AzQtComponents::FileDialog::GetSaveFileName(
nullptr, "Save As...", QString(initialAbsolutePathToExport.c_str()), fileFilter);
const auto absoluteSaveFilePathUtf8 = absoluteSaveFilePath.toUtf8();
@@ -577,7 +577,7 @@ namespace WhiteBox
{
const QString fileFilter =
AZStd::string::format("*.%s", Pipeline::WhiteBoxMeshAssetHandler::AssetFileExtension).c_str();
const QString absolutePath = QFileDialog::getSaveFileName(
const QString absolutePath = AzQtComponents::FileDialog::GetSaveFileName(
nullptr, "Save As Asset...", QString(initialAbsolutePath.c_str()), fileFilter);
return AZStd::string(absolutePath.toUtf8());