Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option to copy transcription source from transcription table #986

Merged
merged 1 commit into from
Nov 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions buzz/widgets/transcription_tasks_table_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -250,9 +252,26 @@
)
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))

Check warning on line 260 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L256-L260

Added lines #L256 - L260 were not covered by tests

selected_text += f"{file_name}{url}\n"

Check warning on line 262 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L262

Added line #L262 was not covered by tests

selected_text = selected_text.rstrip("\n")
QApplication.clipboard().setText(selected_text)

Check warning on line 265 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L264-L265

Added lines #L264 - L265 were not covered by tests

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

Check warning on line 273 in buzz/widgets/transcription_tasks_table_widget.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/transcription_tasks_table_widget.py#L272-L273

Added lines #L272 - L273 were not covered by tests

super().keyPressEvent(event)

def selected_transcriptions(self) -> List[Transcription]:
Expand Down