From 4dd32339761f10db55a6e866ddb6638e7f5bf0cd Mon Sep 17 00:00:00 2001 From: Jim Broadus Date: Sat, 6 Jun 2020 11:27:32 -0700 Subject: [PATCH] organise: Set extension override in OrganiseDialog If the destination device has a transcode option set, then compute filenames with updated extensions. This does not cover the case where Organise needs to transcode due to format support. --- src/ui/organisedialog.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/ui/organisedialog.cpp b/src/ui/organisedialog.cpp index 9f274368b..1705ff8a0 100644 --- a/src/ui/organisedialog.cpp +++ b/src/ui/organisedialog.cpp @@ -265,6 +265,20 @@ void OrganiseDialog::UpdatePreviews() { format_.set_replace_spaces(ui_->replace_spaces->isChecked()); format_.set_replace_the(ui_->replace_the->isChecked()); + // If this is set to Transcode_Always, then the user has selected transcode, + // so we can be fairly certain that the device supports the selected format. + // However, if the option has not been set, and the device does not support + // the file's format, then Organise will try to transcode to a new format and + // the preview will be incorrect. + if (storage && + storage->GetTranscodeMode() == MusicStorage::Transcode_Always) { + const Song::FileType format = storage->GetTranscodeFormat(); + TranscoderPreset preset = Transcoder::PresetForFileType(format); + format_.add_tag_override("extension", preset.extension_); + } else { + format_.reset_tag_overrides(); + } + const bool format_valid = !has_local_destination || format_.IsValid(); // Are we gonna enable the ok button? @@ -345,6 +359,10 @@ void OrganiseDialog::accept() { if (!storage) return; + // Reset the extension override if we set it. Organise should correctly set + // the Song object. + format_.reset_tag_overrides(); + // It deletes itself when it's finished. const bool copy = ui_->aftercopying->currentIndex() == 0; Organise* organise = new Organise(