-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathTolgeeEditor.cpp
More file actions
195 lines (168 loc) · 5.55 KB
/
TolgeeEditor.cpp
File metadata and controls
195 lines (168 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Copyright (c) Tolgee 2022-2025. All Rights Reserved.
#include "TolgeeEditor.h"
#include <LevelEditor.h>
#include <Interfaces/IPluginManager.h>
#include "STolgeeTranslationTab.h"
#include "TolgeeEditorSettings.h"
#include "TolgeeStyle.h"
#define LOCTEXT_NAMESPACE "Tolgee"
namespace
{
const FName MenuTabName = FName("TolgeeDashboardMenuTab");
}
void FTolgeeEditorModule::StartupModule()
{
RegisterStyle();
RegisterWindowExtension();
RegisterToolbarExtension();
}
void FTolgeeEditorModule::ShutdownModule()
{
UnregisterStyle();
UnregisterWindowExtension();
UnregisterToolbarExtension();
}
void FTolgeeEditorModule::RegisterStyle()
{
FTolgeeStyle::Initialize();
}
void FTolgeeEditorModule::UnregisterStyle()
{
FTolgeeStyle::Shutdown();
}
void FTolgeeEditorModule::RegisterWindowExtension()
{
FTabSpawnerEntry& DashboardTab = FGlobalTabmanager::Get()->RegisterNomadTabSpawner(
MenuTabName,
FOnSpawnTab::CreateLambda(
[](const FSpawnTabArgs& Args)
{
return SNew(STolgeeTranslationTab);
}
)
);
// clang-format off
DashboardTab.SetDisplayName(LOCTEXT("DashboardName", "Tolgee Dashboard"))
.SetTooltipText(LOCTEXT("DashboardTooltip", "Get an overview of your project state in a separate tab."))
.SetIcon(FSlateIcon(FTolgeeStyle::Get().GetStyleSetName(), "Tolgee.Settings"))
.SetMenuType(ETabSpawnerMenuType::Hidden);
// clang-format on
}
void FTolgeeEditorModule::UnregisterWindowExtension()
{
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(MenuTabName);
}
void FTolgeeEditorModule::RegisterToolbarExtension()
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
const TSharedPtr<FExtensibilityManager> ExtensionManager = LevelEditorModule.GetToolBarExtensibilityManager();
#if ENGINE_MAJOR_VERSION > 4
const FName ToolbarHook = TEXT("ProjectSettings");
#else
const FName ToolbarHook = TEXT("Settings");
#endif
ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension(ToolbarHook, EExtensionHook::First, nullptr, FToolBarExtensionDelegate::CreateRaw(this, &FTolgeeEditorModule::ExtendToolbar));
ExtensionManager->AddExtender(ToolbarExtender);
}
void FTolgeeEditorModule::UnregisterToolbarExtension()
{
if (ToolbarExtender.IsValid())
{
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
const TSharedPtr<FExtensibilityManager> ExtensionManager = LevelEditorModule.GetToolBarExtensibilityManager();
ExtensionManager->RemoveExtender(ToolbarExtender);
ToolbarExtender.Reset();
}
}
void FTolgeeEditorModule::ExtendToolbar(FToolBarBuilder& Builder)
{
Builder.AddComboButton(
FUIAction(),
FOnGetContent::CreateLambda(
[=]()
{
FMenuBuilder MenuBuilder(true, NULL);
MenuBuilder.AddMenuEntry(
LOCTEXT("TranslationDashboard", "Translation Tab"),
LOCTEXT("TranslationDashboardTip", "Open a translation widget inside Unreal which allows you translate text by hovering on top"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
FGlobalTabmanager::Get()->TryInvokeTab(MenuTabName);
}
))
);
MenuBuilder.AddMenuEntry(
LOCTEXT("WebDashboard", "Web dashboard"),
LOCTEXT("WebDashboardTip", "Launches the Tolgee dashboard in your browser"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
const UTolgeeEditorSettings* Settings = GetDefault<UTolgeeEditorSettings>();
FPlatformProcess::LaunchURL(*Settings->GetBaseUrl(), nullptr, nullptr);
}
))
);
MenuBuilder.AddMenuEntry(
LOCTEXT("OpenSettings", "Open Settings"),
LOCTEXT("OpenSettingsTip", "Open the plugin settings section"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
//TODO: Enable this after settings get unified
//UTolgeeSettings::OpenSettings();
}
))
);
MenuBuilder.AddMenuEntry(
LOCTEXT("OpenDocumentation", "Open Documentation"),
LOCTEXT("OpenDocumentationTip", "Open a step by step guide on how to use our integration"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
const TSharedPtr<IPlugin> TolgeePlugin = IPluginManager::Get().FindPlugin("Tolgee");
const FString DocsURL = TolgeePlugin->GetDescriptor().DocsURL;
FPlatformProcess::LaunchURL(*DocsURL, nullptr, nullptr);
}
))
);
MenuBuilder.AddMenuEntry(
LOCTEXT("GetSupport", "Get support"),
LOCTEXT("GetSupportTip", "Join our slack and get support directly"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
const TSharedPtr<IPlugin> CleanProjectPlugin = IPluginManager::Get().FindPlugin("Tolgee");
const FString DocsURL = CleanProjectPlugin->GetDescriptor().SupportURL;
FPlatformProcess::LaunchURL(*DocsURL, nullptr, nullptr);
}
))
);
MenuBuilder.AddMenuEntry(
LOCTEXT("ReportIssue", "Report issue"),
LOCTEXT("ReportIssueTip", "Report an issue on our GitHub"),
FSlateIcon(),
FUIAction(FExecuteAction::CreateLambda(
[]()
{
FPlatformProcess::LaunchURL(TEXT("https://github.com/tolgee/tolgee-unreal/issues"), nullptr, nullptr);
}
))
);
return MenuBuilder.MakeWidget();
}
),
LOCTEXT("TolgeeDashboardSettingsCombo", "Tolgee Settings"),
LOCTEXT("TolgeeDashboardSettingsCombo_ToolTip", "Tolgee Dashboard settings"),
FSlateIcon(FTolgeeStyle::Get().GetStyleSetName(), "Tolgee.Settings"),
false
);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FTolgeeEditorModule, TolgeeEditor)