LMMS
Loading...
Searching...
No Matches
juce_ApplicationProperties.cpp
Go to the documentation of this file.
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//==============================================================================
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 {
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 {
82 commonSettingsAreReadOnly = commonProps->save() ? -1 : 1;
83
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
void closeFiles()
Definition juce_ApplicationProperties.cpp:97
PropertiesFile::Options options
Definition juce_ApplicationProperties.h:124
PropertiesFile * getUserSettings()
Definition juce_ApplicationProperties.cpp:66
PropertiesFile * getCommonSettings(bool returnUserPropsIfReadOnly)
Definition juce_ApplicationProperties.cpp:74
bool saveIfNeeded()
Definition juce_ApplicationProperties.cpp:91
int commonSettingsAreReadOnly
Definition juce_ApplicationProperties.h:126
std::unique_ptr< PropertiesFile > commonProps
Definition juce_ApplicationProperties.h:125
void openFiles()
Definition juce_ApplicationProperties.cpp:41
~ApplicationProperties()
Definition juce_ApplicationProperties.cpp:29
void setStorageParameters(const PropertiesFile::Options &options)
Definition juce_ApplicationProperties.cpp:35
std::unique_ptr< PropertiesFile > userProps
Definition juce_ApplicationProperties.h:125
Definition juce_PropertiesFile.h:48
#define jassert(expression)
Definition carla_juce.cpp:31
Definition juce_PropertiesFile.h:61
bool commonToAllUsers
Definition juce_PropertiesFile.h:109