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.

216 lines
8.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. #include "jucer_MainWindow.h"
  21. #include "../Project/jucer_Module.h"
  22. #include "jucer_AutoUpdater.h"
  23. #include "../CodeEditor/jucer_SourceCodeEditor.h"
  24. #include "../Utility/UI/jucer_ProjucerLookAndFeel.h"
  25. #include "../Licenses/jucer_LicenseController.h"
  26. #if JUCE_MODULE_AVAILABLE_juce_analytics
  27. #include "jucer_ProjucerAnalytics.h"
  28. #endif
  29. struct ChildProcessCache;
  30. //==============================================================================
  31. class ProjucerApplication : public JUCEApplication,
  32. private AsyncUpdater,
  33. private LicenseController::StateChangedCallback
  34. {
  35. public:
  36. ProjucerApplication();
  37. static ProjucerApplication& getApp();
  38. static ApplicationCommandManager& getCommandManager();
  39. //==============================================================================
  40. void initialise (const String& commandLine) override;
  41. void initialiseBasics();
  42. bool initialiseLogger (const char* filePrefix);
  43. void initialiseWindows (const String& commandLine);
  44. void shutdown() override;
  45. void systemRequestedQuit() override;
  46. void deleteLogger();
  47. //==============================================================================
  48. const String getApplicationName() override { return "Projucer"; }
  49. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  50. String getVersionDescription() const;
  51. bool moreThanOneInstanceAllowed() override { return true; } // this is handled manually in initialise()
  52. void anotherInstanceStarted (const String& commandLine) override;
  53. //==============================================================================
  54. MenuBarModel* getMenuModel();
  55. StringArray getMenuNames();
  56. void createMenu (PopupMenu&, const String& menuName);
  57. void createFileMenu (PopupMenu&);
  58. void createEditMenu (PopupMenu&);
  59. void createViewMenu (PopupMenu&);
  60. void createBuildMenu (PopupMenu&);
  61. void createColourSchemeItems (PopupMenu&);
  62. void createWindowMenu (PopupMenu&);
  63. void createDocumentMenu (PopupMenu&);
  64. void createToolsMenu (PopupMenu&);
  65. void createHelpMenu (PopupMenu&);
  66. void createExtraAppleMenuItems (PopupMenu&);
  67. void handleMainMenuCommand (int menuItemID);
  68. //==============================================================================
  69. void getAllCommands (Array<CommandID>&) override;
  70. void getCommandInfo (CommandID commandID, ApplicationCommandInfo&) override;
  71. bool perform (const InvocationInfo&) override;
  72. //==============================================================================
  73. void createNewProject();
  74. void createNewProjectFromClipboard();
  75. void createNewPIP();
  76. void askUserToOpenFile();
  77. bool openFile (const File&);
  78. void saveAllDocuments();
  79. bool closeAllDocuments (bool askUserToSave);
  80. bool closeAllMainWindows();
  81. void closeAllMainWindowsAndQuitIfNeeded();
  82. void clearRecentFiles();
  83. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  84. //==============================================================================
  85. void showUTF8ToolWindow();
  86. void showSVGPathDataToolWindow();
  87. void showAboutWindow();
  88. void showApplicationUsageDataAgreementPopup();
  89. void dismissApplicationUsageDataAgreementPopup();
  90. void showPathsWindow (bool highlightJUCEPath = false);
  91. void showEditorColourSchemeWindow();
  92. void showPIPCreatorWindow();
  93. void launchForumBrowser();
  94. void launchModulesBrowser();
  95. void launchClassesBrowser();
  96. void launchTutorialsBrowser();
  97. void updateAllBuildTabs();
  98. //==============================================================================
  99. void licenseStateChanged (const LicenseState&) override;
  100. void doLogout();
  101. bool isPaidOrGPL() const { return licenseController == nullptr || licenseController->getState().isPaidOrGPL(); }
  102. //==============================================================================
  103. void selectEditorColourSchemeWithName (const String& schemeName);
  104. static bool isEditorColourSchemeADefaultScheme (const StringArray& schemes, int editorColourSchemeIndex);
  105. static int getEditorColourSchemeForGUIColourScheme (const StringArray& schemes, int guiColourSchemeIndex);
  106. //==============================================================================
  107. void setAnalyticsEnabled (bool);
  108. //==============================================================================
  109. void rescanJUCEPathModules();
  110. void rescanUserPathModules();
  111. AvailableModuleList& getJUCEPathModuleList() { return jucePathModuleList; }
  112. AvailableModuleList& getUserPathsModuleList() { return userPathsModuleList; }
  113. //==============================================================================
  114. ProjucerLookAndFeel lookAndFeel;
  115. std::unique_ptr<StoredSettings> settings;
  116. std::unique_ptr<Icons> icons;
  117. struct MainMenuModel;
  118. std::unique_ptr<MainMenuModel> menuModel;
  119. MainWindowList mainWindowList;
  120. OpenDocumentManager openDocumentManager;
  121. std::unique_ptr<ApplicationCommandManager> commandManager;
  122. std::unique_ptr<Component> utf8Window, svgPathWindow, aboutWindow, applicationUsageDataWindow,
  123. pathsWindow, editorColourSchemeWindow, pipCreatorWindow;
  124. std::unique_ptr<FileLogger> logger;
  125. bool isRunningCommandLine;
  126. std::unique_ptr<ChildProcessCache> childProcessCache;
  127. std::unique_ptr<LicenseController> licenseController;
  128. private:
  129. //==============================================================================
  130. void handleAsyncUpdate() override;
  131. void initCommandManager();
  132. void createExamplesPopupMenu (PopupMenu&) noexcept;
  133. Array<File> getSortedExampleDirectories() noexcept;
  134. Array<File> getSortedExampleFilesInDirectory (const File&) const noexcept;
  135. bool findWindowAndOpenPIP (const File&);
  136. void findAndLaunchExample (int);
  137. void checkIfGlobalJUCEPathHasChanged();
  138. File tryToFindDemoRunnerExecutable();
  139. File tryToFindDemoRunnerProject();
  140. void launchDemoRunner();
  141. void resetAnalytics() noexcept;
  142. void setupAnalytics();
  143. void showSetJUCEPathAlert();
  144. void setColourScheme (int index, bool saveSetting);
  145. void setEditorColourScheme (int index, bool saveSetting);
  146. void updateEditorColourSchemeIfNeeded();
  147. //==============================================================================
  148. void* server = nullptr;
  149. TooltipWindow tooltipWindow;
  150. AvailableModuleList jucePathModuleList, userPathsModuleList;
  151. int numExamples = 0;
  152. std::unique_ptr<AlertWindow> demoRunnerAlert;
  153. std::unique_ptr<AlertWindow> pathAlert;
  154. bool hasScannedForDemoRunnerExecutable = false, hasScannedForDemoRunnerProject = false;
  155. File lastJUCEPath, lastDemoRunnerExectuableFile, lastDemoRunnerProjectFile;
  156. #if JUCE_LINUX
  157. ChildProcess makeProcess;
  158. #endif
  159. int selectedColourSchemeIndex = 0, selectedEditorColourSchemeIndex = 0;
  160. //==============================================================================
  161. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ProjucerApplication)
  162. };