OpenShot Audio Library | OpenShotAudio: juce_ApplicationProperties.cpp Source File

OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
juce_ApplicationProperties.cpp
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
11 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12 27th April 2017).
13
14 End User License Agreement: www.juce.com/juce-5-licence
15 Privacy Policy: www.juce.com/juce-5-privacy-policy
16
17 Or: You may also use this code under the terms of the GPL v3 (see
18 www.gnu.org/licenses).
19
20 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22 DISCLAIMED.
23
24 ==============================================================================
25*/
26
27namespace juce
28{
29
30ApplicationProperties::ApplicationProperties()
31{
32}
33
34ApplicationProperties::~ApplicationProperties()
35{
36 closeFiles();
37}
38
39//==============================================================================
40 void ApplicationProperties::setStorageParameters (const PropertiesFile::Options& newOptions)
41{
42 options = newOptions;
43}
44
45//==============================================================================
46void ApplicationProperties::openFiles()
47{
48 // You need to call setStorageParameters() before trying to get hold of the properties!
49 jassert (options.applicationName.isNotEmpty());
50
51 if (options.applicationName.isNotEmpty())
52 {
53 PropertiesFile::Options o (options);
54
55 if (userProps == nullptr)
56 {
57 o.commonToAllUsers = false;
58 userProps.reset (new PropertiesFile (o));
59 }
60
61 if (commonProps == nullptr)
62 {
63 o.commonToAllUsers = true;
64 commonProps.reset (new PropertiesFile (o));
65 }
66
67 userProps->setFallbackPropertySet (commonProps.get());
68 }
69}
70
71 PropertiesFile* ApplicationProperties::getUserSettings()
72{
73 if (userProps == nullptr)
74 openFiles();
75
76 return userProps.get();
77}
78
79 PropertiesFile* ApplicationProperties::getCommonSettings (const bool returnUserPropsIfReadOnly)
80{
81 if (commonProps == nullptr)
82 openFiles();
83
84 if (returnUserPropsIfReadOnly)
85 {
86 if (commonSettingsAreReadOnly == 0)
87 commonSettingsAreReadOnly = commonProps->save() ? -1 : 1;
88
89 if (commonSettingsAreReadOnly > 0)
90 return userProps.get();
91 }
92
93 return commonProps.get();
94}
95
96 bool ApplicationProperties::saveIfNeeded()
97{
98 return (userProps == nullptr || userProps->saveIfNeeded())
99 && (commonProps == nullptr || commonProps->saveIfNeeded());
100}
101
102 void ApplicationProperties::closeFiles()
103{
104 userProps.reset();
105 commonProps.reset();
106}
107
108} // namespace juce
juce::ApplicationProperties::closeFiles
void closeFiles()
Definition: juce_ApplicationProperties.cpp:102
juce::ApplicationProperties::getUserSettings
PropertiesFile * getUserSettings()
Definition: juce_ApplicationProperties.cpp:71
juce::ApplicationProperties::ApplicationProperties
ApplicationProperties()
Definition: juce_ApplicationProperties.cpp:30
juce::ApplicationProperties::getCommonSettings
PropertiesFile * getCommonSettings(bool returnUserPropsIfReadOnly)
Definition: juce_ApplicationProperties.cpp:79
juce::ApplicationProperties::saveIfNeeded
bool saveIfNeeded()
Definition: juce_ApplicationProperties.cpp:96
juce::ApplicationProperties::~ApplicationProperties
~ApplicationProperties()
Definition: juce_ApplicationProperties.cpp:34
juce::ApplicationProperties::setStorageParameters
void setStorageParameters(const PropertiesFile::Options &options)
Definition: juce_ApplicationProperties.cpp:40
juce::PropertiesFile
Definition: juce_PropertiesFile.h:49
juce::String::isNotEmpty
bool isNotEmpty() const noexcept
Definition: juce_String.h:302
juce::PropertiesFile::Options
Definition: juce_PropertiesFile.h:62
juce::PropertiesFile::Options::applicationName
String applicationName
Definition: juce_PropertiesFile.h:70