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.

217 lines
7.8KB

  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. bool closeAllDocuments (bool askUserToSave);
  79. bool closeAllMainWindows();
  80. void closeAllMainWindowsAndQuitIfNeeded();
  81. void clearRecentFiles();
  82. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  83. //==============================================================================
  84. void showUTF8ToolWindow();
  85. void showSVGPathDataToolWindow();
  86. void showAboutWindow();
  87. void showApplicationUsageDataAgreementPopup();
  88. void dismissApplicationUsageDataAgreementPopup();
  89. void showPathsWindow (bool highlightJUCEPath = false);
  90. void showEditorColourSchemeWindow();
  91. void showPIPCreatorWindow();
  92. void launchForumBrowser();
  93. void launchModulesBrowser();
  94. void launchClassesBrowser();
  95. void launchTutorialsBrowser();
  96. void updateAllBuildTabs();
  97. LatestVersionChecker* createVersionChecker() const;
  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. ProjucerLookAndFeel lookAndFeel;
  110. std::unique_ptr<StoredSettings> settings;
  111. std::unique_ptr<Icons> icons;
  112. struct MainMenuModel;
  113. std::unique_ptr<MainMenuModel> menuModel;
  114. MainWindowList mainWindowList;
  115. OpenDocumentManager openDocumentManager;
  116. std::unique_ptr<ApplicationCommandManager> commandManager;
  117. std::unique_ptr<Component> utf8Window, svgPathWindow, aboutWindow, applicationUsageDataWindow,
  118. pathsWindow, editorColourSchemeWindow, pipCreatorWindow;
  119. std::unique_ptr<FileLogger> logger;
  120. bool isRunningCommandLine;
  121. std::unique_ptr<ChildProcessCache> childProcessCache;
  122. std::unique_ptr<LicenseController> licenseController;
  123. private:
  124. void* server = nullptr;
  125. std::unique_ptr<LatestVersionChecker> versionChecker;
  126. TooltipWindow tooltipWindow;
  127. void loginOrLogout();
  128. bool checkEULA();
  129. bool currentEULAHasBeenAcceptedPreviously() const;
  130. String getEULAChecksumProperty() const;
  131. void setCurrentEULAAccepted (bool hasBeenAccepted) const;
  132. void handleAsyncUpdate() override;
  133. void initCommandManager();
  134. void deleteTemporaryFiles() const noexcept;
  135. void createExamplesPopupMenu (PopupMenu&) noexcept;
  136. Array<File> getSortedExampleDirectories() noexcept;
  137. Array<File> getSortedExampleFilesInDirectory (const File&) const noexcept;
  138. bool findWindowAndOpenPIP (const File&);
  139. File getJUCEExamplesDirectoryPathFromGlobal() noexcept;
  140. void findAndLaunchExample (int);
  141. File findDemoRunnerExecutable() noexcept;
  142. File findDemoRunnerProject() noexcept;
  143. void launchDemoRunner();
  144. int numExamples = 0;
  145. std::unique_ptr<AlertWindow> demoRunnerAlert;
  146. #if JUCE_LINUX
  147. ChildProcess makeProcess;
  148. #endif
  149. void resetAnalytics() noexcept;
  150. void setupAnalytics();
  151. void showSetJUCEPathAlert();
  152. std::unique_ptr<AlertWindow> pathAlert;
  153. //==============================================================================
  154. void setColourScheme (int index, bool saveSetting);
  155. void setEditorColourScheme (int index, bool saveSetting);
  156. void updateEditorColourSchemeIfNeeded();
  157. int selectedColourSchemeIndex = 0;
  158. int selectedEditorColourSchemeIndex = 0;
  159. int numEditorColourSchemes = 0;
  160. };