From 5451c59d927a569f7634be64eee703071b67ea00 Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Sat, 9 Nov 2024 08:43:10 +0200 Subject: [PATCH] Adding option to copy transcription source from transcription table --- .../transcription_tasks_table_widget.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/buzz/widgets/transcription_tasks_table_widget.py b/buzz/widgets/transcription_tasks_table_widget.py index 67718958d..62357ea82 100644 --- a/buzz/widgets/transcription_tasks_table_widget.py +++ b/buzz/widgets/transcription_tasks_table_widget.py @@ -11,7 +11,9 @@ from PyQt6.QtCore import Qt from PyQt6.QtCore import pyqtSignal, QModelIndex from PyQt6.QtSql import QSqlTableModel, QSqlRecord +from PyQt6.QtGui import QKeySequence from PyQt6.QtWidgets import ( + QApplication, QWidget, QMenu, QHeaderView, @@ -250,9 +252,26 @@ def save_column_visibility(self): ) self.settings.end_group() + def copy_selected_fields(self): + selected_text = "" + for row in self.selectionModel().selectedRows(): + row_index = row.row() + file_name = self.model().data(self.model().index(row_index, 3)) + url = self.model().data(self.model().index(row_index, 14)) + + selected_text += f"{file_name}{url}\n" + + selected_text = selected_text.rstrip("\n") + QApplication.clipboard().setText(selected_text) + def keyPressEvent(self, event: QtGui.QKeyEvent) -> None: if event.key() == Qt.Key.Key_Return: self.return_clicked.emit() + + if event.matches(QKeySequence.StandardKey.Copy): + self.copy_selected_fields() + return + super().keyPressEvent(event) def selected_transcriptions(self) -> List[Transcription]: