-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
491 additions
and
469 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import sys | ||
from typing import TYPE_CHECKING | ||
|
||
from PySide6.QtCore import QObject, QThread, Signal | ||
from PySide6.QtWidgets import QWidget | ||
|
||
from bd_to_avp.modules.disc import MKVCreationError | ||
from bd_to_avp.modules.util import OutputHandler, terminate_process | ||
from bd_to_avp.process import process | ||
|
||
if TYPE_CHECKING: | ||
from bd_to_avp.gui.main_window import MainWindow | ||
|
||
|
||
class ProcessingSignals(QObject): | ||
progress_updated = Signal(str) | ||
|
||
|
||
class ProcessingThread(QThread): | ||
error_occurred = Signal(Exception) | ||
mkv_creation_error = Signal(MKVCreationError) | ||
|
||
def __init__(self, main_window: "MainWindow", parent: QWidget | None = None) -> None: | ||
super().__init__(parent) | ||
self.signals = ProcessingSignals() | ||
self.output_handler = OutputHandler(self.signals.progress_updated.emit) | ||
self.main_window = main_window | ||
|
||
def run(self) -> None: | ||
sys.stdout = self.output_handler # type: ignore | ||
|
||
try: | ||
process() | ||
except MKVCreationError as error: | ||
self.mkv_creation_error.emit(error) | ||
except (RuntimeError, ValueError) as error: | ||
self.error_occurred.emit(error) | ||
finally: | ||
sys.stdout = sys.__stdout__ | ||
self.signals.progress_updated.emit("Process Completed.") | ||
self.main_window.process_button.setText(self.main_window.START_PROCESSING_TEXT) | ||
|
||
def terminate(self) -> None: | ||
terminate_process() | ||
super().terminate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pathlib import Path | ||
|
||
from PySide6.QtGui import QIcon | ||
from PySide6.QtWidgets import QApplication | ||
|
||
from bd_to_avp.modules.config import config | ||
from bd_to_avp.modules.util import load_data_from_pyproject | ||
|
||
|
||
def load_app_info_from_pyproject(app: QApplication) -> None: | ||
pyproject_data = load_data_from_pyproject() | ||
if not pyproject_data: | ||
return | ||
|
||
tool = pyproject_data.get("tool", {}) | ||
poetry = tool.get("poetry", {}) | ||
briefcase = tool.get("briefcase", {}) | ||
|
||
app.setApplicationName(poetry.get("name")) | ||
app.setOrganizationName(briefcase.get("organization")) | ||
app.setApplicationVersion(config.code_version) | ||
app.setOrganizationDomain(briefcase.get("bundle")) | ||
app.setApplicationDisplayName(briefcase.get("project_name")) | ||
|
||
briefcase_icon_path = Path(briefcase.get("icon")) | ||
icon_path = Path(*briefcase_icon_path.parts[1:]).with_suffix(".icns") | ||
icon_absolute_path = Path(__file__).parent / icon_path | ||
app.setWindowIcon(QIcon(icon_absolute_path.as_posix())) | ||
|
||
app.setProperty("authors", poetry.get("authors", [])) | ||
app.setProperty("url", poetry.get("homepage")) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters