296{
298 throw std::runtime_error("This preset transaction has already been committed; start a new begin_update()");
300 throw std::runtime_error("This preset transaction has no target");
301
302 PresetUpdateResult result;
306 PresetBundle& bundle = *app.preset_bundle;
308
309
310
311 const std::string edited = collection.get_edited_preset().name;
313 throw std::runtime_error(
"The edited " + std::string(
preset_tab_name(
type)) +
" preset is \"" + edited
314 +
"\", not this transaction's target \"" +
target_name
315 + "\"; nothing was applied");
316
318
321 throw std::runtime_error(
"Filament slot " + std::to_string(
slot_number) +
" now holds \"" + now_assigned
323 + "\" as when this transaction was created; the slot mapping changed, so nothing was applied");
324 }
325
326
327
328
329
330 tab->apply_preset_config_values(
staged);
331
337 result.keys.reserve(
staged.size());
338 for (
const auto& entry :
staged)
339 result.keys.push_back(entry.first);
340 result.dirty = collection.get_edited_preset().is_dirty;
341
343
344
345 for (std::size_t index = 0; index < bundle.filament_presets.size(); ++index) {
346 Preset* preset = bundle.filaments.find_preset(bundle.filament_presets[index]);
347 if (preset !=
nullptr && preset->name ==
target_name)
348 result.shared_slots.push_back(static_cast<int>(index) + 1);
349 }
350 }
351 });
352
354 return result;
355}
static void run_on_ui_thread(std::function< void()> fn)
Definition PluginHostUi.cpp:677
@ TYPE_INVALID
Definition Preset.hpp:245
GUI::Tab * require_tab(GUI::GUI_App &app, Preset::Type type)
Definition PluginHostPresets.cpp:172
std::string resolved_slot_preset(PresetBundle &bundle, int slot_number)
Definition PluginHostPresets.cpp:266
const char * preset_tab_name(Preset::Type type)
Definition PluginHostPresets.cpp:62
GUI::GUI_App & require_gui_app()
Definition PluginHostPresets.cpp:160
PresetCollection & collection_for(PresetBundle &bundle, Preset::Type type)
Definition PluginHostPresets.cpp:72
@ Preset
Definition calib.hpp:39
Preset::Type type
Definition PluginHostPresets.cpp:144
std::string slot_assignment_snapshot
Definition PluginHostPresets.cpp:148
std::vector< std::pair< std::string, std::string > > staged
Definition PluginHostPresets.cpp:152
bool filament
Definition PluginHostPresets.cpp:146
bool committed
Definition PluginHostPresets.cpp:154
int slot_number
Definition PluginHostPresets.cpp:147
std::string target_name
Definition PluginHostPresets.cpp:145
bool selection_changed
Definition PluginHostPresets.cpp:149
bool slot_assignment_changed
Definition PluginHostPresets.cpp:150