Skip to content

Commit

Permalink
Copy and Paste added + Shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
Creepler13 committed Apr 27, 2024
1 parent c955fb1 commit 8ec0948
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tagstudio/src/qt/ts_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3990,6 +3990,20 @@ def start(self):
new_tag_action.setToolTip('Ctrl+T')
edit_menu.addAction(new_tag_action)

edit_menu.addSeparator()

copy_entry_fields_action = QAction('&Copy', menu_bar)
copy_entry_fields_action.triggered.connect(lambda: self.copy_entry_fields_action_callback())
copy_entry_fields_action.setShortcut(QtCore.QKeyCombination(QtCore.Qt.KeyboardModifier(QtCore.Qt.KeyboardModifier.ControlModifier), QtCore.Qt.Key.Key_C))
copy_entry_fields_action.setToolTip('Ctrl+C')
edit_menu.addAction(copy_entry_fields_action)

paste_entry_fields_action = QAction('&Paste', menu_bar)
paste_entry_fields_action.triggered.connect(lambda: self.paste_entry_fields_action_callback())
paste_entry_fields_action.setShortcut(QtCore.QKeyCombination(QtCore.Qt.KeyboardModifier(QtCore.Qt.KeyboardModifier.ControlModifier), QtCore.Qt.Key.Key_V))
paste_entry_fields_action.setToolTip('Ctrl+V')
edit_menu.addAction(paste_entry_fields_action)

edit_menu.addSeparator()

manage_file_extensions_action = QAction('Ignore File Extensions', menu_bar)
Expand Down Expand Up @@ -4357,6 +4371,21 @@ def run_macro(self, name: str, entry_id: int):
self.lib.get_field_attr(field, 'content')),
mode='replace')

def copy_entry_fields_action_callback(self):
for item in self.selected.__reversed__():
if item[0] == ItemType.ENTRY:
entry = self.lib.get_entry(item[1])
self.copied_fields = entry.fields.copy()

def paste_entry_fields_action_callback(self):
if self.copied_fields != None:
for item in self.selected:
if item[0] == ItemType.ENTRY:
entry = self.lib.get_entry(item[1])
entry.fields = self.copied_fields.copy()
self.preview_panel.update_widgets()


def mouse_navigation(self, event: QMouseEvent):
# print(event.button())
if event.button() == Qt.MouseButton.ForwardButton:
Expand Down

0 comments on commit 8ec0948

Please sign in to comment.