From 402792113e8ce2387493da88697c5df00ed4db23 Mon Sep 17 00:00:00 2001 From: Philipp Wolfer Date: Wed, 8 Jan 2025 15:11:43 +0100 Subject: [PATCH] PICARD-3021: Context menu action to merge original and new metadata values --- picard/ui/metadatabox.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/picard/ui/metadatabox.py b/picard/ui/metadatabox.py index a2b4abfe2b..f5e90312df 100644 --- a/picard/ui/metadatabox.py +++ b/picard/ui/metadatabox.py @@ -465,6 +465,9 @@ def contextMenuEvent(self, event): use_orig_value_action = QtGui.QAction(name, self) use_orig_value_action.triggered.connect(partial(self._apply_update_funcs, useorigs)) menu.addAction(use_orig_value_action) + merge_tags_action = QtGui.QAction(_("Merge Original Values"), self) + merge_tags_action.triggered.connect(partial(self._merge_tags, selected_tag)) + menu.addAction(merge_tags_action) menu.addSeparator() if single_tag: menu.addSeparator() @@ -491,6 +494,16 @@ def _apply_update_funcs(self, funcs): f() self.tagger.window.update_selection(new_selection=False, drop_album_caches=True) + def _merge_tags(self, tag): + with self.tagger.window.ignore_selection_changes: + for obj in self.objects: + values = list(obj.orig_metadata.getall(tag)) + for new_value in obj.metadata.getall(tag): + if new_value not in values: + values.append(new_value) + obj.metadata[tag] = values + obj.update() + def _edit_tag(self, tag): if self.tag_diff is not None: EditTagDialog(self, tag).exec()