| 630 | } |
| 631 | |
| 632 | void 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 | |
| 665 | void ModuleWidget::save(std::string filename) { |
| 666 | INFO("Saving preset %s", filename.c_str()); |
no test coverage detected