| 1096 | } |
| 1097 | |
| 1098 | void 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 | |
| 1128 | void RackWidget::saveSelection(std::string path) { |
| 1129 | INFO("Saving selection %s", path.c_str()); |
no test coverage detected