From 1f0a59064d5bd8faf48a3de8d92627c215137839 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 4e05fb05f6..a6c0a60d17 100644 --- a/picard/ui/metadatabox.py +++ b/picard/ui/metadatabox.py @@ -434,6 +434,9 @@ def contextMenuEvent(self, event): use_orig_value_action = QtWidgets.QAction(name, self.parent) use_orig_value_action.triggered.connect(partial(self._apply_update_funcs, useorigs)) menu.addAction(use_orig_value_action) + merge_tags_action = QtWidgets.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() @@ -460,6 +463,16 @@ def _apply_update_funcs(self, funcs): f() self.parent.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.parent, tag).exec_()