Plasma Engine  2.0
Loading...
Searching...
No Matches
EditorApp.moc.h
1#pragma once
2
3#include <EditorEngineProcessFramework/LongOps/LongOpControllerManager.h>
4#include <EditorFramework/EditorApp/Configuration/Plugins.h>
5#include <EditorFramework/EditorFrameworkDLL.h>
6#include <EditorFramework/IPC/EngineProcessConnection.h>
7#include <Foundation/Application/Config/FileSystemConfig.h>
8#include <Foundation/Application/Config/PluginConfig.h>
9#include <Foundation/Communication/Event.h>
10#include <Foundation/Configuration/Singleton.h>
11#include <Foundation/Containers/Set.h>
12#include <Foundation/Logging/HTMLWriter.h>
13#include <Foundation/Strings/String.h>
14#include <Foundation/Types/Bitflags.h>
15#include <Foundation/Types/UniquePtr.h>
16#include <GuiFoundation/ContainerWindow/ContainerWindow.moc.h>
17#include <QApplication>
18#include <ToolsFoundation/Project/ToolsProject.h>
19#include <ToolsFoundation/Utilities/RecentFilesList.h>
20
21class QMainWindow;
22class QWidget;
23class plProgress;
24class plQtProgressbar;
25class plQtEditorApp;
26template <typename T>
27class QList;
31class QSplashScreen;
33
34struct PL_EDITORFRAMEWORK_DLL plEditorAppEvent
35{
36 enum class Type
37 {
38 BeforeApplyDataDirectories,
40 ReloadResources,
41 EditorStarted,
42 };
43
44 Type m_Type;
45};
46
47class PL_EDITORFRAMEWORK_DLL plQtEditorApp : public QObject
48{
49 Q_OBJECT
50
51 PL_DECLARE_SINGLETON(plQtEditorApp);
52
53public:
55 {
56 using StorageType = plUInt8;
57 enum Enum
58 {
59 Headless = PL_BIT(0),
60 SafeMode = PL_BIT(1),
61 NoRecent = PL_BIT(2),
62 UnitTest = PL_BIT(3),
63 Background = PL_BIT(4),
64 Default = 0,
65 };
66
67 struct Bits
68 {
69 StorageType Headless : 1;
70 StorageType SafeMode : 1;
71 StorageType NoRecent : 1;
72 StorageType UnitTest : 1;
73 StorageType Background : 1;
74 };
75 };
76
77public:
80
82
83 //
84 // External Tools
85 //
86
91 plString FindToolApplication(const char* szToolName);
92
97 plStatus ExecuteTool(const char* szTool, const QStringList& arguments, plUInt32 uiSecondsTillTimeout, plLogInterface* pLogOutput = nullptr, plLogMsgType::Enum logLevel = plLogMsgType::WarningMsg, const char* szCWD = nullptr);
98
100 plString BuildFileserveCommandLine() const;
101
103 void RunFileserve();
104
106 void RunInspector();
107
108 //
109 //
110 //
111
113 bool IsInSafeMode() const { return m_StartupFlags.IsSet(StartupFlags::SafeMode); }
114
116 bool IsInHeadlessMode() const { return m_StartupFlags.IsSet(StartupFlags::Headless); }
117
119 bool IsInUnitTestMode() const { return m_StartupFlags.IsSet(StartupFlags::UnitTest); }
120
122 bool IsBackgroundMode() const { return m_StartupFlags.IsSet(StartupFlags::Background); }
123
124 const plPluginBundleSet& GetPluginBundles() const { return m_PluginBundles; }
125 plPluginBundleSet& GetPluginBundles() { return m_PluginBundles; }
126
127 void AddRestartRequiredReason(const char* szReason);
128 const plSet<plString>& GetRestartRequiredReasons() { return m_RestartRequiredReasons; }
129
130 void AddReloadProjectRequiredReason(const char* szReason);
131 const plSet<plString>& GetReloadProjectRequiredReason() { return m_ReloadProjectRequiredReasons; }
132
133 void SaveSettings();
134
136 void SaveOpenDocumentsList();
137
139 plRecentFilesList LoadOpenDocumentsList();
140
141 void InitQt(int iArgc, char** pArgv);
142 void StartupEditor();
143 void StartupEditor(plBitflags<StartupFlags> startupFlags, const char* szUserDataFolder = nullptr);
144 void ShutdownEditor();
145 plInt32 RunEditor();
146 void DeInitQt();
147
148 void LoadEditorPlugins();
149
150 plRecentFilesList& GetRecentProjectsList() { return m_RecentProjects; }
151 plRecentFilesList& GetRecentDocumentsList() { return m_RecentDocuments; }
152
153 plEditorEngineProcessConnection* GetEngineViewProcess() { return m_pEngineViewProcess; }
154
155 void ShowSettingsDocument();
156 void CloseSettingsDocument();
157
158 void CloseProject();
159 plResult OpenProject(const char* szProject, bool bImmediate = false);
160
161 void GuiCreateDocument();
162 void GuiOpenDocument();
163
164 void GuiOpenDashboard();
165 void GuiOpenDocsAndCommunity();
166 bool GuiCreateProject(bool bImmediate = false);
167 bool GuiOpenProject(bool bImmediate = false);
168
169 void OpenDocumentQueued(plStringView sDocument, const plDocumentObject* pOpenContext = nullptr);
170 plDocument* OpenDocument(plStringView sDocument, plBitflags<plDocumentFlags> flags, const plDocumentObject* pOpenContext = nullptr);
171 plDocument* CreateDocument(plStringView sDocument, plBitflags<plDocumentFlags> flags, const plDocumentObject* pOpenContext = nullptr);
172
173 plResult CreateOrOpenProject(bool bCreate, plStringView sFile);
174
180 plStatus MakeRemoteProjectLocal(plStringBuilder& inout_sFilePath);
181
182 bool ExistsPluginSelectionStateDDL(const char* szProjectDir = ":project");
183 void WritePluginSelectionStateDDL(const char* szProjectDir = ":project");
184 void CreatePluginSelectionDDL(const char* szProjectFile, const char* szTemplate);
185 void LoadPluginBundleDlls(const char* szProjectFile);
186 void DetectAvailablePluginBundles(plStringView sSearchDirectory);
187
189 void LaunchEditor(const char* szProject, bool bCreate);
190
193 void AddPluginDataDirDependency(const char* szSdkRootRelativePath, const char* szRootName = nullptr, bool bWriteable = false);
194
195 const plApplicationFileSystemConfig& GetFileSystemConfig() const { return m_FileSystemConfig; }
196 const plApplicationPluginConfig GetRuntimePluginConfig(bool bIncludeEditorPlugins) const;
197
198 void SetFileSystemConfig(const plApplicationFileSystemConfig& cfg);
199
200 bool MakeDataDirectoryRelativePathAbsolute(plStringBuilder& ref_sPath) const;
201 bool MakeDataDirectoryRelativePathAbsolute(plString& ref_sPath) const;
202 bool MakePathDataDirectoryRelative(plStringBuilder& ref_sPath) const;
203 bool MakePathDataDirectoryRelative(plString& ref_sPath) const;
204
205 bool MakePathDataDirectoryParentRelative(plStringBuilder& ref_sPath) const;
206 bool MakeParentDataDirectoryRelativePathAbsolute(plStringBuilder& ref_sPath, bool bCheckExists) const;
207
208 plStatus SaveTagRegistry();
209
214 void GetKnownInputSlots(plDynamicArray<plString>& slots) const;
215
217 void ReloadEngineResources();
218
219 void RestartEngineProcessIfPluginsChanged(bool bForce);
220 void SetStyleSheet();
221
222Q_SIGNALS:
223 void IdleEvent();
224
225private:
226 plString BuildDocumentTypeFileFilter(bool bForCreation);
227
228 void GuiCreateOrOpenDocument(bool bCreate);
229 bool GuiCreateOrOpenProject(bool bCreate);
230
231private Q_SLOTS:
232 void SlotTimedUpdate();
233 void SlotQueuedCloseProject();
234 void SlotQueuedOpenProject(QString sProject);
235 void SlotQueuedOpenDocument(QString sProject, void* pOpenContext);
236 void SlotQueuedGuiOpenDashboard();
237 void SlotQueuedGuiOpenDocsAndCommunity();
238 void SlotQueuedGuiCreateOrOpenProject(bool bCreate);
239 void SlotSaveSettings();
240 void SlotVersionCheckCompleted(bool bNewVersionReleased, bool bForced);
241
242private:
243 void UpdateGlobalStatusBarMessage();
244
245 void DocumentManagerRequestHandler(plDocumentManager::Request& r);
246 void DocumentManagerEventHandler(const plDocumentManager::Event& r);
247 void DocumentEventHandler(const plDocumentEvent& e);
248 void DocumentWindowEventHandler(const plQtDocumentWindowEvent& e);
249 void ProjectRequestHandler(plToolsProjectRequest& r);
250 void ProjectEventHandler(const plToolsProjectEvent& r);
251 void EngineProcessMsgHandler(const plEditorEngineProcessConnection::Event& e);
252 void UiServicesEvents(const plQtUiServices::Event& e);
253
254 void SetupNewProject();
255 void LoadEditorPreferences();
256 void LoadProjectPreferences();
257 void StoreEnginePluginModificationTimes();
258 bool CheckForEnginePluginModifications();
259 void SaveAllOpenDocuments();
260
261 void ReadTagRegistry();
262
263 void SetupDataDirectories();
264 void CreatePanels();
265
266 void SetupAndShowSplashScreen();
267 void CloseSplashScreen();
268
269 plResult AddBundlesInOrder(plDynamicArray<plApplicationPluginConfig::PluginConfig>& order, const plPluginBundleSet& bundles, const plString& start, bool bEditor, bool bEditorEngine, bool bRuntime) const;
270
271 bool m_bSavePreferencesAfterOpenProject;
272 bool m_bLoadingProjectInProgress = false;
273 bool m_bAnyProjectOpened = false;
274 bool m_bWroteCrashIndicatorFile = false;
275
276 plBitflags<StartupFlags> m_StartupFlags;
277 plDynamicArray<plString> m_DocumentsToOpen;
278
279 plSet<plString> m_RestartRequiredReasons;
280 plSet<plString> m_ReloadProjectRequiredReasons;
281
282 plPluginBundleSet m_PluginBundles;
283
284 void SaveRecentFiles();
285 void LoadRecentFiles();
286
287 plRecentFilesList m_RecentProjects;
288 plRecentFilesList m_RecentDocuments;
289
290 int m_iArgc = 0;
291 QApplication* m_pQtApplication = nullptr;
292 plLongOpControllerManager m_LongOpControllerManager;
293 plEditorEngineProcessConnection* m_pEngineViewProcess;
294 QTimer* m_pTimer = nullptr;
295
296 QSplashScreen* m_pSplashScreen = nullptr;
297
298 plLogWriter::HTML m_LogHTML;
299
300 plTime m_LastPluginModificationCheck;
301 plApplicationFileSystemConfig m_FileSystemConfig;
302
303 // *** Recent Paths ***
304 plString m_sLastDocumentFolder;
305 plString m_sLastProjectFolder;
306
307 // *** Progress Bar ***
308public:
309 bool IsProgressBarProcessingEvents() const;
310
311private:
312 plProgress* m_pProgressbar = nullptr;
313 plQtProgressbar* m_pQtProgressbar = nullptr;
314
315 // *** Localization ***
316 plTranslatorFromFiles* m_pTranslatorFromFiles = nullptr;
317
318 // *** Dynamic Enum Strings ***
319 plSet<plString> m_DynamicEnumStringsToClear;
320 void OnDemandDynamicStringEnumLoad(plStringView sEnumName, plDynamicStringEnum& e);
321
322 plUniquePtr<plQtVersionChecker> m_pVersionChecker;
323};
324
325PL_DECLARE_FLAGS_OPERATORS(plQtEditorApp::StartupFlags);
Definition EditorApp.moc.h:27
Definition FileSystemConfig.h:8
Definition PluginConfig.h:9
Definition Document.h:57
Definition DocumentObjectBase.h:11
Definition DynamicArray.h:81
Stores the valid values and names for 'dynamic' enums.
Definition DynamicStringEnum.h:14
Definition EngineProcessConnection.h:21
Definition Event.h:177
Base class for all logging classes.
Definition Log.h:77
A log writer that writes out log messages to an HTML file.
Definition HTMLWriter.h:14
The LongOp controller is active in the editor process and manages which long ops are available,...
Definition LongOpControllerManager.h:30
Manages the way a progress bar is subdivided and advanced.
Definition Progress.h:36
Definition EditorApp.moc.h:48
bool IsBackgroundMode() const
Returns true if the editor is started in run in background mode.
Definition EditorApp.moc.h:122
bool IsInSafeMode() const
Can be set via the command line option '-safe'. In this mode the editor will not automatically load r...
Definition EditorApp.moc.h:113
bool IsInUnitTestMode() const
Returns true if the editor is started in run in test mode.
Definition EditorApp.moc.h:119
bool IsInHeadlessMode() const
Returns true if the the app shouldn't display anything. This is the case in an EditorProcessor.
Definition EditorApp.moc.h:116
A Qt implementation to display the state of an plProgress instance.
Definition QtProgressbar.h:19
Downloads a web page and checks whether the latest version online is newer than the current one.
Definition CheckVersion.moc.h:33
Maintains a list of recently used files and the container window ID they previously resided in.
Definition RecentFilesList.h:7
Definition Set.h:238
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
Loads translations from files. Each translator can have different search paths, but the files to be l...
Definition TranslationLookup.h:88
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
The plBitflags class allows you to work with type-safe bitflags.
Definition Bitflags.h:82
Definition Declarations.h:54
Definition DocumentManager.h:65
Definition DocumentManager.h:87
Definition EditorApp.moc.h:35
Type
Definition EditorApp.moc.h:37
Definition EngineProcessConnection.h:63
Enum
Definition Log.h:29
@ WarningMsg
A warning message.
Definition Log.h:37
Contains multiple plPluginBundle's.
Definition Plugins.h:58
Definition DocumentWindow.moc.h:19
Definition EditorApp.moc.h:68
Definition EditorApp.moc.h:55
Enum
Definition EditorApp.moc.h:58
Definition UIServices.moc.h:23
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
An plResult with an additional message for the reason of failure.
Definition Status.h:12
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12
Definition ToolsProject.h:13
Definition ToolsProject.h:31