2023-11-21 09:56:04 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2023-11-21 10:29:56 -05:00
# if SOURCE_CONTROL_WITH_SLATE
2023-11-21 09:56:04 -05:00
# include "SSourceControlControls.h"
# include "ISourceControlProvider.h"
# include "ISourceControlModule.h"
# include "Misc/ConfigCacheIni.h"
# include "RevisionControlStyle/RevisionControlStyle.h"
# include "Widgets/Input/SButton.h"
# include "Widgets/Input/SComboBox.h"
# include "Widgets/Layout/SSeparator.h"
# define LOCTEXT_NAMESPACE "SSkeinSourceControlWidgets"
2024-03-25 18:13:43 -04:00
int32 SSourceControlControls : : NumConflictsRemaining = 0 ;
FIsEnabled SSourceControlControls : : IsSyncLatestEnabled ;
FIsEnabled SSourceControlControls : : IsCheckInChangesEnabled ;
FIsEnabled SSourceControlControls : : IsRestoreAsLatestEnabled ;
FIsVisible SSourceControlControls : : IsSyncLatestVisible ;
FIsVisible SSourceControlControls : : IsCheckInChangesVisible ;
FIsVisible SSourceControlControls : : IsRestoreAsLatestVisible ;
FOnClicked SSourceControlControls : : OnSyncLatestClicked ;
FOnClicked SSourceControlControls : : OnCheckInChangesClicked ;
FOnClicked SSourceControlControls : : OnRestoreAsLatestClicked ;
2023-12-22 14:15:22 -05:00
2023-11-21 09:56:04 -05:00
/**
* Construct this widget
*
* @ param InArgs The declaration data for this widget
*/
void SSourceControlControls : : Construct ( const FArguments & InArgs )
{
2024-03-25 18:13:43 -04:00
IsMiddleSeparatorEnabled = InArgs . _IsEnabledMiddleSeparator ;
IsRightSeparatorEnabled = InArgs . _IsEnabledRightSeparator ;
2023-12-22 03:31:43 -05:00
2023-11-21 09:56:04 -05:00
ChildSlot
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( ) // Check In Changes Button
. VAlign ( VAlign_Center )
. Padding ( FMargin ( 0.0f , 0.0f , 4.0f , 0.0f ) )
. AutoWidth ( )
[
SNew ( SButton )
. ButtonStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FButtonStyle > ( " StatusBar.StatusBarButton " ) )
2024-03-25 18:13:43 -04:00
. ToolTipText_Static ( & SSourceControlControls : : GetSourceControlCheckInStatusToolTipText )
. Visibility_Static ( & SSourceControlControls : : GetSourceControlCheckInStatusVisibility )
. IsEnabled_Static ( & SSourceControlControls : : IsSourceControlCheckInEnabled )
2023-11-21 09:56:04 -05:00
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. HAlign ( HAlign_Center )
[
SNew ( SImage )
2024-03-25 18:13:43 -04:00
. Image_Static ( & SSourceControlControls : : GetSourceControlCheckInStatusIcon )
2023-11-21 09:56:04 -05:00
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. Padding ( FMargin ( 5 , 0 , 0 , 0 ) )
[
SNew ( STextBlock )
. TextStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FTextBlockStyle > ( " NormalText " ) )
2024-03-25 18:13:43 -04:00
. Text_Static ( & SSourceControlControls : : GetSourceControlCheckInStatusText )
2023-11-21 09:56:04 -05:00
]
]
2024-03-25 18:13:43 -04:00
. OnClicked_Static ( & SSourceControlControls : : OnSourceControlCheckInChangesClicked )
2023-11-21 09:56:04 -05:00
]
2024-02-01 13:44:24 -05:00
+ SHorizontalBox : : Slot ( ) // Restore as Latest button
. VAlign ( VAlign_Center )
. Padding ( FMargin ( 0.0f , 0.0f , 4.0f , 0.0f ) )
. AutoWidth ( )
[
SNew ( SButton )
. ButtonStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FButtonStyle > ( " StatusBar.StatusBarButton " ) )
2024-03-25 18:13:43 -04:00
. ToolTipText_Static ( & SSourceControlControls : : GetSourceControlRestoreAsLatestToolTipText )
. Visibility_Static ( & SSourceControlControls : : GetSourceControlRestoreAsLatestVisibility )
. IsEnabled_Static ( & SSourceControlControls : : IsSourceControlRestoreAsLatestEnabled )
2024-02-01 13:44:24 -05:00
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. HAlign ( HAlign_Center )
[
SNew ( SImage )
2024-03-25 18:13:43 -04:00
. Image_Static ( & SSourceControlControls : : GetSourceControlRestoreAsLatestStatusIcon )
2024-02-01 13:44:24 -05:00
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. Padding ( FMargin ( 5 , 0 , 0 , 0 ) )
[
SNew ( STextBlock )
. TextStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FTextBlockStyle > ( " NormalText " ) )
2024-03-25 18:13:43 -04:00
. Text_Static ( & SSourceControlControls : : GetSourceControlRestoreAsLatestText )
2024-02-01 13:44:24 -05:00
]
]
2024-03-25 18:13:43 -04:00
. OnClicked_Static ( & SSourceControlControls : : OnSourceControlRestoreAsLatestClicked )
2024-02-01 13:44:24 -05:00
]
2023-11-21 09:56:04 -05:00
+ SHorizontalBox : : Slot ( ) // Check In Kebab Combo button
. VAlign ( VAlign_Center )
. AutoWidth ( )
[
SNew ( SComboButton )
. ContentPadding ( FMargin ( 7.f , 0.f ) )
. ComboButtonStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FComboButtonStyle > ( " StatusBar.StatusBarEllipsisComboButton " ) )
. MenuPlacement ( MenuPlacement_AboveAnchor )
2024-03-25 18:13:43 -04:00
. Visibility_Static ( & SSourceControlControls : : GetSourceControlCheckInStatusVisibility )
2023-11-21 09:56:04 -05:00
. OnGetMenuContent ( InArgs . _OnGenerateKebabMenu )
]
+ SHorizontalBox : : Slot ( )
. VAlign ( VAlign_Center )
. AutoWidth ( )
[
SNew ( SSeparator )
2024-03-25 18:13:43 -04:00
. Visibility ( this , & SSourceControlControls : : GetSourceControlMiddleSeparatorVisibility )
2023-11-21 09:56:04 -05:00
. Thickness ( 1.0 )
. Orientation ( EOrientation : : Orient_Vertical )
]
+ SHorizontalBox : : Slot ( ) // Sync Latest Button
. VAlign ( VAlign_Center )
. AutoWidth ( )
[
SNew ( SButton )
. ButtonStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FButtonStyle > ( " StatusBar.StatusBarButton " ) )
2024-03-25 18:13:43 -04:00
. ToolTipText_Static ( & SSourceControlControls : : GetSourceControlSyncStatusToolTipText )
. Visibility_Static ( & SSourceControlControls : : GetSourceControlSyncStatusVisibility )
. IsEnabled_Static ( & SSourceControlControls : : IsSourceControlSyncEnabled )
2023-11-21 09:56:04 -05:00
[
SNew ( SHorizontalBox )
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. HAlign ( HAlign_Center )
[
SNew ( SImage )
2024-03-25 18:13:43 -04:00
. Image_Static ( & SSourceControlControls : : GetSourceControlSyncStatusIcon )
2023-11-21 09:56:04 -05:00
]
+ SHorizontalBox : : Slot ( )
. AutoWidth ( )
. VAlign ( VAlign_Center )
. Padding ( FMargin ( 5 , 0 , 0 , 0 ) )
[
SNew ( STextBlock )
. TextStyle ( & FAppStyle : : Get ( ) . GetWidgetStyle < FTextBlockStyle > ( " NormalText " ) )
2024-03-25 18:13:43 -04:00
. Text_Static ( & SSourceControlControls : : GetSourceControlSyncStatusText )
2023-11-21 09:56:04 -05:00
]
]
2024-03-25 18:13:43 -04:00
. OnClicked_Static ( & SSourceControlControls : : OnSourceControlSyncClicked )
2023-11-21 09:56:04 -05:00
]
+ SHorizontalBox : : Slot ( )
. VAlign ( VAlign_Center )
. AutoWidth ( )
[
SNew ( SSeparator )
2024-03-25 18:13:43 -04:00
. Visibility ( this , & SSourceControlControls : : GetSourceControlRightSeparatorVisibility )
2023-11-21 09:56:04 -05:00
. Thickness ( 1.0 )
. Orientation ( EOrientation : : Orient_Vertical )
]
] ;
CheckSourceControlStatus ( ) ;
}
void SSourceControlControls : : CheckSourceControlStatus ( )
{
ISourceControlModule & SourceControlModule = ISourceControlModule : : Get ( ) ;
if ( ! SourceControlProviderChangedHandle . IsValid ( ) )
{
SourceControlProviderChangedHandle = SourceControlModule . RegisterProviderChanged (
FSourceControlProviderChanged : : FDelegate : : CreateSP ( this , & SSourceControlControls : : OnSourceControlProviderChanged )
) ;
SourceControlStateChangedHandle = SourceControlModule . GetProvider ( ) . RegisterSourceControlStateChanged_Handle (
FSourceControlStateChanged : : FDelegate : : CreateSP ( this , & SSourceControlControls : : OnSourceControlStateChanged )
) ;
}
}
void SSourceControlControls : : OnSourceControlProviderChanged ( ISourceControlProvider & OldProvider , ISourceControlProvider & NewProvider )
{
if ( SourceControlStateChangedHandle . IsValid ( ) )
{
OldProvider . UnregisterSourceControlStateChanged_Handle ( SourceControlStateChangedHandle ) ;
SourceControlStateChangedHandle . Reset ( ) ;
}
if ( ! IsEngineExitRequested ( ) )
{
SourceControlStateChangedHandle = NewProvider . RegisterSourceControlStateChanged_Handle (
FSourceControlStateChanged : : FDelegate : : CreateSP ( this , & SSourceControlControls : : OnSourceControlStateChanged )
) ;
}
}
void SSourceControlControls : : OnSourceControlStateChanged ( )
{
ISourceControlProvider & SourceControlProvider = ISourceControlModule : : Get ( ) . GetProvider ( ) ;
TArray < FSourceControlStateRef > Conflicts = SourceControlProvider . GetCachedStateByPredicate (
[ ] ( const FSourceControlStateRef & State )
{
return State - > IsConflicted ( ) ;
}
) ;
2024-03-25 18:13:43 -04:00
NumConflictsRemaining = Conflicts . Num ( ) ; // Atomic write.
2023-11-21 09:56:04 -05:00
}
2024-03-25 18:13:43 -04:00
int32 SSourceControlControls : : GetNumConflictsRemaining ( )
2023-12-22 14:15:22 -05:00
{
return NumConflictsRemaining ;
}
2023-11-21 09:56:04 -05:00
/** Sync Status */
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : IsAtLatestRevision ( )
2023-11-21 09:56:04 -05:00
{
ISourceControlModule & SourceControlModule = ISourceControlModule : : Get ( ) ;
return SourceControlModule . IsEnabled ( ) & &
SourceControlModule . GetProvider ( ) . IsAvailable ( ) & &
SourceControlModule . GetProvider ( ) . IsAtLatestRevision ( ) . IsSet ( ) & &
SourceControlModule . GetProvider ( ) . IsAtLatestRevision ( ) . GetValue ( ) ;
}
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : IsSourceControlSyncEnabled ( )
2023-11-30 03:37:36 -05:00
{
if ( ! HasSourceControlChangesToSync ( ) )
{
return false ;
}
2024-03-25 18:13:43 -04:00
if ( IsSyncLatestEnabled . IsBound ( ) )
{
return IsSyncLatestEnabled . Execute ( ) ;
}
return false ;
2023-11-30 03:37:36 -05:00
}
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : HasSourceControlChangesToSync ( )
2023-11-21 09:56:04 -05:00
{
return ! IsAtLatestRevision ( ) ;
}
2024-03-25 18:13:43 -04:00
EVisibility SSourceControlControls : : GetSourceControlSyncStatusVisibility ( )
2023-11-21 09:56:04 -05:00
{
if ( ! GIsEditor )
{
// Always visible in the Slate Viewer
return EVisibility : : Visible ;
}
2024-03-25 18:13:43 -04:00
bool bVisibleSourceControlSyncStatus = true ;
if ( IsSyncLatestVisible . IsBound ( ) )
{
bVisibleSourceControlSyncStatus = IsSyncLatestVisible . Execute ( ) ;
}
2023-11-21 09:56:04 -05:00
bool bDisplaySourceControlSyncStatus = false ;
GConfig - > GetBool ( TEXT ( " SourceControlSettings " ) , TEXT ( " DisplaySourceControlSyncStatus " ) , bDisplaySourceControlSyncStatus , GEditorIni ) ;
2024-03-25 18:13:43 -04:00
if ( bVisibleSourceControlSyncStatus & & bDisplaySourceControlSyncStatus )
2023-11-21 09:56:04 -05:00
{
ISourceControlModule & SourceControlModule = ISourceControlModule : : Get ( ) ;
if ( SourceControlModule . IsEnabled ( ) & &
SourceControlModule . GetProvider ( ) . IsAvailable ( ) & &
SourceControlModule . GetProvider ( ) . IsAtLatestRevision ( ) . IsSet ( ) ) // Only providers that implement IsAtLatestRevision are supported.
{
return EVisibility : : Visible ;
}
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return EVisibility : : Collapsed ;
}
2024-03-25 18:13:43 -04:00
EVisibility SSourceControlControls : : GetSourceControlRightSeparatorVisibility ( ) const
2023-12-22 03:31:43 -05:00
{
EVisibility StatusVisibility = GetSourceControlSyncStatusVisibility ( ) ;
if ( StatusVisibility ! = EVisibility : : Visible )
{
return StatusVisibility ;
}
2024-03-25 18:13:43 -04:00
return IsRightSeparatorEnabled . Get ( true ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
2023-12-22 03:31:43 -05:00
}
2024-03-25 18:13:43 -04:00
FText SSourceControlControls : : GetSourceControlSyncStatusText ( )
2023-11-21 09:56:04 -05:00
{
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToSync ( ) )
2023-11-21 09:56:04 -05:00
{
return LOCTEXT ( " SyncLatestButtonNotAtHeadText " , " Sync Latest " ) ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return LOCTEXT ( " SyncLatestButtonAtHeadText " , " At Latest " ) ;
}
2024-03-25 18:13:43 -04:00
FText SSourceControlControls : : GetSourceControlSyncStatusToolTipText ( )
2023-11-21 09:56:04 -05:00
{
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
return LOCTEXT ( " SyncLatestButtonNotAtHeadTooltipTextConflict " , " Some of your local changes conflict with the latest snapshot of the project. Click here to review these conflicts. " ) ;
}
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToSync ( ) )
2023-11-21 09:56:04 -05:00
{
return LOCTEXT ( " SyncLatestButtonNotAtHeadTooltipText " , " Sync to the latest Snapshot for this project " ) ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return LOCTEXT ( " SyncLatestButtonAtHeadTooltipText " , " Currently at the latest Snapshot for this project " ) ;
}
2024-03-25 18:13:43 -04:00
const FSlateBrush * SSourceControlControls : : GetSourceControlSyncStatusIcon ( )
2023-11-21 09:56:04 -05:00
{
static const FSlateBrush * ConflictBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.Conflicted " ) ;
static const FSlateBrush * AtHeadBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.AtLatestRevision " ) ;
static const FSlateBrush * NotAtHeadBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.NotAtLatestRevision " ) ;
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
return ConflictBrush ;
}
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToSync ( ) )
2023-11-21 09:56:04 -05:00
{
return NotAtHeadBrush ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return AtHeadBrush ;
}
2024-03-25 18:13:43 -04:00
FReply SSourceControlControls : : OnSourceControlSyncClicked ( )
2023-11-21 09:56:04 -05:00
{
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
if ( IConsoleObject * CObj = IConsoleManager : : Get ( ) . FindConsoleObject ( TEXT ( " UnrealRevisionControl.FocusConflictResolution " ) ) )
{
CObj - > AsCommand ( ) - > Execute ( /*Args=*/ TArray < FString > ( ) , /*InWorld=*/ nullptr , * GLog ) ;
}
}
2023-11-30 03:37:36 -05:00
else if ( HasSourceControlChangesToSync ( ) )
2023-11-21 09:56:04 -05:00
{
2024-03-25 18:13:43 -04:00
if ( OnSyncLatestClicked . IsBound ( ) )
2023-11-21 09:56:04 -05:00
{
OnSyncLatestClicked . Execute ( ) ;
}
}
return FReply : : Handled ( ) ;
}
/** Check-in Status */
2024-03-25 18:13:43 -04:00
int SSourceControlControls : : GetNumLocalChanges ( )
2023-11-21 09:56:04 -05:00
{
ISourceControlModule & SourceControlModule = ISourceControlModule : : Get ( ) ;
if ( SourceControlModule . IsEnabled ( ) & &
SourceControlModule . GetProvider ( ) . IsAvailable ( ) & &
SourceControlModule . GetProvider ( ) . GetNumLocalChanges ( ) . IsSet ( ) )
{
return SourceControlModule . GetProvider ( ) . GetNumLocalChanges ( ) . GetValue ( ) ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return 0 ;
}
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : IsSourceControlCheckInEnabled ( )
2023-11-30 03:37:36 -05:00
{
if ( ! HasSourceControlChangesToCheckIn ( ) )
{
return false ;
}
2024-03-25 18:13:43 -04:00
if ( IsCheckInChangesEnabled . IsBound ( ) )
{
return IsCheckInChangesEnabled . Execute ( ) ;
}
return false ;
2023-11-30 03:37:36 -05:00
}
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : HasSourceControlChangesToCheckIn ( )
2023-11-21 09:56:04 -05:00
{
return ( GetNumLocalChanges ( ) > 0 ) ;
}
2024-03-25 18:13:43 -04:00
EVisibility SSourceControlControls : : GetSourceControlCheckInStatusVisibility ( )
2023-11-21 09:56:04 -05:00
{
if ( ! GIsEditor )
{
// Always visible in the Slate Viewer
return EVisibility : : Visible ;
}
2024-03-25 18:13:43 -04:00
bool bVisibleSourceControlCheckInStatus = true ;
if ( IsCheckInChangesVisible . IsBound ( ) )
2024-02-01 13:44:24 -05:00
{
2024-03-25 18:13:43 -04:00
bVisibleSourceControlCheckInStatus = IsCheckInChangesVisible . Execute ( ) ;
2024-02-01 13:44:24 -05:00
}
2023-11-21 09:56:04 -05:00
bool bDisplaySourceControlCheckInStatus = false ;
GConfig - > GetBool ( TEXT ( " SourceControlSettings " ) , TEXT ( " DisplaySourceControlCheckInStatus " ) , bDisplaySourceControlCheckInStatus , GEditorIni ) ;
2024-03-25 18:13:43 -04:00
if ( bVisibleSourceControlCheckInStatus & & bDisplaySourceControlCheckInStatus )
2023-11-21 09:56:04 -05:00
{
ISourceControlModule & SourceControlModule = ISourceControlModule : : Get ( ) ;
if ( SourceControlModule . IsEnabled ( ) & &
SourceControlModule . GetProvider ( ) . IsAvailable ( ) & &
SourceControlModule . GetProvider ( ) . GetNumLocalChanges ( ) . IsSet ( ) ) // Only providers that implement GetNumLocalChanges are supported.
{
return EVisibility : : Visible ;
}
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return EVisibility : : Collapsed ;
}
2024-03-25 18:13:43 -04:00
EVisibility SSourceControlControls : : GetSourceControlMiddleSeparatorVisibility ( ) const
2023-12-22 03:31:43 -05:00
{
EVisibility StatusVisibility = GetSourceControlCheckInStatusVisibility ( ) ;
if ( StatusVisibility ! = EVisibility : : Visible )
{
return StatusVisibility ;
}
2024-03-25 18:13:43 -04:00
return IsMiddleSeparatorEnabled . Get ( true ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
2023-12-22 03:31:43 -05:00
}
2024-03-25 18:13:43 -04:00
FText SSourceControlControls : : GetSourceControlCheckInStatusText ( )
2023-11-21 09:56:04 -05:00
{
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToCheckIn ( ) )
2023-11-21 09:56:04 -05:00
{
return LOCTEXT ( " CheckInButtonChangesText " , " Check-in Changes " ) ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return LOCTEXT ( " CheckInButtonNoChangesText " , " No Changes " ) ;
}
2024-03-25 18:13:43 -04:00
FText SSourceControlControls : : GetSourceControlCheckInStatusToolTipText ( )
2023-11-21 09:56:04 -05:00
{
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
return LOCTEXT ( " CheckInButtonChangesTooltipTextConflict " , " Some of your local changes conflict with the latest snapshot of the project. Click here to review these conflicts. " ) ;
}
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToCheckIn ( ) )
2023-11-21 09:56:04 -05:00
{
return FText : : Format ( LOCTEXT ( " CheckInButtonChangesTooltipText " , " Check-in {0} change(s) to this project " ) , GetNumLocalChanges ( ) ) ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return LOCTEXT ( " CheckInButtonNoChangesTooltipText " , " No Changes to check in for this project " ) ;
}
2024-03-25 18:13:43 -04:00
const FSlateBrush * SSourceControlControls : : GetSourceControlCheckInStatusIcon ( )
2023-11-21 09:56:04 -05:00
{
static const FSlateBrush * ConflictBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.Conflicted " ) ;
static const FSlateBrush * NoLocalChangesBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.NoLocalChanges " ) ;
static const FSlateBrush * HasLocalChangesBrush = FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.HasLocalChanges " ) ;
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
return ConflictBrush ;
}
2023-11-30 03:37:36 -05:00
if ( HasSourceControlChangesToCheckIn ( ) )
2023-11-21 09:56:04 -05:00
{
return HasLocalChangesBrush ;
}
2024-03-25 18:13:43 -04:00
2023-11-21 09:56:04 -05:00
return NoLocalChangesBrush ;
}
2024-03-25 18:13:43 -04:00
FReply SSourceControlControls : : OnSourceControlCheckInChangesClicked ( )
2023-11-21 09:56:04 -05:00
{
2024-03-25 18:13:43 -04:00
if ( GetNumConflictsRemaining ( ) > 0 )
2023-11-21 09:56:04 -05:00
{
if ( IConsoleObject * CObj = IConsoleManager : : Get ( ) . FindConsoleObject ( TEXT ( " UnrealRevisionControl.FocusConflictResolution " ) ) )
{
CObj - > AsCommand ( ) - > Execute ( /*Args=*/ TArray < FString > ( ) , /*InWorld=*/ nullptr , * GLog ) ;
}
}
2023-11-30 03:37:36 -05:00
else if ( HasSourceControlChangesToCheckIn ( ) )
2023-11-21 09:56:04 -05:00
{
if ( OnCheckInChangesClicked . IsBound ( ) )
{
OnCheckInChangesClicked . Execute ( ) ;
}
}
return FReply : : Handled ( ) ;
}
2024-02-01 13:44:24 -05:00
/** Restore as Latest */
2024-03-25 18:13:43 -04:00
bool SSourceControlControls : : IsSourceControlRestoreAsLatestEnabled ( )
2024-02-01 13:44:24 -05:00
{
2024-03-25 18:13:43 -04:00
if ( IsRestoreAsLatestEnabled . IsBound ( ) )
2024-02-01 13:44:24 -05:00
{
2024-03-25 18:13:43 -04:00
return IsRestoreAsLatestEnabled . Execute ( ) ;
2024-02-01 13:44:24 -05:00
}
2024-03-25 18:13:43 -04:00
return false ;
}
EVisibility SSourceControlControls : : GetSourceControlRestoreAsLatestVisibility ( )
{
if ( IsRestoreAsLatestVisible . IsBound ( ) )
{
return IsRestoreAsLatestVisible . Execute ( ) ? EVisibility : : Visible : EVisibility : : Collapsed ;
}
2024-02-01 13:44:24 -05:00
return EVisibility : : Collapsed ;
}
2024-03-25 18:13:43 -04:00
FText SSourceControlControls : : GetSourceControlRestoreAsLatestText ( )
2024-02-01 13:44:24 -05:00
{
2024-03-25 18:13:43 -04:00
return LOCTEXT ( " RestoreAsLatestButtonText " , " Restore as Latest " ) ;
}
FText SSourceControlControls : : GetSourceControlRestoreAsLatestToolTipText ( )
{
return LOCTEXT ( " RestoreAsLatestTooltipText " , " Restore this snapshot to be the latest version of the project for all team members. " ) ;
}
const FSlateBrush * SSourceControlControls : : GetSourceControlRestoreAsLatestStatusIcon ( )
{
return FRevisionControlStyleManager : : Get ( ) . GetBrush ( " RevisionControl.StatusBar.Promote " ) ;
}
FReply SSourceControlControls : : OnSourceControlRestoreAsLatestClicked ( )
{
if ( OnRestoreAsLatestClicked . IsBound ( ) )
2024-02-01 13:44:24 -05:00
{
OnRestoreAsLatestClicked . Execute ( ) ;
}
return FReply : : Handled ( ) ;
}
2023-11-21 09:56:04 -05:00
2023-11-21 10:29:56 -05:00
# undef LOCTEXT_NAMESPACE
# endif // SOURCE_CONTROL_WITH_SLATE