Skip to content

Commit

Permalink
PICARD-3021: Context menu action to merge original and new metadata v…
Browse files Browse the repository at this point in the history
…alues
  • Loading branch information
phw committed Jan 9, 2025
1 parent d8acdb3 commit 1f0a590
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions picard/ui/metadatabox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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_()
Expand Down

0 comments on commit 1f0a590

Please sign in to comment.