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.

232 lines
8.4KB

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