MCPcopy Create free account
hub / github.com/VCVRack/Rack / loadDialog

Method loadDialog

src/app/ModuleWidget.cpp:632–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632void ModuleWidget::loadDialog() {
633 std::string presetDir = model->getUserPresetDirectory();
634 system::createDirectories(presetDir);
635
636 // Delete directories if empty
637 DEFER({
638 try {
639 system::remove(presetDir);
640 system::remove(system::getDirectory(presetDir));
641 }
642 catch (Exception& e) {
643 // Ignore exceptions if directory cannot be removed.
644 }
645 });
646
647 osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS);
648 DEFER({osdialog_filters_free(filters);});
649
650 char* pathC = osdialog_file(OSDIALOG_OPEN, presetDir.c_str(), NULL, filters);
651 if (!pathC) {
652 // No path selected
653 return;
654 }
655 DEFER({std::free(pathC);});
656
657 try {
658 loadAction(pathC);
659 }
660 catch (Exception& e) {
661 osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
662 }
663}
664
665void ModuleWidget::save(std::string filename) {
666 INFO("Saving preset %s", filename.c_str());

Callers 3

onHoverKeyMethod · 0.45
createContextMenuMethod · 0.45
onActionMethod · 0.45

Calls 5

createDirectoriesFunction · 0.85
removeFunction · 0.85
getDirectoryFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected