2
2
3
3
#include " SentrySettingsCustomization.h"
4
4
#include " SentrySettings.h"
5
+ #include " SentryCliDownloader.h"
5
6
6
7
#include " DetailCategoryBuilder.h"
7
8
#include " DetailLayoutBuilder.h"
10
11
#include " Misc/Paths.h"
11
12
#include " Misc/ConfigCacheIni.h"
12
13
#include " PropertyHandle.h"
14
+ #include " Framework/Notifications/NotificationManager.h"
13
15
#include " Runtime/Launch/Resources/Version.h"
14
16
15
17
#include " Widgets/Text/SRichTextBlock.h"
18
+ #include " Widgets/Text/STextBlock.h"
16
19
#include " Widgets/Layout/SBorder.h"
20
+ #include " Widgets/Layout/SWidgetSwitcher.h"
17
21
#include " Widgets/Input/SButton.h"
22
+ #include " Widgets/Notifications/SNotificationList.h"
23
+ #include " Widgets/Images/SImage.h"
18
24
19
25
#if ENGINE_MAJOR_VERSION >= 5
20
26
#include " Styling/AppStyle.h"
@@ -26,6 +32,11 @@ const FString FSentrySettingsCustomization::DefaultCrcEndpoint = TEXT("https://d
26
32
27
33
void OnDocumentationLinkClicked (const FSlateHyperlinkRun::FMetadata& Metadata);
28
34
35
+ FSentrySettingsCustomization::FSentrySettingsCustomization ()
36
+ : CliDownloader(MakeShareable(new FSentryCliDownloader()))
37
+ {
38
+ }
39
+
29
40
TSharedRef<IDetailCustomization> FSentrySettingsCustomization::MakeInstance ()
30
41
{
31
42
return MakeShareable (new FSentrySettingsCustomization);
@@ -45,12 +56,44 @@ void FSentrySettingsCustomization::DrawDebugSymbolsNotice(IDetailLayoutBuilder&
45
56
46
57
TSharedPtr<IPropertyHandle> CrashReporterUrlHandle = DetailBuilder.GetProperty (GET_MEMBER_NAME_CHECKED (USentrySettings, CrashReporterUrl));
47
58
59
+ TSharedRef<SWidget> CliMissingWidget = MakeSentryCliStatusRow (FName (TEXT (" SettingsEditor.WarningIcon" )),
60
+ FText::FromString (TEXT (" Sentry CLI is not configured." )), FText::FromString (TEXT (" Configure Now" )));
61
+
62
+ TSharedRef<SWidget> CliDownloadingWidget = MakeSentryCliStatusRow (FName (TEXT (" SettingsEditor.WarningIcon" )),
63
+ FText::FromString (TEXT (" Downloading Sentry CLI..." )), FText ());
64
+
65
+ TSharedRef<SWidget> CliConfiguredWidget = MakeSentryCliStatusRow (FName (TEXT (" SettingsEditor.GoodIcon" )),
66
+ FText::FromString (TEXT (" Sentry CLI is configured." )), FText::FromString (TEXT (" Reload" )));
67
+
48
68
#if ENGINE_MAJOR_VERSION >= 5
49
69
const ISlateStyle& Style = FAppStyle::Get ();
50
70
#else
51
71
const ISlateStyle& Style = FEditorStyle::Get ();
52
72
#endif
53
73
74
+ DebugSymbolsCategory.AddCustomRow (FText::FromString (TEXT (" DebugSymbols" )), false )
75
+ .WholeRowWidget
76
+ [
77
+ SNew (SBorder)
78
+ .Padding (8 .0f )
79
+ [
80
+ SNew (SWidgetSwitcher)
81
+ .WidgetIndex (this , &FSentrySettingsCustomization::GetSentryCliStatusAsInt)
82
+ +SWidgetSwitcher::Slot ()
83
+ [
84
+ CliMissingWidget
85
+ ]
86
+ +SWidgetSwitcher::Slot ()
87
+ [
88
+ CliDownloadingWidget
89
+ ]
90
+ +SWidgetSwitcher::Slot ()
91
+ [
92
+ CliConfiguredWidget
93
+ ]
94
+ ]
95
+ ];
96
+
54
97
DebugSymbolsCategory.AddCustomRow (FText::FromString (TEXT (" DebugSymbols" )), false )
55
98
.WholeRowWidget
56
99
[
@@ -167,6 +210,66 @@ void FSentrySettingsCustomization::SetPropertiesUpdateHandler(IDetailLayoutBuild
167
210
AuthTokenHandle->SetOnPropertyValueChanged (OnUpdateAuthToken);
168
211
}
169
212
213
+ TSharedRef<SWidget> FSentrySettingsCustomization::MakeSentryCliStatusRow (FName IconName, FText Message, FText ButtonMessage)
214
+ {
215
+ TSharedRef<SHorizontalBox> Result = SNew (SHorizontalBox)
216
+ +SHorizontalBox::Slot ()
217
+ .AutoWidth ()
218
+ .VAlign (VAlign_Center)
219
+ [
220
+ SNew (SImage)
221
+ #if ENGINE_MAJOR_VERSION >= 5
222
+ .Image (FAppStyle::Get ().GetBrush (IconName))
223
+ #else
224
+ .Image (FEditorStyle::Get ().GetBrush (IconName))
225
+ #endif
226
+ ]
227
+
228
+ +SHorizontalBox::Slot ()
229
+ .FillWidth (1 .0f )
230
+ .Padding (16 .0f , 0 .0f )
231
+ .VAlign (VAlign_Center)
232
+ [
233
+ SNew (STextBlock)
234
+ .ColorAndOpacity (FLinearColor::White)
235
+ .ShadowColorAndOpacity (FLinearColor::Black)
236
+ .ShadowOffset (FVector2D::UnitVector)
237
+ .Text (Message)
238
+ ];
239
+
240
+ if (!ButtonMessage.IsEmpty ())
241
+ {
242
+ Result->AddSlot ()
243
+ .AutoWidth ()
244
+ .VAlign (VAlign_Center)
245
+ [
246
+ SNew (SButton)
247
+ .OnClicked_Lambda ([=]() -> FReply
248
+ {
249
+ if (CliDownloader.IsValid () && CliDownloader->GetStatus () != ESentryCliStatus::Downloading)
250
+ {
251
+ CliDownloader->Download ([](bool Result)
252
+ {
253
+ FNotificationInfo Info (FText::FromString (Result
254
+ ? TEXT (" Sentry CLI was configured successfully." )
255
+ : TEXT (" Sentry CLI configuration failed." )));
256
+ Info.ExpireDuration = 3 .0f ;
257
+ Info.bUseSuccessFailIcons = true ;
258
+
259
+ TSharedPtr<SNotificationItem> EditorNotification = FSlateNotificationManager::Get ().AddNotification (Info);
260
+ EditorNotification->SetCompletionState (Result ? SNotificationItem::CS_Success : SNotificationItem::CS_Fail);
261
+ });
262
+ }
263
+
264
+ return FReply::Handled ();
265
+ })
266
+ .Text (ButtonMessage)
267
+ ];
268
+ }
269
+
270
+ return Result;
271
+ }
272
+
170
273
void FSentrySettingsCustomization::UpdateProjectName ()
171
274
{
172
275
FString Value;
@@ -231,11 +334,21 @@ void FSentrySettingsCustomization::UpdateCrcConfig(const FString& Url)
231
334
CrcConfigFile.SetString (*CrcSectionName, *DataRouterUrlKey, *DataRouterUrlValue, CrcConfigFilePath);
232
335
}
233
336
234
- FString FSentrySettingsCustomization::GetCrcConfigPath ()
337
+ FString FSentrySettingsCustomization::GetCrcConfigPath () const
235
338
{
236
339
return FPaths::Combine (FPaths::EngineDir (), TEXT (" Programs" ), TEXT (" CrashReportClient" ), TEXT (" Config" ), TEXT (" DefaultEngine.ini" ));
237
340
}
238
341
342
+ int32 FSentrySettingsCustomization::GetSentryCliStatusAsInt () const
343
+ {
344
+ if (CliDownloader.IsValid ())
345
+ {
346
+ return static_cast <int32>(CliDownloader->GetStatus ());
347
+ }
348
+
349
+ return 0 ;
350
+ }
351
+
239
352
void OnDocumentationLinkClicked (const FSlateHyperlinkRun::FMetadata& Metadata)
240
353
{
241
354
const FString* UrlPtr = Metadata.Find (TEXT (" href" ));
0 commit comments