PathContextMenu.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // Copyright 2017-2021 marynate. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "Input/Reply.h"
  5. //#include "Editor/ContentBrowser/Private/NewAssetOrClassContextMenu.h"
  6. class FExtender;
  7. class FMenuBuilder;
  8. class SWidget;
  9. class SWindow;
  10. class FPathContextMenu : public TSharedFromThis<FPathContextMenu>
  11. {
  12. public:
  13. /** Constructor */
  14. FPathContextMenu(const TWeakPtr<SWidget>& InParentContent);
  15. /** Delegate for when the context menu requests a rename of a folder */
  16. DECLARE_DELEGATE_OneParam(FOnRenameFolderRequested, const FString& /*FolderToRename*/);
  17. void SetOnRenameFolderRequested(const FOnRenameFolderRequested& InOnRenameFolderRequested);
  18. /** Delegate for when the context menu has successfully deleted a folder */
  19. DECLARE_DELEGATE(FOnFolderDeleted)
  20. void SetOnFolderDeleted(const FOnFolderDeleted& InOnFolderDeleted);
  21. /** Delegate for when the context menu has successfully toggled the favorite status of a folder */
  22. DECLARE_DELEGATE_OneParam(FOnFolderFavoriteToggled, const TArray<FString>& /*FoldersToToggle*/)
  23. void SetOnFolderFavoriteToggled(const FOnFolderFavoriteToggled& InOnFolderFavoriteToggled);
  24. /** Gets the currently selected paths */
  25. const TArray<FString>& GetSelectedPaths() const;
  26. /** Sets the currently selected paths */
  27. void SetSelectedPaths(const TArray<FString>& InSelectedPaths);
  28. /** Makes the asset tree context menu extender */
  29. TSharedRef<FExtender> MakePathViewContextMenuExtender(const TArray<FString>& InSelectedPaths);
  30. /** Makes the asset tree context menu widget */
  31. void MakePathViewContextMenu(FMenuBuilder& MenuBuilder);
  32. /** Handler to check to see if creating a new asset is allowed */
  33. bool CanCreateAsset() const;
  34. /** Makes the new asset submenu */
  35. void MakeNewAssetSubMenu(FMenuBuilder& MenuBuilder);
  36. /** Makes the set color submenu */
  37. void MakeSetColorSubMenu(FMenuBuilder& MenuBuilder);
  38. /** Handler for when "Migrate Folder" is selected */
  39. void ExecuteMigrateFolder();
  40. /** Handler for when "Explore" is selected */
  41. void ExecuteExplore();
  42. /** Handler for when "Apply Project Folder Colors" is selected */
  43. void ExecuteApplyProjectFolderColors();
  44. /** Handler for when "ValidateAssets" is selected */
  45. void ExecuteValidateAssetsInFolder();
  46. /** Handler to check to see if a rescan content folder command is allowed */
  47. bool CanExecuteRescanFolder() const;
  48. /** Handler to check to see if a import content folder command is allowed */
  49. bool CanExecuteImportFolder() const;
  50. /** Handler to check to see if it's a project folder */
  51. bool CanExecuteApplyProjectFolderColors() const;
  52. /** Handler for Rescan Content Folder */
  53. void ExecuteRescanFolder();
  54. /** Handler for Import Content Folder */
  55. void ExecuteImportFolder();
  56. /** Handler to check to see if a remove content folder command is allowed */
  57. bool CanExecuteRootDirsActions() const;
  58. /** Handler for Reload Content Folder */
  59. void ExecuteReloadRootFolder();
  60. /** Handler for Remove Content Folder */
  61. void ExecuteRemoveRootFolder();
  62. /** Handler for Add Content Folder */
  63. void ExecuteAddRootFolder();
  64. /** Handler for export Content Folder list*/
  65. void ExecuteExportRootFolderList();
  66. void LoadRootFolderList(bool bReplaceCurrent);
  67. /** Handler for load and merge Content Folder list*/
  68. void ExecuteLoadAndMergeRootFolderList();
  69. /** Handler for load and replace Content Folder list*/
  70. void ExecuteLoadAndReplaceRootFolderList();
  71. /** Handler to check to see if a rename command is allowed */
  72. bool CanExecuteRename() const;
  73. /** Handler for Rename */
  74. void ExecuteRename();
  75. /** Handler to check to see if a delete command is allowed */
  76. bool CanExecuteDelete() const;
  77. /** Handler for Delete */
  78. void ExecuteDelete();
  79. /** Handler for when reset color is selected */
  80. void ExecuteResetColor();
  81. /** Handler for when new or set color is selected */
  82. void ExecutePickColor();
  83. /** Handler for favoriting */
  84. void ExecuteFavorite();
  85. /** Handler for when "Save" is selected */
  86. void ExecuteSaveFolder();
  87. /** Handler for when "Resave" is selected */
  88. void ExecuteResaveFolder();
  89. /** Handler for when "Fix up Redirectors in Folder" is selected */
  90. void ExecuteFixUpRedirectorsInFolder();
  91. /** Handler for when "Delete" is selected and the delete was confirmed */
  92. FReply ExecuteDeleteFolderConfirmed();
  93. private:
  94. /** Initializes some variable used to in "CanExecute" checks that won't change at runtime or are too expensive to check every frame. */
  95. void CacheCanExecuteVars();
  96. /** Returns a list of names of packages in all selected paths in the sources view */
  97. void GetPackageNamesInSelectedPaths(TArray<FString>& OutPackageNames) const;
  98. /** Gets the first selected path, if it exists */
  99. FString GetFirstSelectedPath() const;
  100. /** Checks to see if any of the selected paths use custom colors */
  101. bool SelectedHasCustomColors() const;
  102. /** Callback when the color picker dialog has been closed */
  103. void NewColorComplete(const TSharedRef<SWindow>& Window);
  104. /** Callback when the color is picked from the set color submenu */
  105. FReply OnColorClicked( const FLinearColor InColor );
  106. /** Resets the colors of the selected paths */
  107. void ResetColors();
  108. private:
  109. TArray<FString> SelectedPaths;
  110. TWeakPtr<SWidget> ParentContent;
  111. FOnRenameFolderRequested OnRenameFolderRequested;
  112. FOnFolderDeleted OnFolderDeleted;
  113. FOnFolderFavoriteToggled OnFolderFavoriteToggled;
  114. bool bCanExecuteRootDirsActions;
  115. bool bHasSelectedPath;
  116. bool bRescanFolderAndAssetsInSelecteFolder = false;
  117. };