diff --git a/src/Menus.h b/src/Menus.h index cdfa09de0..3405cebb5 100644 --- a/src/Menus.h +++ b/src/Menus.h @@ -106,9 +106,6 @@ public: /// Namespace for functions for Edit menu namespace EditActions { -bool DoEditMetadata( - AudacityProject &project, - const wxString &title, const wxString &shortUndoDescription, bool force ); void DoReloadPreferences( AudacityProject & ); } diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 1ab73df04..f1a876e45 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -61,13 +61,14 @@ #include "../DirManager.h" #include "../FileFormats.h" -#include "../Menus.h" #include "../Mix.h" #include "../Prefs.h" #include "../Project.h" +#include "../ProjectHistory.h" #include "../ProjectSettings.h" #include "../ProjectWindow.h" #include "../ShuttleGui.h" +#include "../Tags.h" #include "../TimeTrack.h" #include "../WaveTrack.h" #include "../widgets/AudacityMessageBox.h" @@ -380,6 +381,34 @@ const ExportPluginArray &Exporter::GetPlugins() return mPlugins; } +bool Exporter::DoEditMetadata(AudacityProject &project, + const wxString &title, const wxString &shortUndoDescription, bool force) +{ + auto &settings = ProjectSettings::Get( project ); + auto &tags = Tags::Get( project ); + + // Back up my tags + // Tags (artist name, song properties, MP3 ID3 info, etc.) + // The structure may be shared with undo history entries + // To keep undo working correctly, always replace this with a NEW duplicate + // BEFORE doing any editing of it! + auto newTags = tags.Duplicate(); + + if (newTags->ShowEditDialog(&GetProjectFrame( project ), title, force)) { + if (tags != *newTags) { + // Commit the change to project state only now. + Tags::Set( project, newTags ); + ProjectHistory::Get( project ).PushState(title, shortUndoDescription); + } + bool bShowInFuture; + gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true); + settings.SetShowId3Dialog( bShowInFuture ); + return true; + } + + return false; +} + bool Exporter::Process(AudacityProject *project, bool selectedOnly, double t0, double t1) { // Save parms @@ -405,9 +434,9 @@ bool Exporter::Process(AudacityProject *project, bool selectedOnly, double t0, d // Let user edit MetaData if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) { - if (!(EditActions::DoEditMetadata( *project, + if (!DoEditMetadata( *project, _("Edit Metadata Tags"), _("Exported Tags"), - ProjectSettings::Get( *mProject ).GetShowId3Dialog()))) { + ProjectSettings::Get( *mProject ).GetShowId3Dialog())) { return false; } } @@ -1044,10 +1073,10 @@ bool Exporter::SetAutoExportOptions(AudacityProject *project) { // Let user edit MetaData if (mPlugins[mFormat]->GetCanMetaData(mSubFormat)) { - if (!(EditActions::DoEditMetadata( *project, + if (!DoEditMetadata( *project, _("Edit Metadata Tags"), _("Exported Tags"), - ProjectSettings::Get(*mProject).GetShowId3Dialog()))) { + ProjectSettings::Get(*mProject).GetShowId3Dialog())) { return false; } } diff --git a/src/export/Export.h b/src/export/Export.h index 6660652c0..091d469da 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -157,6 +157,9 @@ class AUDACITY_DLL_API Exporter final : public wxEvtHandler { public: + static bool DoEditMetadata(AudacityProject &project, + const wxString &title, const wxString &shortUndoDescription, bool force); + Exporter(); virtual ~Exporter(); diff --git a/src/menus/EditMenus.cpp b/src/menus/EditMenus.cpp index eb846cfcc..76fbb4b25 100644 --- a/src/menus/EditMenus.cpp +++ b/src/menus/EditMenus.cpp @@ -11,7 +11,6 @@ #include "../ProjectSettings.h" #include "../ProjectWindow.h" #include "../SelectUtilities.h" -#include "../Tags.h" #include "../TimeTrack.h" #include "../TrackPanel.h" #include "../UndoManager.h" @@ -20,6 +19,7 @@ #include "../commands/CommandContext.h" #include "../commands/CommandManager.h" #include "../commands/ScreenshotCommand.h" +#include "../export/Export.h" #include "../prefs/PrefsDialog.h" #include "../prefs/SpectrogramSettings.h" #include "../prefs/WaveformSettings.h" @@ -206,35 +206,6 @@ void DoReloadPreferences( AudacityProject &project ) } } -bool DoEditMetadata -(AudacityProject &project, - const wxString &title, const wxString &shortUndoDescription, bool force) -{ - auto &settings = ProjectSettings::Get( project ); - auto &tags = Tags::Get( project ); - - // Back up my tags - // Tags (artist name, song properties, MP3 ID3 info, etc.) - // The structure may be shared with undo history entries - // To keep undo working correctly, always replace this with a NEW duplicate - // BEFORE doing any editing of it! - auto newTags = tags.Duplicate(); - - if (newTags->ShowEditDialog(&GetProjectFrame( project ), title, force)) { - if (tags != *newTags) { - // Commit the change to project state only now. - Tags::Set( project, newTags ); - ProjectHistory::Get( project ).PushState(title, shortUndoDescription); - } - bool bShowInFuture; - gPrefs->Read(wxT("/AudioFiles/ShowId3Dialog"), &bShowInFuture, true); - settings.SetShowId3Dialog( bShowInFuture ); - return true; - } - - return false; -} - // Menu handler functions struct Handler : CommandHandlerObject { @@ -1012,7 +983,7 @@ void OnDisjoin(const CommandContext &context) void OnEditMetadata(const CommandContext &context) { auto &project = context.project; - (void)DoEditMetadata( project, + (void)Exporter::DoEditMetadata( project, _("Edit Metadata Tags"), _("Metadata Tags"), true); }