MCPcopy Create free account
hub / github.com/audacity/audacity / ImportPresets

Method ImportPresets

src/effects/BasicEffectUIServices.cpp:106–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106OptionalMessage BasicEffectUIServices::ImportPresets(
107 const EffectPlugin &plugin, EffectSettings &settings) const
108{
109 wxString params;
110
111 auto path = SelectFile(FileNames::Operation::Presets,
112 XO("Import Effect Parameters"),
113 wxEmptyString,
114 wxEmptyString,
115 wxEmptyString,
116 PresetTypes(),
117 wxFD_OPEN | wxRESIZE_BORDER,
118 nullptr);
119 if (path.empty()) {
120 return {};
121 }
122
123 wxFFile f(path);
124 if (!f.IsOpened())
125 return {};
126
127 OptionalMessage result{};
128
129 if (f.ReadAll(&params)) {
130 wxString ident = params.BeforeFirst(':');
131 params = params.AfterFirst(':');
132
133 auto commandId = plugin.GetSquashedName(plugin.GetSymbol().Internal());
134
135 if (ident != commandId) {
136 // effect identifiers are a sensible length!
137 // must also have some params.
138 if ((params.Length() < 2 ) || (ident.Length() < 2) ||
139 (ident.Length() > 30))
140 {
141 EffectUIServices::DoMessageBox(plugin,
142 /* i18n-hint %s will be replaced by a file name */
143 XO("%s: is not a valid presets file.\n")
144 .Format(wxFileNameFromPath(path)));
145 }
146 else
147 {
148 EffectUIServices::DoMessageBox(plugin,
149 /* i18n-hint %s will be replaced by a file name */
150 XO("%s: is for a different Effect, Generator or Analyzer.\n")
151 .Format(wxFileNameFromPath(path)));
152 }
153 return {};
154 }
155 result = plugin.LoadSettingsFromString(params, settings);
156 }
157
158 //SetWindowTitle();
159
160 return result;
161}
162
163void BasicEffectUIServices::ShowOptions(const EffectPlugin &) const

Callers

nothing calls this directly

Calls 8

SelectFileFunction · 0.85
IsOpenedMethod · 0.80
GetSquashedNameMethod · 0.80
LengthMethod · 0.80
DoMessageBoxFunction · 0.70
emptyMethod · 0.45
GetSymbolMethod · 0.45

Tested by

no test coverage detected