3
0

SettingsDialog.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 <QDialog>
  11. #include <AzCore/std/smart_ptr/unique_ptr.h>
  12. #include <AzCore/UserSettings/UserSettings.h>
  13. #include <AzCore/Component/EntityId.h>
  14. #include <Editor/Settings.h>
  15. #include <ScriptCanvas/Core/Core.h>
  16. #endif
  17. namespace Ui
  18. {
  19. class SettingsDialog;
  20. }
  21. namespace AzToolsFramework
  22. {
  23. class ReflectedPropertyEditor;
  24. }
  25. namespace ScriptCanvasEditor
  26. {
  27. class Settings
  28. : public AZ::UserSettings
  29. {
  30. public:
  31. AZ_RTTI(Settings, "{E3B5DE71-FB4E-472C-BD2A-BD180E68B9A6}", AZ::UserSettings);
  32. AZ_CLASS_ALLOCATOR(Settings, AZ::SystemAllocator);
  33. Settings()
  34. : m_enableLogging(false)
  35. {}
  36. bool m_enableLogging;
  37. static void Reflect(AZ::ReflectContext* reflection);
  38. };
  39. enum class SettingsType
  40. {
  41. None,
  42. All,
  43. General,
  44. Graph
  45. };
  46. class SettingsDialog
  47. : public QDialog
  48. {
  49. Q_OBJECT
  50. public:
  51. SettingsDialog(const QString& title, ScriptCanvas::ScriptCanvasId scriptCanvasId, QWidget* pParent = nullptr);
  52. ~SettingsDialog() override;
  53. const QString& GetText() const { return m_text; }
  54. protected:
  55. void OnOK();
  56. void OnCancel();
  57. void OnTextChanged(const QString& text);
  58. void ConfigurePropertyEditor(AzToolsFramework::ReflectedPropertyEditor*);
  59. private:
  60. void SetType(SettingsType settingsType);
  61. void SetupGeneralSettings(AZ::SerializeContext* context);
  62. void SetupGraphSettings(AZ::SerializeContext* context);
  63. void RevertSettings();
  64. QString m_text;
  65. ScriptCanvas::ScriptCanvasId m_scriptCanvasId;
  66. bool m_revertOnClose;
  67. Settings m_originalSettings;
  68. EditorSettings::ScriptCanvasEditorSettings m_originalEditorSettings;
  69. SettingsType m_settingsType = SettingsType::None;
  70. Ui::SettingsDialog* ui;
  71. };
  72. }