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.

111 lines
4.1KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  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 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. #pragma once
  19. #include <map>
  20. #include "jucer_AppearanceSettings.h"
  21. //==============================================================================
  22. class StoredSettings final : private ValueTree::Listener
  23. {
  24. public:
  25. StoredSettings();
  26. ~StoredSettings() override;
  27. PropertiesFile& getGlobalProperties();
  28. PropertiesFile& getProjectProperties (const String& projectUID);
  29. void flush();
  30. void reload();
  31. //==============================================================================
  32. RecentlyOpenedFilesList recentFiles;
  33. Array<File> getLastProjects();
  34. void setLastProjects (const Array<File>& files);
  35. //==============================================================================
  36. Array<Colour> swatchColours;
  37. struct ColourSelectorWithSwatches final : public ColourSelector
  38. {
  39. ColourSelectorWithSwatches();
  40. ~ColourSelectorWithSwatches() override;
  41. int getNumSwatches() const override;
  42. Colour getSwatchColour (int index) const override;
  43. void setSwatchColour (int index, const Colour& newColour) override;
  44. };
  45. //==============================================================================
  46. void addProjectDefaultsListener (ValueTree::Listener&);
  47. void removeProjectDefaultsListener (ValueTree::Listener&);
  48. void addFallbackPathsListener (ValueTree::Listener&);
  49. void removeFallbackPathsListener (ValueTree::Listener&);
  50. ValueTreePropertyWithDefault getStoredPath (const Identifier& key, DependencyPathOS os);
  51. bool isJUCEPathIncorrect();
  52. //==============================================================================
  53. AppearanceSettings appearance;
  54. StringArray monospacedFontNames;
  55. File lastWizardFolder;
  56. private:
  57. //==============================================================================
  58. void updateGlobalPreferences();
  59. void updateRecentFiles();
  60. void updateLastWizardFolder();
  61. void updateKeyMappings();
  62. void loadSwatchColours();
  63. void saveSwatchColours();
  64. void updateOldProjectSettingsFiles();
  65. void checkJUCEPaths();
  66. //==============================================================================
  67. void changed (bool);
  68. void valueTreePropertyChanged (ValueTree& vt, const Identifier&) override { changed (vt == projectDefaults); }
  69. void valueTreeChildAdded (ValueTree& vt, ValueTree&) override { changed (vt == projectDefaults); }
  70. void valueTreeChildRemoved (ValueTree& vt, ValueTree&, int) override { changed (vt == projectDefaults); }
  71. void valueTreeChildOrderChanged (ValueTree& vt, int, int) override { changed (vt == projectDefaults); }
  72. void valueTreeParentChanged (ValueTree& vt) override { changed (vt == projectDefaults); }
  73. //==============================================================================
  74. OwnedArray<PropertiesFile> propertyFiles;
  75. ValueTree projectDefaults;
  76. ValueTree fallbackPaths;
  77. //==============================================================================
  78. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (StoredSettings)
  79. };
  80. StoredSettings& getAppSettings();
  81. PropertiesFile& getGlobalProperties();