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.

231 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 initCommandManager();
  84. bool initialiseLogger (const char* filePrefix);
  85. void initialiseWindows (const String& commandLine);
  86. void createNewProject();
  87. void createNewProjectFromClipboard();
  88. void createNewPIP();
  89. void askUserToOpenFile();
  90. void saveAllDocuments();
  91. bool closeAllDocuments (OpenDocumentManager::SaveIfNeeded askUserToSave);
  92. bool closeAllMainWindows();
  93. void closeAllMainWindowsAndQuitIfNeeded();
  94. void clearRecentFiles();
  95. StringArray getMenuNames();
  96. PopupMenu createMenu (const String& menuName);
  97. PopupMenu createFileMenu();
  98. PopupMenu createEditMenu();
  99. PopupMenu createViewMenu();
  100. PopupMenu createBuildMenu();
  101. void createColourSchemeItems (PopupMenu&);
  102. PopupMenu createWindowMenu();
  103. PopupMenu createDocumentMenu();
  104. PopupMenu createToolsMenu();
  105. PopupMenu createHelpMenu();
  106. PopupMenu createExtraAppleMenuItems();
  107. void handleMainMenuCommand (int menuItemID);
  108. PopupMenu createExamplesPopupMenu() noexcept;
  109. void findAndLaunchExample (int);
  110. void checkIfGlobalJUCEPathHasChanged();
  111. File tryToFindDemoRunnerExecutable();
  112. File tryToFindDemoRunnerProject();
  113. void launchDemoRunner();
  114. void setColourScheme (int index, bool saveSetting);
  115. void setEditorColourScheme (int index, bool saveSetting);
  116. void updateEditorColourSchemeIfNeeded();
  117. void showUTF8ToolWindow();
  118. void showSVGPathDataToolWindow();
  119. void showAboutWindow();
  120. void showEditorColourSchemeWindow();
  121. void showPIPCreatorWindow();
  122. void launchForumBrowser();
  123. void launchModulesBrowser();
  124. void launchClassesBrowser();
  125. void launchTutorialsBrowser();
  126. void doLoginOrLogout();
  127. void showLoginForm();
  128. void enableOrDisableLiveBuild();
  129. void enableOrDisableGUIEditor();
  130. //==============================================================================
  131. #if JUCE_MAC
  132. class AppleMenuRebuildListener : private MenuBarModel::Listener
  133. {
  134. public:
  135. AppleMenuRebuildListener()
  136. {
  137. if (auto* model = ProjucerApplication::getApp().getMenuModel())
  138. model->addListener (this);
  139. }
  140. ~AppleMenuRebuildListener() override
  141. {
  142. if (auto* model = ProjucerApplication::getApp().getMenuModel())
  143. model->removeListener (this);
  144. }
  145. private:
  146. void menuBarItemsChanged (MenuBarModel*) override {}
  147. void menuCommandInvoked (MenuBarModel*,
  148. const ApplicationCommandTarget::InvocationInfo& info) override
  149. {
  150. if (info.commandID == CommandIDs::enableNewVersionCheck)
  151. Timer::callAfterDelay (50, [] { ProjucerApplication::getApp().rebuildAppleMenu(); });
  152. }
  153. };
  154. void rebuildAppleMenu();
  155. std::unique_ptr<AppleMenuRebuildListener> appleMenuRebuildListener;
  156. #endif
  157. //==============================================================================
  158. std::unique_ptr<LicenseController> licenseController;
  159. void* server = nullptr;
  160. std::unique_ptr<TooltipWindow> tooltipWindow;
  161. AvailableModulesList jucePathModulesList, userPathsModulesList;
  162. std::unique_ptr<Component> utf8Window, svgPathWindow, aboutWindow, pathsWindow,
  163. editorColourSchemeWindow, pipCreatorWindow;
  164. std::unique_ptr<FileLogger> logger;
  165. int numExamples = 0;
  166. std::unique_ptr<AlertWindow> demoRunnerAlert;
  167. bool hasScannedForDemoRunnerExecutable = false, hasScannedForDemoRunnerProject = false;
  168. File lastJUCEPath, lastDemoRunnerExectuableFile, lastDemoRunnerProjectFile;
  169. #if JUCE_LINUX
  170. ChildProcess makeProcess;
  171. #endif
  172. int selectedColourSchemeIndex = 0, selectedEditorColourSchemeIndex = 0;
  173. //==============================================================================
  174. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjucerApplication)
  175. };