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 hide GUI window in CLI mode #996

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
1 change: 1 addition & 0 deletions buzz/buzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@

app = Application(sys.argv)
parse_command_line(app)
app.show_main_window()

Check warning on line 68 in buzz/buzz.py

View check run for this annotation

Codecov / codecov/patch

buzz/buzz.py#L68

Added line #L68 was not covered by tests
sys.exit(app.exec())
4 changes: 4 additions & 0 deletions buzz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
srt_option = QCommandLineOption(["srt"], "Output result in an SRT file.")
vtt_option = QCommandLineOption(["vtt"], "Output result in a VTT file.")
txt_option = QCommandLineOption("txt", "Output result in a TXT file.")
hide_gui_option = QCommandLineOption("hide-gui", "Hide the main application window.")

parser.addOptions(
[
Expand All @@ -124,6 +125,7 @@
srt_option,
vtt_option,
txt_option,
hide_gui_option,
]
)

Expand Down Expand Up @@ -216,6 +218,8 @@
)
app.add_task(transcription_task, quit_on_complete=True)

if parser.isSet(hide_gui_option):
app.hide_main_window = True

Check warning on line 222 in buzz/cli.py

View check run for this annotation

Codecov / codecov/patch

buzz/cli.py#L222

Added line #L222 was not covered by tests

T = typing.TypeVar("T", bound=enum.Enum)

Expand Down
6 changes: 5 additions & 1 deletion buzz/widgets/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

self.setApplicationName(APP_NAME)
self.setApplicationVersion(VERSION)
self.hide_main_window = False

if sys.platform.startswith("win") and darkdetect.isDark():
palette = QPalette()
Expand Down Expand Up @@ -173,7 +174,10 @@
)

self.window = MainWindow(transcription_service)
self.window.show()

def show_main_window(self):
if not self.hide_main_window:
self.window.show()

Check warning on line 180 in buzz/widgets/application.py

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/application.py#L179-L180

Added lines #L179 - L180 were not covered by tests

def add_task(self, task: FileTranscriptionTask, quit_on_complete: bool = False):
self.window.quit_on_complete = quit_on_complete
Expand Down
3 changes: 3 additions & 0 deletions buzz/widgets/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
)
from PyQt6.QtGui import QIcon
from PyQt6.QtWidgets import (
QApplication,
QMainWindow,
QMessageBox,
QFileDialog,
Expand Down Expand Up @@ -395,6 +396,7 @@

if self.quit_on_complete:
self.close()
QApplication.quit()


def on_task_error(self, task: FileTranscriptionTask, error: str):
Expand All @@ -403,6 +405,7 @@

if self.quit_on_complete:
self.close()
QApplication.quit()

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

View check run for this annotation

Codecov / codecov/patch

buzz/widgets/main_window.py#L408

Added line #L408 was not covered by tests

def on_shortcuts_changed(self):
self.menu_bar.reset_shortcuts()
Expand Down
1 change: 1 addition & 0 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ Options:
--srt Output result in an SRT file.
--vtt Output result in a VTT file.
--txt Output result in a TXT file.
--hide-gui Hide the main application window.
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-v, --version Displays version information.
Expand Down
14 changes: 13 additions & 1 deletion docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,16 @@ sidebar_position: 5

If a model download was incomplete or corrupted, Buzz may crash. Try to delete the downloaded model files in `Help -> Preferences -> Models` and re-download them.

If that does not help, check the log file for errors and [report the issue](https://github.com/chidiwilliams/buzz/issues) so we can fix it. The log file is located in `~/Library/Logs/Buzz` (Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Logs` (Windows). On Linux run the Buzz from the command line to see the relevant messages.
If that does not help, check the log file for errors and [report the issue](https://github.com/chidiwilliams/buzz/issues) so we can fix it. The log file is located in `~/Library/Logs/Buzz` (Mac OS) or `%USERPROFILE%\AppData\Local\Buzz\Buzz\Logs` (Windows). On Linux run the Buzz from the command line to see the relevant messages.

9. **Where can I get latest development version?**

Latest development version will have latest bug fixes and most recent features. If you feel a bit adventurous it is recommended to try the latest development version as they needs some testing before they get released to everybody.

Linux users can get the latest version with this command `sudo snap install buzz --edge`

For other platforms do the following:
- Go to the [build section](https://github.com/chidiwilliams/buzz/actions/workflows/ci.yml?query=branch%3Amain)
- Click on the link to the latest build
- Scroll down to the artifacts section in the build page
- Download the installation file. Please note that you need to be logged in the Github to see the download links.