2
0

NewFileDialog.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #if !defined(Q_MOC_RUN)
  10. #include <AzCore/std/string/string.h>
  11. #include <AzFramework/Platform/PlatformDefaults.h>
  12. #include <QDialog>
  13. #include <QFileDialog>
  14. #include <QSharedPointer>
  15. #endif
  16. namespace Ui
  17. {
  18. class NewFileDialog;
  19. }
  20. namespace AssetBundler
  21. {
  22. class GUIApplicationManager;
  23. class NewFileDialog
  24. : public QDialog
  25. {
  26. Q_OBJECT
  27. public:
  28. explicit NewFileDialog(
  29. QWidget* parent,
  30. const QString& dialogTitle,
  31. const QString& startingPath,
  32. const char* fileExtension,
  33. const QString& fileNameFilter,
  34. const AzFramework::PlatformFlags& enabledPlatforms,
  35. bool isRunningRule = false);
  36. virtual ~NewFileDialog() {}
  37. AZStd::string GetAbsoluteFilePath();
  38. AzFramework::PlatformFlags GetPlatformFlags();
  39. //! A standard OS-specific New File Dialog, but blocks all Qt signals from the dialog and does NOT create a new file.
  40. //! Use in place of the static QFileDialog functions to avoid unexpected file watcher updates.
  41. //! Returns the absolute path of the file the user either selected or attempted to create, or an empty string if the user canceled out of the dialog.
  42. static AZStd::string OSNewFileDialog(
  43. QWidget* parent,
  44. const char* fileExtension,
  45. const char* fileTypeDisplayName,
  46. const AZStd::string& startingDirectory);
  47. static int FileGenerationResultMessageBox(
  48. QWidget* parent,
  49. const AZStd::vector<AZStd::string>& generatedFiles,
  50. bool generatedWithErrors);
  51. private:
  52. void OnBrowseButtonPressed();
  53. void OnPlatformSelectionChanged(const AzFramework::PlatformFlags& selectedPlatforms);
  54. void OnCreateFileButtonPressed();
  55. QSharedPointer<Ui::NewFileDialog> m_ui;
  56. QString m_startingPath;
  57. const char* m_fileExtension;
  58. QFileDialog m_newFileDialog;
  59. AZStd::string m_absoluteFilePath;
  60. bool m_fileNameIsValid = false;
  61. bool m_platformIsValid = false;
  62. };
  63. } // namespace AssetBundler