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.

171 lines
6.4KB

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