From 29e3a943959176be6c5a7ec1c4deffe00c306c7a Mon Sep 17 00:00:00 2001 From: Raivis Dejus Date: Mon, 18 Nov 2024 15:01:53 +0200 Subject: [PATCH] Will close the app on task finish in CLI (#995) --- buzz/cli.py | 2 +- buzz/widgets/application.py | 3 ++- buzz/widgets/main_window.py | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/buzz/cli.py b/buzz/cli.py index 1540992bd..a12e00792 100644 --- a/buzz/cli.py +++ b/buzz/cli.py @@ -214,7 +214,7 @@ def parse(app: Application, parser: QCommandLineParser): file_transcription_options=file_transcription_options, output_directory=output_directory if output_directory != "" else None, ) - app.add_task(transcription_task) + app.add_task(transcription_task, quit_on_complete=True) T = typing.TypeVar("T", bound=enum.Enum) diff --git a/buzz/widgets/application.py b/buzz/widgets/application.py index 78014f553..e170a80e4 100755 --- a/buzz/widgets/application.py +++ b/buzz/widgets/application.py @@ -175,5 +175,6 @@ def __init__(self, argv: list) -> None: self.window = MainWindow(transcription_service) self.window.show() - def add_task(self, task: FileTranscriptionTask): + def add_task(self, task: FileTranscriptionTask, quit_on_complete: bool = False): + self.window.quit_on_complete = quit_on_complete self.window.add_task(task) diff --git a/buzz/widgets/main_window.py b/buzz/widgets/main_window.py index 9dff43b48..4ce11dc7c 100644 --- a/buzz/widgets/main_window.py +++ b/buzz/widgets/main_window.py @@ -66,6 +66,7 @@ def __init__(self, transcription_service: TranscriptionService): self.shortcuts = Shortcuts(settings=self.settings) + self.quit_on_complete = False self.transcription_service = transcription_service self.toolbar = MainWindowToolbar(shortcuts=self.shortcuts, parent=self) @@ -392,10 +393,17 @@ def on_task_completed(self, task: FileTranscriptionTask, segments: List[Segment] self.transcription_service.update_transcription_as_completed(task.uid, segments) self.table_widget.refresh_row(task.uid) + if self.quit_on_complete: + self.close() + + def on_task_error(self, task: FileTranscriptionTask, error: str): self.transcription_service.update_transcription_as_failed(task.uid, error) self.table_widget.refresh_row(task.uid) + if self.quit_on_complete: + self.close() + def on_shortcuts_changed(self): self.menu_bar.reset_shortcuts() self.toolbar.reset_shortcuts()