| 480 | } |
| 481 | |
| 482 | void ExportAudioDialog::OnExport(wxCommandEvent &event) |
| 483 | { |
| 484 | auto selectedPlugin = mExportOptionsPanel->GetPlugin(); |
| 485 | if(selectedPlugin == nullptr) |
| 486 | return; |
| 487 | auto selectedFormat = mExportOptionsPanel->GetFormat(); |
| 488 | auto parameters = mExportOptionsPanel->GetParameters(); |
| 489 | if(!parameters.has_value()) |
| 490 | return; |
| 491 | |
| 492 | const auto path = mExportOptionsPanel->GetPath(); |
| 493 | |
| 494 | if(!wxDirExists(path)) |
| 495 | wxFileName::Mkdir(path, wxS_DIR_DEFAULT, wxPATH_MKDIR_FULL); |
| 496 | |
| 497 | if(!wxDirExists(path)) |
| 498 | { |
| 499 | AudacityMessageBox(XO("Unable to create destination folder"), |
| 500 | XO("Export Audio"), |
| 501 | wxOK | wxCENTER, |
| 502 | this); |
| 503 | return; |
| 504 | } |
| 505 | |
| 506 | auto result = ExportResult::Error; |
| 507 | |
| 508 | if(mRangeSplit->GetValue()) |
| 509 | { |
| 510 | FilePaths exportedFiles; |
| 511 | |
| 512 | UpdateExportSettings(); |
| 513 | |
| 514 | if(mSplitByLabels->GetValue()) |
| 515 | result = DoExportSplitByLabels(*selectedPlugin, selectedFormat, *parameters, exportedFiles); |
| 516 | else if(mSplitByTracks->GetValue()) |
| 517 | result = DoExportSplitByTracks(*selectedPlugin, selectedFormat, *parameters, exportedFiles); |
| 518 | |
| 519 | auto msg = (result == ExportResult::Success |
| 520 | ? XO("Successfully exported the following %lld file(s).") |
| 521 | : result == ExportResult::Error |
| 522 | ? XO("Something went wrong after exporting the following %lld file(s).") |
| 523 | : result == ExportResult::Cancelled |
| 524 | ? XO("Export canceled after exporting the following %lld file(s).") |
| 525 | : result == ExportResult::Stopped |
| 526 | ? XO("Export stopped after exporting the following %lld file(s).") |
| 527 | : XO("Something went really wrong after exporting the following %lld file(s).") |
| 528 | ).Format((long long) exportedFiles.size()); |
| 529 | |
| 530 | wxString fileList; |
| 531 | for (auto& path : exportedFiles) |
| 532 | fileList += path + '\n'; |
| 533 | |
| 534 | // TODO: give some warning dialog first, when only some files exported |
| 535 | // successfully. |
| 536 | |
| 537 | HelpSystem::ShowInfoDialog( this, |
| 538 | XO("Export Audio"), |
| 539 | msg, |
nothing calls this directly
no test coverage detected