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.

201 lines
7.3KB

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