OpenShot Audio Library | OpenShotAudio 0.4.0
Loading...
Searching...
No Matches
juce_ApplicationProperties.cpp
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
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 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
33
34//==============================================================================
36{
37 options = newOptions;
38}
39
40//==============================================================================
41void ApplicationProperties::openFiles()
42{
43 // You need to call setStorageParameters() before trying to get hold of the properties!
44 jassert (options.applicationName.isNotEmpty());
45
46 if (options.applicationName.isNotEmpty())
47 {
48 PropertiesFile::Options o (options);
49
50 if (userProps == nullptr)
51 {
52 o.commonToAllUsers = false;
53 userProps.reset (new PropertiesFile (o));
54 }
55
56 if (commonProps == nullptr)
57 {
58 o.commonToAllUsers = true;
59 commonProps.reset (new PropertiesFile (o));
60 }
61
62 userProps->setFallbackPropertySet (commonProps.get());
63 }
64}
65
67{
68 if (userProps == nullptr)
69 openFiles();
70
71 return userProps.get();
72}
73
74PropertiesFile* ApplicationProperties::getCommonSettings (const bool returnUserPropsIfReadOnly)
75{
76 if (commonProps == nullptr)
77 openFiles();
78
79 if (returnUserPropsIfReadOnly)
80 {
81 if (commonSettingsAreReadOnly == 0)
82 commonSettingsAreReadOnly = commonProps->save() ? -1 : 1;
83
84 if (commonSettingsAreReadOnly > 0)
85 return userProps.get();
86 }
87
88 return commonProps.get();
89}
90
92{
93 return (userProps == nullptr || userProps->saveIfNeeded())
94 && (commonProps == nullptr || commonProps->saveIfNeeded());
95}
96
98{
99 userProps.reset();
100 commonProps.reset();
101}
102
103} // namespace juce
PropertiesFile * getCommonSettings(bool returnUserPropsIfReadOnly)
void setStorageParameters(const PropertiesFile::Options &options)
bool isNotEmpty() const noexcept