Skip to content

Commit

Permalink
Will close the app on task finish in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
raivisdejus committed Nov 18, 2024
1 parent c181a28 commit d575a7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion buzz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion buzz/widgets/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 8 additions & 0 deletions buzz/widgets/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Check warning on line 405 in buzz/widgets/main_window.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/main_window.py#L404-L405

Added lines #L404 - L405 were not covered by tests

def on_shortcuts_changed(self):
self.menu_bar.reset_shortcuts()
self.toolbar.reset_shortcuts()
Expand Down

0 comments on commit d575a7a

Please sign in to comment.