The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
8.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. #pragma once
  14. #include "UserAccount/jucer_LicenseController.h"
  15. #include "jucer_MainWindow.h"
  16. #include "../Project/Modules/jucer_Modules.h"
  17. #include "jucer_AutoUpdater.h"
  18. #include "../CodeEditor/jucer_SourceCodeEditor.h"
  19. #include "../Utility/UI/jucer_ProjucerLookAndFeel.h"
  20. struct ChildProcessCache;
  21. //==============================================================================
  22. class ProjucerApplication : public JUCEApplication,
  23. private AsyncUpdater
  24. {
  25. public:
  26. ProjucerApplication() = default;
  27. static ProjucerApplication& getApp();
  28. static ApplicationCommandManager& getCommandManager();
  29. //==============================================================================
  30. void initialise (const String& commandLine) override;
  31. void shutdown() override;
  32. void systemRequestedQuit() override;
  33. void deleteLogger();
  34. const String getApplicationName() override { return "Projucer"; }
  35. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  36. String getVersionDescription() const;
  37. bool moreThanOneInstanceAllowed() override { return true; } // this is handled manually in initialise()
  38. void anotherInstanceStarted (const String& commandLine) override;
  39. //==============================================================================
  40. MenuBarModel* getMenuModel();
  41. void getAllCommands (Array<CommandID>&) override;
  42. void getCommandInfo (CommandID commandID, ApplicationCommandInfo&) override;
  43. bool perform (const InvocationInfo&) override;
  44. bool isLiveBuildEnabled() const;
  45. bool isGUIEditorEnabled() const;
  46. //==============================================================================
  47. bool openFile (const File&);
  48. void showPathsWindow (bool highlightJUCEPath = false);
  49. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  50. void selectEditorColourSchemeWithName (const String& schemeName);
  51. //==============================================================================
  52. void rescanJUCEPathModules();
  53. void rescanUserPathModules();
  54. AvailableModulesList& getJUCEPathModulesList() { return jucePathModulesList; }
  55. AvailableModulesList& getUserPathsModulesList() { return userPathsModulesList; }
  56. LicenseController& getLicenseController() { return *licenseController; }
  57. bool isAutomaticVersionCheckingEnabled() const;
  58. void setAutomaticVersionCheckingEnabled (bool shouldBeEnabled);
  59. bool shouldPromptUserAboutIncorrectJUCEPath() const;
  60. void setShouldPromptUserAboutIncorrectJUCEPath (bool shouldPrompt);
  61. //==============================================================================
  62. ProjucerLookAndFeel lookAndFeel;
  63. std::unique_ptr<StoredSettings> settings;
  64. std::unique_ptr<Icons> icons;
  65. struct MainMenuModel;
  66. std::unique_ptr<MainMenuModel> menuModel;
  67. MainWindowList mainWindowList;
  68. OpenDocumentManager openDocumentManager;
  69. std::unique_ptr<ApplicationCommandManager> commandManager;
  70. bool isRunningCommandLine = false;
  71. std::unique_ptr<ChildProcessCache> childProcessCache;
  72. private:
  73. //==============================================================================
  74. void handleAsyncUpdate() override;
  75. void initCommandManager();
  76. bool initialiseLogger (const char* filePrefix);
  77. void initialiseWindows (const String& commandLine);
  78. void createNewProject();
  79. void createNewProjectFromClipboard();
  80. void createNewPIP();
  81. void askUserToOpenFile();
  82. void saveAllDocuments();
  83. bool closeAllDocuments (OpenDocumentManager::SaveIfNeeded askUserToSave);
  84. bool closeAllMainWindows();
  85. void closeAllMainWindowsAndQuitIfNeeded();
  86. void clearRecentFiles();
  87. StringArray getMenuNames();
  88. PopupMenu createMenu (const String& menuName);
  89. PopupMenu createFileMenu();
  90. PopupMenu createEditMenu();
  91. PopupMenu createViewMenu();
  92. PopupMenu createBuildMenu();
  93. void createColourSchemeItems (PopupMenu&);
  94. PopupMenu createWindowMenu();
  95. PopupMenu createDocumentMenu();
  96. PopupMenu createToolsMenu();
  97. PopupMenu createHelpMenu();
  98. PopupMenu createExtraAppleMenuItems();
  99. void handleMainMenuCommand (int menuItemID);
  100. PopupMenu createExamplesPopupMenu() noexcept;
  101. Array<File> getSortedExampleDirectories() noexcept;
  102. Array<File> getSortedExampleFilesInDirectory (const File&) const noexcept;
  103. bool findWindowAndOpenPIP (const File&);
  104. void findAndLaunchExample (int);
  105. void checkIfGlobalJUCEPathHasChanged();
  106. File tryToFindDemoRunnerExecutable();
  107. File tryToFindDemoRunnerProject();
  108. void launchDemoRunner();
  109. void setColourScheme (int index, bool saveSetting);
  110. void setEditorColourScheme (int index, bool saveSetting);
  111. void updateEditorColourSchemeIfNeeded();
  112. void showUTF8ToolWindow();
  113. void showSVGPathDataToolWindow();
  114. void showAboutWindow();
  115. void showEditorColourSchemeWindow();
  116. void showPIPCreatorWindow();
  117. void launchForumBrowser();
  118. void launchModulesBrowser();
  119. void launchClassesBrowser();
  120. void launchTutorialsBrowser();
  121. void doLoginOrLogout();
  122. void showLoginForm();
  123. void enableOrDisableLiveBuild();
  124. void enableOrDisableGUIEditor();
  125. //==============================================================================
  126. #if JUCE_MAC
  127. class AppleMenuRebuildListener : private MenuBarModel::Listener
  128. {
  129. public:
  130. AppleMenuRebuildListener()
  131. {
  132. if (auto* model = ProjucerApplication::getApp().getMenuModel())
  133. model->addListener (this);
  134. }
  135. ~AppleMenuRebuildListener() override
  136. {
  137. if (auto* model = ProjucerApplication::getApp().getMenuModel())
  138. model->removeListener (this);
  139. }
  140. private:
  141. void menuBarItemsChanged (MenuBarModel*) override {}
  142. void menuCommandInvoked (MenuBarModel*,
  143. const ApplicationCommandTarget::InvocationInfo& info) override
  144. {
  145. if (info.commandID == CommandIDs::enableNewVersionCheck)
  146. Timer::callAfterDelay (50, [] { ProjucerApplication::getApp().rebuildAppleMenu(); });
  147. }
  148. };
  149. void rebuildAppleMenu();
  150. std::unique_ptr<AppleMenuRebuildListener> appleMenuRebuildListener;
  151. #endif
  152. //==============================================================================
  153. std::unique_ptr<LicenseController> licenseController;
  154. void* server = nullptr;
  155. std::unique_ptr<TooltipWindow> tooltipWindow;
  156. AvailableModulesList jucePathModulesList, userPathsModulesList;
  157. std::unique_ptr<Component> utf8Window, svgPathWindow, aboutWindow, pathsWindow,
  158. editorColourSchemeWindow, pipCreatorWindow;
  159. std::unique_ptr<FileLogger> logger;
  160. int numExamples = 0;
  161. std::unique_ptr<AlertWindow> demoRunnerAlert;
  162. bool hasScannedForDemoRunnerExecutable = false, hasScannedForDemoRunnerProject = false;
  163. File lastJUCEPath, lastDemoRunnerExectuableFile, lastDemoRunnerProjectFile;
  164. #if JUCE_LINUX
  165. ChildProcess makeProcess;
  166. #endif
  167. int selectedColourSchemeIndex = 0, selectedEditorColourSchemeIndex = 0;
  168. //==============================================================================
  169. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjucerApplication)
  170. };