| 104 | } |
| 105 | |
| 106 | OptionalMessage 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(¶ms)) { |
| 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 | |
| 163 | void BasicEffectUIServices::ShowOptions(const EffectPlugin &) const |
nothing calls this directly
no test coverage detected