| 159 | END_EVENT_TABLE() |
| 160 | |
| 161 | ExportAudioDialog::ExportAudioDialog(wxWindow* parent, |
| 162 | AudacityProject& project, |
| 163 | const wxString& defaultName, |
| 164 | const wxString& defaultFormat, |
| 165 | ExportMode mode) |
| 166 | : wxDialogWrapper(parent, wxID_ANY, XO("Export Audio")) |
| 167 | , mProject(project) |
| 168 | { |
| 169 | assert(!ExportUtils::FindExportWaveTracks(TrackList::Get(project), false).empty()); |
| 170 | |
| 171 | ShuttleGui S(this, eIsCreatingFromPrefs); |
| 172 | PopulateOrExchange(S); |
| 173 | |
| 174 | SetMinSize({GetBestSize().GetWidth(), -1}); |
| 175 | |
| 176 | wxFileName filename; |
| 177 | auto exportPath = ExportAudioDefaultPath.Read(); |
| 178 | if(exportPath.empty()) |
| 179 | exportPath = FileNames::FindDefaultPath(FileNames::Operation::Export); |
| 180 | filename.SetPath(exportPath); |
| 181 | |
| 182 | //extension will be set in `ChangeFormat` |
| 183 | filename.SetEmptyExt(); |
| 184 | if(defaultName.empty()) |
| 185 | //i18n-hint: default exported file name when exporting from unsaved project |
| 186 | filename.SetName(_("untitled")); |
| 187 | else |
| 188 | filename.SetName(defaultName); |
| 189 | |
| 190 | auto sampleRate = ImportExport::Get(project).GetPreferredExportRate(); |
| 191 | if(sampleRate == ImportExport::InvalidRate) |
| 192 | { |
| 193 | auto& tracks = TrackList::Get(project); |
| 194 | for(const auto track : tracks.Any<WaveTrack>()) |
| 195 | sampleRate = std::max(sampleRate, track->GetRate()); |
| 196 | } |
| 197 | |
| 198 | wxString format = defaultFormat; |
| 199 | if(format.empty()) |
| 200 | ExportAudioDefaultFormat.Read(&format); |
| 201 | |
| 202 | mExportOptionsPanel->Init(filename, sampleRate, format); |
| 203 | |
| 204 | auto& tracks = TrackList::Get(mProject); |
| 205 | const auto labelTracks = tracks.Any<LabelTrack>(); |
| 206 | const auto hasLabels = !labelTracks.empty() && |
| 207 | (*labelTracks.begin())->GetNumLabels() > 0; |
| 208 | const auto hasMultipleWaveTracks = tracks.Any<WaveTrack>().size() > 1; |
| 209 | const auto hasSelectedAudio = ExportUtils::HasSelectedAudio(mProject); |
| 210 | |
| 211 | mRangeSelection->Enable(hasSelectedAudio); |
| 212 | mRangeSplit->Enable(hasLabels || hasMultipleWaveTracks); |
| 213 | |
| 214 | mSplitByLabels->Enable(hasLabels); |
| 215 | mSplitByTracks->Enable(hasMultipleWaveTracks); |
| 216 | |
| 217 | if(mRangeSelection->IsEnabled() && mode == ExportMode::SelectedOnly) |
| 218 | { |
nothing calls this directly
no test coverage detected