Files
UnrealEngineUWP/Engine/Source/Editor/StatusBar/Private/SourceControlMenuHelpers.h
wouter burgers b96d8d30b2 SkeinUE: Refactored SSourceControlControls.
The SSourceControlControls is currently instantiated in two places in the editor: bottom right and as part of the snapshot history panel. Regardless, we would like the behavior of these buttons to be the same. This was accomplished by providing 'defaults' in SourceControlMenuHelpers and then setting temporary 'overrides' in SnapshotHistoryPanel. This wasn't very pretty and somewhat confusing with SSourceControlControls providing a mix of instance and static interfaces and behaviors. I've refactored this with the idea in mind that these buttons should behave similar, wherever they are placed in the editor and providing static methods to control that behavior. The default behavior is now no-op and SnapshotHistory provides the UEFN/Skein behavior.

This also allowed the 'CanAutoSave' code to live in one location (in the SnapshotHistoryController) instead of being duplicated in two spots. This was also not possible because engine code cannot be accessed from SkeinSourceControlSlate, where the SSourceControlControls was being instantiated, resulting in the behavior as described in the JIRA bug.

#rb manuel.lang, marco.anastasi

[CL 31796796 by wouter burgers in ue5-main branch]
2024-02-26 03:57:11 -05:00

90 lines
2.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Framework/Commands/Commands.h"
#include "ISourceControlOperation.h"
#include "ISourceControlProvider.h"
class FUICommandList;
class FReply;
class SWidget;
class SSourceControlControls;
class FSourceControlCommands : public TCommands<FSourceControlCommands>
{
public:
FSourceControlCommands();
/**
* Initialize commands
*/
virtual void RegisterCommands() override;
private:
static void ConnectToSourceControl_Clicked();
static bool ViewChangelists_CanExecute();
static bool ViewChangelists_IsVisible();
static bool ViewSnapshotHistory_CanExecute();
static bool ViewSnapshotHistory_IsVisible();
static bool SubmitContent_IsVisible();
static void ViewChangelists_Clicked();
static void ViewSnapshotHistory_Clicked();
static bool CheckOutModifiedFiles_CanExecute();
static void CheckOutModifiedFiles_Clicked();
static bool RevertAllModifiedFiles_CanExecute();
static void RevertAllModifiedFiles_Clicked();
public:
/**
* Source Control Commands
*/
TSharedPtr< FUICommandInfo > ConnectToSourceControl;
TSharedPtr< FUICommandInfo > ChangeSourceControlSettings;
TSharedPtr< FUICommandInfo > ViewChangelists;
TSharedPtr< FUICommandInfo > ViewSnapshotHistory;
TSharedPtr< FUICommandInfo > SubmitContent;
TSharedPtr< FUICommandInfo > CheckOutModifiedFiles;
TSharedPtr< FUICommandInfo > RevertAll;
static TSharedRef<FUICommandList> ActionList;
};
class FSourceControlMenuHelpers
{
friend class FSourceControlCommands;
private:
FSourceControlMenuHelpers() {};
private:
enum EQueryState
{
NotQueried,
Querying,
Queried,
};
static EQueryState QueryState;
public:
static void CheckSourceControlStatus();
static TSharedRef<SWidget> MakeSourceControlStatusWidget();
private:
static void OnSourceControlOperationComplete(const FSourceControlOperationRef& InOperation, ECommandResult::Type InResult);
static TSharedRef<SWidget> GenerateSourceControlMenuContent();
static TSharedRef<SWidget> GenerateCheckInComboButtonContent();
static FText GetSourceControlStatusText();
static FText GetSourceControlTooltip();
static const FSlateBrush* GetSourceControlIconBadge();
private:
/** Delegate handles */
FDelegateHandle SourceControlProviderChangedHandle;
FDelegateHandle SourceControlStateChangedHandle;
};