MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / saveDialog

Method saveDialog

src/override/ModuleWidget.cpp:750–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750void ModuleWidget::saveDialog() {
751 std::string presetDir = model->getUserPresetDirectory();
752 system::createDirectories(presetDir);
753
754 WeakPtr<ModuleWidget> weakThis = this;
755 async_dialog_filebrowser(true, "preset.vcvm", presetDir.c_str(), "Save preset", [=](char* pathC) {
756
757 // Delete directories if empty
758 DEFER({
759 try {
760 system::remove(presetDir);
761 system::remove(system::getDirectory(presetDir));
762 }
763 catch (Exception& e) {
764 // Ignore exceptions if directory cannot be removed.
765 }
766 });
767
768 if (!weakThis)
769 return;
770 if (!pathC) {
771 // No path selected
772 return;
773 }
774 DEFER({std::free(pathC);});
775
776 std::string path = pathC;
777 // Automatically append .vcvm extension
778 if (system::getExtension(path) != ".vcvm")
779 path += ".vcvm";
780
781 weakThis->save(path);
782 });
783}
784
785void ModuleWidget::disconnect() {
786 for (PortWidget* pw : getPorts()) {

Callers 1

createContextMenuMethod · 0.45

Calls 4

c_strMethod · 0.80
async_dialog_filebrowserFunction · 0.50
saveMethod · 0.45

Tested by

no test coverage detected