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

Method loadSelectionDialog

src/app/RackWidget.cpp:1098–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1096}
1097
1098void RackWidget::loadSelectionDialog() {
1099 std::string dir = settings::lastSelectionDirectory;
1100
1101 // Use fallback <Rack user dir>/selections
1102 if (dir == "" || !system::isDirectory(dir)) {
1103 dir = asset::user("selections");
1104 system::createDirectory(dir);
1105 }
1106
1107 osdialog_filters* filters = osdialog_filters_parse(SELECTION_FILTERS);
1108 DEFER({osdialog_filters_free(filters);});
1109
1110 char* pathC = osdialog_file(OSDIALOG_OPEN, dir.c_str(), NULL, filters);
1111 if (!pathC) {
1112 // Cancel silently
1113 return;
1114 }
1115 std::string path = pathC;
1116 std::free(pathC);
1117
1118 try {
1119 loadSelection(path);
1120 }
1121 catch (Exception& e) {
1122 osdialog_message(OSDIALOG_WARNING, OSDIALOG_OK, e.what());
1123 }
1124
1125 settings::lastSelectionDirectory = system::getDirectory(path);
1126}
1127
1128void RackWidget::saveSelection(std::string path) {
1129 INFO("Saving selection %s", path.c_str());

Callers 1

onActionMethod · 0.80

Calls 5

isDirectoryFunction · 0.85
userFunction · 0.85
createDirectoryFunction · 0.85
getDirectoryFunction · 0.85
whatMethod · 0.80

Tested by

no test coverage detected