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.

177 lines
6.6KB

  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 createToolsMenu (PopupMenu&);
  61. void createHelpMenu (PopupMenu&);
  62. void createExtraAppleMenuItems (PopupMenu&);
  63. void handleMainMenuCommand (int menuItemID);
  64. //==============================================================================
  65. void getAllCommands (Array<CommandID>&) override;
  66. void getCommandInfo (CommandID commandID, ApplicationCommandInfo&) override;
  67. bool perform (const InvocationInfo&) override;
  68. //==============================================================================
  69. void createNewProject();
  70. void updateNewlyOpenedProject (Project&);
  71. void askUserToOpenFile();
  72. bool openFile (const File&);
  73. bool closeAllDocuments (bool askUserToSave);
  74. bool closeAllMainWindows();
  75. PropertiesFile::Options getPropertyFileOptionsFor (const String& filename, bool isProjectSettings);
  76. //==============================================================================
  77. void showUTF8ToolWindow();
  78. void showSVGPathDataToolWindow();
  79. void showAboutWindow();
  80. void showApplicationUsageDataAgreementPopup();
  81. void dismissApplicationUsageDataAgreementPopup();
  82. void showPathsWindow();
  83. void showEditorColourSchemeWindow();
  84. void launchForumBrowser();
  85. void launchModulesBrowser();
  86. void launchClassesBrowser();
  87. void launchTutorialsBrowser();
  88. void updateAllBuildTabs();
  89. LatestVersionChecker* createVersionChecker() const;
  90. //==============================================================================
  91. void licenseStateChanged (const LicenseState&) override;
  92. void doLogout();
  93. bool isPaidOrGPL() const { return licenseController == nullptr || licenseController->getState().isPaidOrGPL(); }
  94. //==============================================================================
  95. void selectEditorColourSchemeWithName (const String& schemeName);
  96. static bool isEditorColourSchemeADefaultScheme (const StringArray& schemes, int editorColourSchemeIndex);
  97. static int getEditorColourSchemeForGUIColourScheme (const StringArray& schemes, int guiColourSchemeIndex);
  98. //==============================================================================
  99. ProjucerLookAndFeel lookAndFeel;
  100. ScopedPointer<StoredSettings> settings;
  101. ScopedPointer<Icons> icons;
  102. struct MainMenuModel;
  103. ScopedPointer<MainMenuModel> menuModel;
  104. MainWindowList mainWindowList;
  105. OpenDocumentManager openDocumentManager;
  106. ScopedPointer<ApplicationCommandManager> commandManager;
  107. ScopedPointer<Component> utf8Window, svgPathWindow, aboutWindow, applicationUsageDataWindow,
  108. pathsWindow, editorColourSchemeWindow;
  109. ScopedPointer<FileLogger> logger;
  110. bool isRunningCommandLine;
  111. ScopedPointer<ChildProcessCache> childProcessCache;
  112. ScopedPointer<LicenseController> licenseController;
  113. private:
  114. void* server = nullptr;
  115. ScopedPointer<LatestVersionChecker> versionChecker;
  116. TooltipWindow tooltipWindow;
  117. void loginOrLogout();
  118. bool checkEULA();
  119. bool currentEULAHasBeenAcceptedPreviously() const;
  120. String getEULAChecksumProperty() const;
  121. void setCurrentEULAAccepted (bool hasBeenAccepted) const;
  122. void handleAsyncUpdate() override;
  123. void initCommandManager();
  124. //==============================================================================
  125. void setColourScheme (int index, bool saveSetting);
  126. void setEditorColourScheme (int index, bool saveSetting);
  127. void updateEditorColourSchemeIfNeeded();
  128. int selectedColourSchemeIndex = 0;
  129. int selectedEditorColourSchemeIndex = 0;
  130. int numEditorColourSchemes = 0;
  131. };