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.

109 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "../jucer_Headers.h"
  19. #include "jucer_StoredSettings.h"
  20. //==============================================================================
  21. StoredSettings::StoredSettings()
  22. : props (0)
  23. {
  24. flush();
  25. }
  26. StoredSettings::~StoredSettings()
  27. {
  28. flush();
  29. props = 0;
  30. clearSingletonInstance();
  31. }
  32. juce_ImplementSingleton (StoredSettings);
  33. //==============================================================================
  34. PropertiesFile& StoredSettings::getProps()
  35. {
  36. jassert (props != 0);
  37. return *props;
  38. }
  39. void StoredSettings::flush()
  40. {
  41. if (props != 0)
  42. {
  43. props->setValue ("recentFiles", recentFiles.toString());
  44. props->removeValue ("keyMappings");
  45. if (commandManager != 0)
  46. {
  47. ScopedPointer <XmlElement> keys (commandManager->getKeyMappings()->createXml (true));
  48. if (keys != 0)
  49. props->setValue ("keyMappings", (XmlElement*) keys);
  50. }
  51. }
  52. props = 0;
  53. props = PropertiesFile::createDefaultAppPropertiesFile ("Jucer2",
  54. "settings",
  55. String::empty,
  56. false, 3000,
  57. PropertiesFile::storeAsXML);
  58. // recent files...
  59. recentFiles.restoreFromString (props->getValue ("recentFiles"));
  60. recentFiles.removeNonExistentFiles();
  61. }
  62. const File StoredSettings::getLastProject() const
  63. {
  64. return props->getValue ("lastProject");
  65. }
  66. void StoredSettings::setLastProject (const File& file)
  67. {
  68. props->setValue ("lastProject", file.getFullPathName());
  69. }
  70. const File StoredSettings::getLastKnownJuceFolder() const
  71. {
  72. File defaultJuceFolder (findDefaultJuceFolder());
  73. File f (props->getValue ("lastJuceFolder", defaultJuceFolder.getFullPathName()));
  74. if ((! isJuceFolder (f)) && isJuceFolder (defaultJuceFolder))
  75. f = defaultJuceFolder;
  76. return f;
  77. }
  78. void StoredSettings::setLastKnownJuceFolder (const File& file)
  79. {
  80. jassert (isJuceFolder (file));
  81. props->setValue ("lastJuceFolder", file.getFullPathName());
  82. }