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
26
namespace
juce
27
{
28
29
ApplicationProperties::~ApplicationProperties
()
30
{
31
closeFiles
();
32
}
33
34
//==============================================================================
35
void
ApplicationProperties::setStorageParameters
(
const
PropertiesFile::Options
&
newOptions
)
36
{
37
options =
newOptions
;
38
}
39
40
//==============================================================================
41
void
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
66
PropertiesFile
*
ApplicationProperties::getUserSettings
()
67
{
68
if
(userProps ==
nullptr
)
69
openFiles();
70
71
return
userProps.get();
72
}
73
74
PropertiesFile
*
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
91
bool
ApplicationProperties::saveIfNeeded
()
92
{
93
return
(userProps ==
nullptr
|| userProps->saveIfNeeded())
94
&& (commonProps ==
nullptr
|| commonProps->saveIfNeeded());
95
}
96
97
void
ApplicationProperties::closeFiles
()
98
{
99
userProps.reset();
100
commonProps.reset();
101
}
102
103
}
// namespace juce
juce::ApplicationProperties::closeFiles
void closeFiles()
Definition
juce_ApplicationProperties.cpp:97
juce::ApplicationProperties::getUserSettings
PropertiesFile * getUserSettings()
Definition
juce_ApplicationProperties.cpp:66
juce::ApplicationProperties::getCommonSettings
PropertiesFile * getCommonSettings(bool returnUserPropsIfReadOnly)
Definition
juce_ApplicationProperties.cpp:74
juce::ApplicationProperties::saveIfNeeded
bool saveIfNeeded()
Definition
juce_ApplicationProperties.cpp:91
juce::ApplicationProperties::~ApplicationProperties
~ApplicationProperties()
Definition
juce_ApplicationProperties.cpp:29
juce::ApplicationProperties::setStorageParameters
void setStorageParameters(const PropertiesFile::Options &options)
Definition
juce_ApplicationProperties.cpp:35
juce::Optional
Definition
juce_Optional.h:57
juce::PropertiesFile
Definition
juce_PropertiesFile.h:48
juce::String::isNotEmpty
bool isNotEmpty() const noexcept
Definition
juce_String.h:316
juce::PropertiesFile::Options
Definition
juce_PropertiesFile.h:61
juce::PropertiesFile::Options::applicationName
String applicationName
Definition
juce_PropertiesFile.h:69
JuceLibraryCode
modules
juce_data_structures
app_properties
juce_ApplicationProperties.cpp
Generated by
1.10.0