| 718 | } |
| 719 | |
| 720 | void ModuleWidget::saveDialog() { |
| 721 | std::string presetDir = model->getUserPresetDirectory(); |
| 722 | system::createDirectories(presetDir); |
| 723 | |
| 724 | // Delete directories if empty |
| 725 | DEFER({ |
| 726 | try { |
| 727 | system::remove(presetDir); |
| 728 | system::remove(system::getDirectory(presetDir)); |
| 729 | } |
| 730 | catch (Exception& e) { |
| 731 | // Ignore exceptions if directory cannot be removed. |
| 732 | } |
| 733 | }); |
| 734 | |
| 735 | osdialog_filters* filters = osdialog_filters_parse(PRESET_FILTERS); |
| 736 | DEFER({osdialog_filters_free(filters);}); |
| 737 | |
| 738 | char* pathC = osdialog_file(OSDIALOG_SAVE, presetDir.c_str(), "Untitled.vcvm", filters); |
| 739 | if (!pathC) { |
| 740 | // No path selected |
| 741 | return; |
| 742 | } |
| 743 | DEFER({std::free(pathC);}); |
| 744 | |
| 745 | std::string path = pathC; |
| 746 | // Automatically append .vcvm extension |
| 747 | if (system::getExtension(path) != ".vcvm") |
| 748 | path += ".vcvm"; |
| 749 | |
| 750 | save(path); |
| 751 | } |
| 752 | |
| 753 | void ModuleWidget::disconnect() { |
| 754 | for (PortWidget* pw : getPorts()) { |
no test coverage detected