AzAssetBrowserWindow.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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/Memory/SystemAllocator.h>
  11. #include <QWidget>
  12. #include <QMenu>
  13. #endif
  14. class QItemSelection;
  15. namespace Ui
  16. {
  17. class AzAssetBrowserWindowClass;
  18. }
  19. namespace AzToolsFramework
  20. {
  21. namespace AssetBrowser
  22. {
  23. class AssetBrowserEntry;
  24. class AssetBrowserFilterModel;
  25. class AssetBrowserListModel;
  26. class AssetBrowserModel;
  27. class AssetBrowserFilterModel;
  28. class AssetBrowserTreeView;
  29. enum class AssetBrowserDisplayState : int
  30. {
  31. TreeViewMode,
  32. ListViewMode,
  33. Invalid
  34. };
  35. enum class AssetBrowserMode : int
  36. {
  37. ThumbnailView,
  38. TableView,
  39. ListView
  40. };
  41. } // namespace AssetBrowser
  42. } // namespace AzToolsFramework
  43. class AzAssetBrowserWindow : public QWidget
  44. {
  45. Q_OBJECT
  46. public:
  47. AZ_CLASS_ALLOCATOR(AzAssetBrowserWindow, AZ::SystemAllocator);
  48. explicit AzAssetBrowserWindow(QWidget* parent = nullptr);
  49. virtual ~AzAssetBrowserWindow();
  50. void SelectAsset(const QString& assetPath);
  51. static void RegisterViewClass();
  52. static QObject* createListenerForShowAssetEditorEvent(QObject* parent);
  53. bool ViewWidgetBelongsTo(QWidget* viewWidget);
  54. AzToolsFramework::AssetBrowser::AssetBrowserMode GetCurrentMode() const;
  55. void SetCurrentMode(const AzToolsFramework::AssetBrowser::AssetBrowserMode mode);
  56. Q_SIGNALS:
  57. void SizeChangedSignal(int newWidth);
  58. protected:
  59. void resizeEvent(QResizeEvent* resizeEvent) override;
  60. private:
  61. void UpdateDisplayInfo();
  62. void SetNarrowMode(bool narrow);
  63. protected slots:
  64. void CreateToolsMenu();
  65. void AddCreateMenu();
  66. void SetTreeViewMode();
  67. void SetListViewMode();
  68. void UpdateWidgetAfterFilter();
  69. void SetTwoColumnMode(QWidget* viewToShow);
  70. void SetOneColumnMode();
  71. void OnDoubleClick(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry);
  72. private:
  73. QScopedPointer<Ui::AzAssetBrowserWindowClass> m_ui;
  74. QScopedPointer<AzToolsFramework::AssetBrowser::AssetBrowserFilterModel> m_filterModel;
  75. QScopedPointer<AzToolsFramework::AssetBrowser::AssetBrowserListModel> m_listModel;
  76. AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel;
  77. QMenu* m_toolsMenu = nullptr;
  78. QMenu* m_createMenu = nullptr;
  79. QAction* m_treeViewMode = nullptr;
  80. QAction* m_listViewMode = nullptr;
  81. AzToolsFramework::AssetBrowser::AssetBrowserDisplayState m_assetBrowserDisplayState =
  82. AzToolsFramework::AssetBrowser::AssetBrowserDisplayState::ListViewMode;
  83. AzToolsFramework::AssetBrowser::AssetBrowserMode m_currentMode = AzToolsFramework::AssetBrowser::AssetBrowserMode::ThumbnailView;
  84. //! Updates breadcrumbs with the selectedEntry relative path if it's a folder or with the
  85. //! relative path of the first folder parent of the passed entry.
  86. //! Clears breadcrumbs if nullptr is passed or there's no folder parent.
  87. void UpdateBreadcrumbs(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* selectedEntry) const;
  88. bool m_inNarrowMode = false;
  89. private Q_SLOTS:
  90. void CurrentIndexChangedSlot(const QModelIndex& idx) const;
  91. void DoubleClickedItem(const QModelIndex& element);
  92. void BreadcrumbsPathChangedSlot(const QString& path) const;
  93. };
  94. extern const char* AZ_ASSET_BROWSER_PREVIEW_NAME;