Files
wouter burgers 2c01620d6c 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 32488440 by wouter burgers in 5.4 branch]
2024-03-25 18:13:43 -04:00

109 lines
4.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#if SOURCE_CONTROL_WITH_SLATE
#include "CoreMinimal.h"
#include "ISourceControlProvider.h"
#include "Delegates/IDelegateInstance.h"
#include "Framework/SlateDelegates.h"
#include "Styling/SlateTypes.h"
#include "Widgets/SCompoundWidget.h"
DECLARE_DELEGATE_RetVal(bool, FIsVisible);
DECLARE_DELEGATE_RetVal(bool, FIsEnabled);
/** Widget for displaying Source Control Check in Changes and Sync Latest buttons */
class SOURCECONTROL_API SSourceControlControls : public SCompoundWidget
{
public:
SLATE_BEGIN_ARGS(SSourceControlControls) {}
SLATE_ATTRIBUTE(bool, IsEnabledMiddleSeparator)
SLATE_ATTRIBUTE(bool, IsEnabledRightSeparator)
SLATE_EVENT(FOnGetContent, OnGenerateKebabMenu)
SLATE_END_ARGS()
public:
/** Construct this widget */
void Construct(const FArguments& InArgs);
public:
/** Separators */
EVisibility GetSourceControlMiddleSeparatorVisibility() const;
EVisibility GetSourceControlRightSeparatorVisibility() const;
/** Sync button */
static bool IsAtLatestRevision();
static bool IsSourceControlSyncEnabled();
static bool HasSourceControlChangesToSync();
static EVisibility GetSourceControlSyncStatusVisibility();
static FText GetSourceControlSyncStatusText();
static FText GetSourceControlSyncStatusToolTipText();
static const FSlateBrush* GetSourceControlSyncStatusIcon();
static FReply OnSourceControlSyncClicked();
/** Check-in button */
static int GetNumLocalChanges();
static bool IsSourceControlCheckInEnabled();
static bool HasSourceControlChangesToCheckIn();
static EVisibility GetSourceControlCheckInStatusVisibility();
static FText GetSourceControlCheckInStatusText();
static FText GetSourceControlCheckInStatusToolTipText();
static const FSlateBrush* GetSourceControlCheckInStatusIcon();
static FReply OnSourceControlCheckInChangesClicked();
/** Restore as latest button */
static bool IsSourceControlRestoreAsLatestEnabled();
static EVisibility GetSourceControlRestoreAsLatestVisibility();
static FText GetSourceControlRestoreAsLatestText();
static FText GetSourceControlRestoreAsLatestToolTipText();
static const FSlateBrush* GetSourceControlRestoreAsLatestStatusIcon();
static FReply OnSourceControlRestoreAsLatestClicked();
public:
static int32 GetNumConflictsRemaining();
public:
static void SetIsSyncLatestEnabled(const FIsEnabled& InSyncLatestEnabled) { IsSyncLatestEnabled = InSyncLatestEnabled; }
static void SetIsCheckInChangesEnabled(const FIsEnabled& InCheckInChangesEnabled) { IsCheckInChangesEnabled = InCheckInChangesEnabled; }
static void SetIsRestoreAsLatestEnabled(const FIsEnabled& InRestoreAsLatestEnabled) { IsRestoreAsLatestEnabled = InRestoreAsLatestEnabled; }
static void SetIsSyncLatestVisible(const FIsVisible& InSyncLatestVisible) { IsSyncLatestVisible = InSyncLatestVisible; }
static void SetIsCheckInChangesVisible(const FIsVisible& InCheckInChangesVisible) { IsCheckInChangesVisible = InCheckInChangesVisible; }
static void SetIsRestoreAsLatestVisible(const FIsVisible& InRestoreAsLatestVisible) { IsRestoreAsLatestVisible = InRestoreAsLatestVisible; }
static void SetOnSyncLatestClicked(const FOnClicked& InSyncLatestClicked) { OnSyncLatestClicked = InSyncLatestClicked; }
static void SetOnCheckInChangesClicked(const FOnClicked& InCheckInChangesClicked) { OnCheckInChangesClicked = InCheckInChangesClicked; }
static void SetOnRestoreAsLatestClicked(const FOnClicked& InRestoreAsLatestClicked) { OnRestoreAsLatestClicked = InRestoreAsLatestClicked; }
private:
void OnSourceControlProviderChanged(ISourceControlProvider& OldProvider, ISourceControlProvider& NewProvider);
void OnSourceControlStateChanged();
void CheckSourceControlStatus();
private:
TAttribute<bool> IsMiddleSeparatorEnabled;
TAttribute<bool> IsRightSeparatorEnabled;
FDelegateHandle SourceControlProviderChangedHandle;
FDelegateHandle SourceControlStateChangedHandle;
static int32 NumConflictsRemaining;
static FIsEnabled IsSyncLatestEnabled;
static FIsEnabled IsCheckInChangesEnabled;
static FIsEnabled IsRestoreAsLatestEnabled;
static FIsVisible IsSyncLatestVisible;
static FIsVisible IsCheckInChangesVisible;
static FIsVisible IsRestoreAsLatestVisible;
static FOnClicked OnSyncLatestClicked;
static FOnClicked OnCheckInChangesClicked;
static FOnClicked OnRestoreAsLatestClicked;
};
#endif // SOURCE_CONTROL_WITH_SLATE