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.

211 lines
7.7KB

  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. #include "jucer_ProjucerAnalytics.h"
  27. struct ChildProcessCache;
  28. //==============================================================================
  29. class ProjucerApplication : public JUCEApplication,
  30. private AsyncUpdater,
  31. private LicenseController::StateChangedCallback
  32. {
  33. public:
  34. ProjucerApplication();
  35. static ProjucerApplication& getApp();
  36. static ApplicationCommandManager& getCommandManager();
  37. //==============================================================================
  38. void initialise (const String& commandLine) override;
  39. void initialiseBasics();
  40. bool initialiseLogger (const char* filePrefix);
  41. void initialiseWindows (const String& commandLine);
  42. void shutdown() override;
  43. void systemRequestedQuit() override;
  44. void deleteLogger();
  45. //==============================================================================
  46. const String getApplicationName() override { return "Projucer"; }
  47. const String getApplicationVersion() override { return ProjectInfo::versionString; }
  48. String getVersionDescription() const;
  49. bool moreThanOneInstanceAllowed() override { return true; } // this is handled manually in initialise()
  50. void anotherInstanceStarted (const String& commandLine) override;
  51. //==============================================================================
  52. MenuBarModel* getMenuModel();
  53. StringArray getMenuNames();
  54. void createMenu (PopupMenu&, const String& menuName);
  55. void createFileMenu (PopupMenu&);
  56. void createEditMenu (PopupMenu&);
  57. void createViewMenu (PopupMenu&);
  58. void createBuildMenu (PopupMenu&);
  59. void createColourSchemeItems (PopupMenu&);
  60. void createWindowMenu (PopupMenu&);
  61. void createDocumentMenu (PopupMenu&);
  62. void createToolsMenu (PopupMenu&);
  63. void createHelpMenu (PopupMenu&);
  64. void createExtraAppleMenuItems (PopupMenu&);
  65. void handleMainMenuCommand (int menuItemID);
  66. //==============================================================================
  67. void getAllCommands (Array<CommandID>&) override;
  68. void getCommandInfo (CommandID commandID, ApplicationCommandInfo&) override;
  69. bool perform (const InvocationInfo&) override;
  70. //==============================================================================
  71. void createNewProject();
  72. void createNewProjectFromClipboard();
  73. void updateNewlyOpenedProject (Project&);
  74. void askUserToOpenFile();
  75. bool openFile (const File&);
  76. bool closeAllDocuments (bool askUserToSave);
  77. bool closeAllMainWindows();
  78. void closeAllMainWindowsAndQuitIfNeeded();
  79. void clearRecentFiles();
  80. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  81. //==============================================================================
  82. void showUTF8ToolWindow();
  83. void showSVGPathDataToolWindow();
  84. void showAboutWindow();
  85. void showApplicationUsageDataAgreementPopup();
  86. void dismissApplicationUsageDataAgreementPopup();
  87. void showPathsWindow (bool highlightJUCEPath = false);
  88. void showEditorColourSchemeWindow();
  89. void launchForumBrowser();
  90. void launchModulesBrowser();
  91. void launchClassesBrowser();
  92. void launchTutorialsBrowser();
  93. void updateAllBuildTabs();
  94. LatestVersionChecker* createVersionChecker() const;
  95. //==============================================================================
  96. void licenseStateChanged (const LicenseState&) override;
  97. void doLogout();
  98. bool isPaidOrGPL() const { return licenseController == nullptr || licenseController->getState().isPaidOrGPL(); }
  99. //==============================================================================
  100. void selectEditorColourSchemeWithName (const String& schemeName);
  101. static bool isEditorColourSchemeADefaultScheme (const StringArray& schemes, int editorColourSchemeIndex);
  102. static int getEditorColourSchemeForGUIColourScheme (const StringArray& schemes, int guiColourSchemeIndex);
  103. //==============================================================================
  104. void setAnalyticsEnabled (bool);
  105. //==============================================================================
  106. ProjucerLookAndFeel lookAndFeel;
  107. ScopedPointer<StoredSettings> settings;
  108. ScopedPointer<Icons> icons;
  109. struct MainMenuModel;
  110. ScopedPointer<MainMenuModel> menuModel;
  111. MainWindowList mainWindowList;
  112. OpenDocumentManager openDocumentManager;
  113. ScopedPointer<ApplicationCommandManager> commandManager;
  114. ScopedPointer<Component> utf8Window, svgPathWindow, aboutWindow, applicationUsageDataWindow,
  115. pathsWindow, editorColourSchemeWindow;
  116. ScopedPointer<FileLogger> logger;
  117. bool isRunningCommandLine;
  118. ScopedPointer<ChildProcessCache> childProcessCache;
  119. ScopedPointer<LicenseController> licenseController;
  120. private:
  121. void* server = nullptr;
  122. ScopedPointer<LatestVersionChecker> versionChecker;
  123. TooltipWindow tooltipWindow;
  124. void loginOrLogout();
  125. bool checkEULA();
  126. bool currentEULAHasBeenAcceptedPreviously() const;
  127. String getEULAChecksumProperty() const;
  128. void setCurrentEULAAccepted (bool hasBeenAccepted) const;
  129. void handleAsyncUpdate() override;
  130. void initCommandManager();
  131. void deleteTemporaryFiles() const noexcept;
  132. void createExamplesPopupMenu (PopupMenu&) noexcept;
  133. Array<File> getSortedExampleDirectories() const noexcept;
  134. Array<File> getSortedExampleFilesInDirectory (const File&) const noexcept;
  135. bool findWindowAndOpenPIP (const File&);
  136. void findAndLaunchExample (int);
  137. File findDemoRunnerExecutable() const noexcept;
  138. File findDemoRunnerProject() const noexcept;
  139. void launchDemoRunner();
  140. int numExamples = 0;
  141. ScopedPointer<AlertWindow> demoRunnerAlert;
  142. #if JUCE_LINUX
  143. ChildProcess makeProcess;
  144. #endif
  145. void resetAnalytics() noexcept;
  146. void setupAnalytics();
  147. void showSetJUCEPathAlert();
  148. ScopedPointer<AlertWindow> pathAlert;
  149. //==============================================================================
  150. void setColourScheme (int index, bool saveSetting);
  151. void setEditorColourScheme (int index, bool saveSetting);
  152. void updateEditorColourSchemeIfNeeded();
  153. int selectedColourSchemeIndex = 0;
  154. int selectedEditorColourSchemeIndex = 0;
  155. int numEditorColourSchemes = 0;
  156. };