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

Will close the app on task finish in CLI #995

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
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
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 @@

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 @@
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