Files
UnrealEngineUWP/Engine/Source/Editor/SourceControlWindows/Public/SourceControlWindows.h
julien lheureux 8d3734f953 Added contextual menu options for file actions (diff agains depot, show history, locate file)
Better cleanup in perforce revert operation
Made revert work on changelists
Fixed issue where no changelists would be displayed if the default changelist was empty.

#rb sebastien.lussier

[CL 15138037 by julien lheureux in ue5-main branch]
2021-01-19 14:50:23 -04:00

121 lines
5.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "SlateFwd.h"
#include "ISourceControlProvider.h"
/** Info supplied as argument to delegate FSourceControlWindowsOnCheckInComplete called by FSourceControlWindows::ChoosePackagesToCheckIn() and optional argument to PromptForCheckin(). */
struct SOURCECONTROLWINDOWS_API FCheckinResultInfo
{
/** Default Constructor */
FCheckinResultInfo();
/** Succeeded - if packages were selected and successfully checked in, Cancelled - if the user aborted the process, Failed - if an issue was encountered during the process */
ECommandResult::Type Result;
/** true if added and modified files were automatically checked out from source control again after being submitted, false if not */
bool bAutoCheckedOut;
/** Files that were added. */
TArray<FString> FilesAdded;
/** Files that were modified and checked in. */
TArray<FString> FilesSubmitted;
/** Text that describes result whether failed, cancelled or successful. */
FText Description;
};
/** Optional delegate called when FSourceControlWindows::ChoosePackagesToCheckIn() completes. */
DECLARE_DELEGATE_OneParam(FSourceControlWindowsOnCheckInComplete, const FCheckinResultInfo&);
class SOURCECONTROLWINDOWS_API FSourceControlWindows
{
public:
/**
* Get the list of files and directories that source control should check when looking for changes.
*
* @param bContentOnly True to only include content directories.
*/
static TArray<FString> GetSourceControlLocations(const bool bContentOnly = false);
/**
* Opens a user dialog to choose packages to submit.
*
* @param OnCompleteDelegate Delegate to call when this user-based operation is complete. Also see FCheckinResultInfo.
* @return true - if command successfully in progress and OnCompleteDelegate will be called when complete, false - if immediately unable to comply (such as source control not enabled)
*/
static bool ChoosePackagesToCheckIn(const FSourceControlWindowsOnCheckInComplete& OnCompleteDelegate = FSourceControlWindowsOnCheckInComplete());
/** Determines whether we can choose packages to check in (we cant if an operation is already in progress) */
static bool CanChoosePackagesToCheckIn();
/**
* Display check in dialog for the specified packages and get additional result information
*
* @param OutResultInfo Optional FCheckinResultInfo to store information about checked in files and whether the check in was successful
* @param InPackageNames Names of packages to check in
* @param InPendingDeletePaths Directories to check for files marked 'pending delete'
* @param InConfigFiles Config filenames to check in
* @param bUseSourceControlStateCache Whether to use the cached source control status, or force the status to be updated
*
* @return true - if completed successfully in progress and OnCompleteDelegate will be called when complete, false - if immediately unable to comply (such as source control not enabled)
*/
static bool PromptForCheckin(FCheckinResultInfo& OutResultInfo, const TArray<FString>& InPackageNames, const TArray<FString>& InPendingDeletePaths = TArray<FString>(), const TArray<FString>& InConfigFiles = TArray<FString>(), bool bUseSourceControlStateCache = false);
/**
* Display check in dialog for the specified packages
*
* @param bUseSourceControlStateCache Whether to use the cached source control status, or force the status to be updated
* @param InPackageNames Names of packages to check in
* @param InPendingDeletePaths Directories to check for files marked 'pending delete'
* @param InConfigFiles Config filenames to check in
*
* @return true - if completed successfully in progress and OnCompleteDelegate will be called when complete, false - if immediately unable to comply (such as source control not enabled)
*/
static bool PromptForCheckin(bool bUseSourceControlStateCache, const TArray<FString>& InPackageNames, const TArray<FString>& InPendingDeletePaths = TArray<FString>(), const TArray<FString>& InConfigFiles = TArray<FString>());
/**
* Display file revision history for the provided packages
*
* @param InPackageNames Names of packages to display file revision history for
*/
static void DisplayRevisionHistory( const TArray<FString>& InPackagesNames );
/**
* Prompt the user with a revert files dialog, allowing them to specify which packages, if any, should be reverted.
*
* @param InPackageNames Names of the packages to consider for reverting
*
* @return true if the files were reverted; false if the user canceled out of the dialog
*/
static bool PromptForRevert(const TArray<FString>& InPackageNames );
/**
* Displays file diff against workspace version
*
* @param InFileName Name of the file to diff
*/
static void DiffAgainstWorkspace(const FString& InFileName);
protected:
/** Callback for ChoosePackagesToCheckIn(), continues to bring up UI once source control operations are complete */
static void ChoosePackagesToCheckInCallback(const FSourceControlOperationRef& InOperation, ECommandResult::Type InResult, FSourceControlWindowsOnCheckInComplete OnCompleteDelegate);
/** Called when the user selection process has completed and we have packages to check in. */
static void ChoosePackagesToCheckInCompleted(const TArray<UPackage*>& LoadedPackages, const TArray<FString>& PackageNames, const TArray<FString>& ConfigFiles, FCheckinResultInfo& OutResultInfo);
/** Delegate called when the user has decided to cancel the check in process */
static void ChoosePackagesToCheckInCancelled(FSourceControlOperationRef InOperation);
/** Delegate called when the user clicks submit. if the return value is true the submit dialog is closed. Otherwise it is left open for further corrections */
static bool OnSubmitClicked(TSharedRef<class SSourceControlSubmitWidget> SourceControlWidget);
private:
/** The notification in place while we choose packages to check in */
static TWeakPtr<class SNotificationItem> ChoosePackagesToCheckInNotification;
};