ErrorDialog.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 "Include/EditorCoreAPI.h"
  12. #endif
  13. namespace Ui
  14. {
  15. class ErrorLogDialog;
  16. }
  17. class QItemSelection;
  18. namespace SandboxEditor
  19. {
  20. /// Used to display a collection of error and warning messages.
  21. /// This is used instead of QMessageBox because the details section of QMessageBox is not
  22. /// very resizeable, making it hard to show multiple errors at once.
  23. class EDITOR_CORE_API ErrorDialog
  24. : public QDialog
  25. {
  26. Q_OBJECT
  27. public:
  28. enum class MessageType
  29. {
  30. Warning,
  31. Error
  32. };
  33. //! ErrorDialog constructor.
  34. //! @param parent the optional QWidget to use as a parent.
  35. explicit ErrorDialog(QWidget* parent = nullptr);
  36. ~ErrorDialog();
  37. //! Adds messages to the dialog, marked with the passed in message type.
  38. //! @param messageType what message type to use to mark passed in messages.
  39. //! @param messages the list of messages to add.
  40. void AddMessages(MessageType messageType, const AZStd::list<QString>& messages);
  41. protected Q_SLOTS:
  42. void OnOK();
  43. void MessageSelectionChanged();
  44. private:
  45. /// Tracks which column the message information is used in.
  46. enum class MessageColumn
  47. {
  48. MessageType,
  49. ShortMessage,
  50. DetailedMessage,
  51. };
  52. //! Converts MessageType to QString.
  53. //! @param messageType the message type to convert.
  54. //! @return the QString representation of that message type.
  55. QString GetMessageTypeString(MessageType messageType) const;
  56. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  57. QScopedPointer<Ui::ErrorLogDialog> m_ui; ///< Tracks the Qt UI associated with this class.
  58. QSet<QString> m_uniqueStrings;
  59. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  60. };
  61. }