mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 09:18:18 +00:00
PICARD-2034: Add copy and paste context menu entries in metadata view
This commit is contained in:
21658
picard/resources.py
21658
picard/resources.py
File diff suppressed because it is too large
Load Diff
@@ -49,6 +49,7 @@ from picard.metadata import MULTI_VALUED_JOINER
|
||||
from picard.track import Track
|
||||
from picard.util import (
|
||||
format_time,
|
||||
icontheme,
|
||||
restore_method,
|
||||
thread,
|
||||
throttle,
|
||||
@@ -282,20 +283,32 @@ class MetadataBox(QtWidgets.QTableWidget):
|
||||
return super().edit(index, trigger, event)
|
||||
return False
|
||||
|
||||
def event(self, e):
|
||||
def keyPressEvent(self, event):
|
||||
if event.matches(QtGui.QKeySequence.Copy):
|
||||
self.copy_value()
|
||||
elif event.matches(QtGui.QKeySequence.Paste):
|
||||
self.paste_value()
|
||||
else:
|
||||
super().keyPressEvent(event)
|
||||
|
||||
def copy_value(self):
|
||||
item = self.currentItem()
|
||||
if (item and e.type() == QtCore.QEvent.KeyPress and e.modifiers() == QtCore.Qt.ControlModifier):
|
||||
if item:
|
||||
column = item.column()
|
||||
tag = self.tag_diff.tag_names[item.row()]
|
||||
if e.key() == QtCore.Qt.Key_C:
|
||||
if column == 1:
|
||||
self.clipboard = list(self.tag_diff.orig[tag])
|
||||
elif column == 2:
|
||||
self.clipboard = list(self.tag_diff.new[tag])
|
||||
elif e.key() == QtCore.Qt.Key_V and column == 2 and tag != "~length":
|
||||
if column == 1:
|
||||
self.clipboard = list(self.tag_diff.orig[tag])
|
||||
elif column == 2:
|
||||
self.clipboard = list(self.tag_diff.new[tag])
|
||||
|
||||
def paste_value(self):
|
||||
item = self.currentItem()
|
||||
if item:
|
||||
column = item.column()
|
||||
tag = self.tag_diff.tag_names[item.row()]
|
||||
if column == 2 and tag != "~length":
|
||||
self.set_tag_values(tag, list(self.clipboard))
|
||||
self.update()
|
||||
return super().event(e)
|
||||
|
||||
def closeEditor(self, editor, hint):
|
||||
super().closeEditor(editor, hint)
|
||||
@@ -384,6 +397,16 @@ class MetadataBox(QtWidgets.QTableWidget):
|
||||
use_orig_value_action.triggered.connect(partial(self._apply_update_funcs, useorigs))
|
||||
menu.addAction(use_orig_value_action)
|
||||
menu.addSeparator()
|
||||
if len(tags) == 1:
|
||||
menu.addSeparator()
|
||||
copy_action = QtWidgets.QAction(icontheme.lookup('edit-copy', icontheme.ICON_SIZE_MENU), _("&Copy"), self)
|
||||
copy_action.triggered.connect(self.copy_value)
|
||||
copy_action.setShortcut(QtGui.QKeySequence.Copy)
|
||||
menu.addAction(copy_action)
|
||||
paste_action = QtWidgets.QAction(icontheme.lookup('edit-paste', icontheme.ICON_SIZE_MENU), _("&Paste"), self)
|
||||
paste_action.triggered.connect(self.paste_value)
|
||||
paste_action.setShortcut(QtGui.QKeySequence.Paste)
|
||||
menu.addAction(paste_action)
|
||||
if len(tags) == 1 or removals or useorigs:
|
||||
menu.addSeparator()
|
||||
menu.addAction(self.add_tag_action)
|
||||
|
||||
BIN
resources/images/16x16/edit-copy.png
Normal file
BIN
resources/images/16x16/edit-copy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 421 B |
BIN
resources/images/16x16/edit-copy@2x.png
Normal file
BIN
resources/images/16x16/edit-copy@2x.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 718 B |
156
resources/img-src/edit-copy.svg
Normal file
156
resources/img-src/edit-copy.svg
Normal file
@@ -0,0 +1,156 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
id="Capa_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 58 58"
|
||||
style="enable-background:new 0 0 58 58;"
|
||||
xml:space="preserve"
|
||||
sodipodi:docname="edit-copy.svg"
|
||||
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
|
||||
id="metadata71"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs69">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1848"
|
||||
inkscape:window-height="1016"
|
||||
id="namedview67"
|
||||
showgrid="false"
|
||||
inkscape:zoom="7.4310345"
|
||||
inkscape:cx="18.432788"
|
||||
inkscape:cy="25.472802"
|
||||
inkscape:window-x="72"
|
||||
inkscape:window-y="27"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Capa_1" />
|
||||
<g
|
||||
id="g115"
|
||||
transform="matrix(0.85892673,0,0,0.85892673,0.28214655,0)"><polygon
|
||||
style="fill:#545e73"
|
||||
points="2,58 49,58 49,2 34,2 30,2 30,5 21,5 21,2 17,2 2,2 "
|
||||
id="polygon2" /><rect
|
||||
x="21"
|
||||
style="fill:#404656"
|
||||
width="9"
|
||||
height="5"
|
||||
id="rect4"
|
||||
y="0" /><polygon
|
||||
style="fill:#8697cb"
|
||||
points="37,2 30,2 30,5 21,5 21,2 14,2 14,8 37,8 "
|
||||
id="polygon8" /></g><g
|
||||
id="g972"
|
||||
transform="matrix(0.90104204,0,0,0.90104204,5.5687605,5.6041745)"><rect
|
||||
id="rect137"
|
||||
width="36"
|
||||
height="43.902"
|
||||
x="20.274"
|
||||
y="12.729869"
|
||||
style="fill:#efebde;fill-opacity:1;stroke-width:1.244;stroke-miterlimit:4;stroke-dasharray:none" /><g
|
||||
id="g82"
|
||||
transform="matrix(0.87804878,0,0,0.87804878,15.883756,8.3396248)"><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 24,16 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 13 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path10" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 24,47 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 13 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path12" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 40,22 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 29 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path14" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 40,34 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 29 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path16" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 40,41 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 29 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path18" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 25,28 H 11 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 14 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path20" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="m 40,28 h -7 c -0.553,0 -1,-0.447 -1,-1 0,-0.553 0.447,-1 1,-1 h 7 c 0.553,0 1,0.447 1,1 0,0.553 -0.447,1 -1,1 z"
|
||||
id="path22" /><path
|
||||
style="fill:#d5d0bb"
|
||||
d="M 29,28 C 28.729,28 28.479,27.899 28.29,27.71 28.109,27.52 28,27.26 28,27 c 0,-0.271 0.1,-0.521 0.29,-0.71 0.38,-0.38 1.04,-0.37 1.42,0 0.189,0.189 0.29,0.439 0.29,0.71 0,0.27 -0.11,0.52 -0.29,0.71 C 29.52,27.89 29.27,28 29,28 Z"
|
||||
id="path24" /></g></g><g
|
||||
id="g32">
|
||||
|
||||
|
||||
</g>
|
||||
<g
|
||||
id="g36">
|
||||
</g>
|
||||
<g
|
||||
id="g38">
|
||||
</g>
|
||||
<g
|
||||
id="g40">
|
||||
</g>
|
||||
<g
|
||||
id="g42">
|
||||
</g>
|
||||
<g
|
||||
id="g44">
|
||||
</g>
|
||||
<g
|
||||
id="g46">
|
||||
</g>
|
||||
<g
|
||||
id="g48">
|
||||
</g>
|
||||
<g
|
||||
id="g50">
|
||||
</g>
|
||||
<g
|
||||
id="g52">
|
||||
</g>
|
||||
<g
|
||||
id="g54">
|
||||
</g>
|
||||
<g
|
||||
id="g56">
|
||||
</g>
|
||||
<g
|
||||
id="g58">
|
||||
</g>
|
||||
<g
|
||||
id="g60">
|
||||
</g>
|
||||
<g
|
||||
id="g62">
|
||||
</g>
|
||||
<g
|
||||
id="g64">
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
@@ -16,6 +16,8 @@
|
||||
<file>images/16x16/document-save@2x.png</file>
|
||||
<file>images/16x16/edit-clear.png</file>
|
||||
<file>images/16x16/edit-clear@2x.png</file>
|
||||
<file>images/16x16/edit-copy.png</file>
|
||||
<file>images/16x16/edit-copy@2x.png</file>
|
||||
<file>images/16x16/edit-cut.png</file>
|
||||
<file>images/16x16/edit-cut@2x.png</file>
|
||||
<file>images/16x16/edit-paste.png</file>
|
||||
|
||||
Reference in New Issue
Block a user