def create_app(): if not get_bool_env("FF_DPI_OFF"): if hasattr(QtCore.Qt, "AA_EnableHighDpiScaling"): QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling, True) if hasattr(QtCore.Qt, "AA_UseHighDpiPixmaps"): QtWidgets.QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) main_app = FastFlixApp(sys.argv) main_app.setApplicationDisplayName("FastFlix") my_font = QtGui.QFont("helvetica", 9) main_app.setFont(my_font) main_app.setWindowIcon(QtGui.QIcon(main_icon)) return main_app
def __init__(self, parent, video: Video, index, first=False): self.loading = True super().__init__(parent) self.parent = parent self.index = index self.first = first self.last = False self.video = video.copy() self.setFixedHeight(60) self.widgets = Box( up_button=QtWidgets.QPushButton( QtGui.QIcon( get_icon("up-arrow", self.parent.app.fastflix.config.theme)), ""), down_button=QtWidgets.QPushButton( QtGui.QIcon( get_icon("down-arrow", self.parent.app.fastflix.config.theme)), ""), cancel_button=QtWidgets.QPushButton( QtGui.QIcon( get_icon("black-x", self.parent.app.fastflix.config.theme)), ""), reload_button=QtWidgets.QPushButton( QtGui.QIcon( get_icon("edit-box", self.parent.app.fastflix.config.theme)), ""), retry_button=QtWidgets.QPushButton( QtGui.QIcon( get_icon("undo", self.parent.app.fastflix.config.theme)), ""), ) for widget in self.widgets.values(): widget.setStyleSheet(no_border) title = QtWidgets.QLabel( video.video_settings.video_title if video.video_settings. video_title else video.video_settings.output_path.name) title.setFixedWidth(300) settings = Box(copy.deepcopy(video.video_settings.dict())) settings.output_path = str(settings.output_path) for i, o in enumerate(settings.attachment_tracks): if o.get("file_path"): o["file_path"] = str(o["file_path"]) del settings.conversion_commands title.setToolTip(settings.to_yaml()) open_button = QtWidgets.QPushButton( QtGui.QIcon(get_icon("play", self.parent.app.fastflix.config.theme)), t("Open Directory")) open_button.setLayoutDirection(QtCore.Qt.RightToLeft) open_button.setIconSize(QtCore.QSize(14, 14)) open_button.clicked.connect( lambda: open_folder(video.video_settings.output_path.parent)) view_button = QtWidgets.QPushButton( QtGui.QIcon(get_icon("play", self.parent.app.fastflix.config.theme)), t("Watch")) view_button.setLayoutDirection(QtCore.Qt.RightToLeft) view_button.setIconSize(QtCore.QSize(14, 14)) view_button.clicked.connect(lambda: QtGui.QDesktopServices.openUrl( QtCore.QUrl.fromLocalFile(str(video.video_settings.output_path)))) open_button.setStyleSheet(no_border) view_button.setStyleSheet(no_border) add_retry = False status = t("Ready to encode") if video.status.error: status = t("Encoding errored") elif video.status.complete: status = f"{t('Encoding complete')}" elif video.status.running: status = ( f"{t('Encoding command')} {video.status.current_command + 1} {t('of')} " f"{len(video.video_settings.conversion_commands)}") elif video.status.cancelled: status = t("Cancelled") add_retry = True if not self.video.status.running: self.widgets.cancel_button.clicked.connect( lambda: self.parent.remove_item(self.video)) self.widgets.reload_button.clicked.connect( lambda: self.parent.reload_from_queue(self.video)) self.widgets.cancel_button.setFixedWidth(25) self.widgets.reload_button.setFixedWidth(25) else: self.widgets.cancel_button.hide() self.widgets.reload_button.hide() grid = QtWidgets.QGridLayout() grid.addLayout(self.init_move_buttons(), 0, 0) # grid.addWidget(self.widgets.track_number, 0, 1) grid.addWidget(title, 0, 1, 1, 3) grid.addWidget( QtWidgets.QLabel( f"{video.video_settings.video_encoder_settings.name}"), 0, 4) grid.addWidget( QtWidgets.QLabel( f"{t('Audio Tracks')}: {len(video.video_settings.audio_tracks)}" ), 0, 5) grid.addWidget( QtWidgets.QLabel( f"{t('Subtitles')}: {len(video.video_settings.subtitle_tracks)}" ), 0, 6) grid.addWidget(QtWidgets.QLabel(status), 0, 7) if video.status.complete and not get_bool_env("FF_DOCKERMODE"): grid.addWidget(view_button, 0, 8) grid.addWidget(open_button, 0, 9) elif add_retry: grid.addWidget(self.widgets.retry_button, 0, 8) self.widgets.retry_button.setFixedWidth(25) self.widgets.retry_button.clicked.connect( lambda: self.parent.retry_video(self.video)) right_buttons = QtWidgets.QHBoxLayout() right_buttons.addWidget(self.widgets.reload_button) right_buttons.addWidget(self.widgets.cancel_button) grid.addLayout(right_buttons, 0, 10, alignment=QtCore.Qt.AlignRight) self.setLayout(grid) self.loading = False self.updating_burn = False
try: # PyInstaller creates a temp folder and stores path in _MEIPASS # noinspection PyUnresolvedReferences base_path = sys._MEIPASS pyinstaller = True except AttributeError: base_path = os.path.abspath(".") pyinstaller = False from PySide6 import QtCore, QtGui, QtWidgets from fastflix.language import t from fastflix.resources import get_bool_env DEVMODE = get_bool_env("DEVMODE") my_data = str( Path(pkg_resources.resource_filename(__name__, f"../data/icon.ico")).resolve()) icon = QtGui.QIcon(my_data) logger = logging.getLogger("fastflix") no_border = ( "QPushButton, QPushButton:hover, QPushButton:pressed {border-width: 0;} " "QPushButton:hover {border-bottom: 1px solid #aaa}") class MyMessageBox(QtWidgets.QMessageBox): def __init__(self): QtWidgets.QMessageBox.__init__(self)