AzAssetBrowserWindow.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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, bool assetIsFolder = false);
  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. void SetFavoritesWindowHeight(int height);
  57. Q_SIGNALS:
  58. void SizeChangedSignal(int newWidth);
  59. protected:
  60. void resizeEvent(QResizeEvent* resizeEvent) override;
  61. private:
  62. void UpdateDisplayInfo();
  63. void SetNarrowMode(bool narrow);
  64. void SelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
  65. int GetSelectionCount();
  66. protected slots:
  67. void CreateToolsMenu();
  68. void AddCreateMenu();
  69. void SetTreeViewMode();
  70. void SetListViewMode();
  71. void UpdateWidgetAfterFilter();
  72. void SetTwoColumnMode(QWidget* viewToShow);
  73. void SetOneColumnMode();
  74. void AddFavoriteSearchButtonPressed();
  75. void AddFavoriteEntriesButtonPressed();
  76. void OnDoubleClick(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry);
  77. private:
  78. QScopedPointer<Ui::AzAssetBrowserWindowClass> m_ui;
  79. QScopedPointer<AzToolsFramework::AssetBrowser::AssetBrowserFilterModel> m_filterModel;
  80. QScopedPointer<AzToolsFramework::AssetBrowser::AssetBrowserListModel> m_listModel;
  81. AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel;
  82. QMenu* m_toolsMenu = nullptr;
  83. QMenu* m_createMenu = nullptr;
  84. QAction* m_treeViewMode = nullptr;
  85. QAction* m_listViewMode = nullptr;
  86. AzToolsFramework::AssetBrowser::AssetBrowserDisplayState m_assetBrowserDisplayState =
  87. AzToolsFramework::AssetBrowser::AssetBrowserDisplayState::ListViewMode;
  88. AzToolsFramework::AssetBrowser::AssetBrowserMode m_currentMode = AzToolsFramework::AssetBrowser::AssetBrowserMode::ThumbnailView;
  89. //! Updates breadcrumbs with the selectedEntry relative path if it's a folder or with the
  90. //! relative path of the first folder parent of the passed entry.
  91. //! Clears breadcrumbs if nullptr is passed or there's no folder parent.
  92. void UpdateBreadcrumbs(const AzToolsFramework::AssetBrowser::AssetBrowserEntry* selectedEntry) const;
  93. bool m_inNarrowMode = false;
  94. private Q_SLOTS:
  95. void CurrentIndexChangedSlot(const QModelIndex& idx) const;
  96. void DoubleClickedItem(const QModelIndex& element);
  97. void BreadcrumbsPathChangedSlot(const QString& path) const;
  98. void OnFilterCriteriaChanged();
  99. };
  100. extern const char* AZ_ASSET_BROWSER_PREVIEW_NAME;