Пример #1
0
    def __init__(self, app: FastFlixApp, **kwargs):
        super().__init__(None)
        self.app = app
        self.pb = None

        self.logs = Logs()
        self.changes = Changes()
        self.about = None
        self.profile_details = None

        self.init_menu()

        self.main = Main(self, app)
        self.profile = ProfileWindow(self.app, self.main)

        self.setCentralWidget(self.main)
        self.setBaseSize(QtCore.QSize(1350, 750))
        self.icon = QtGui.QIcon(main_icon)
        self.setWindowIcon(self.icon)
        self.main.set_profile()

        if self.app.fastflix.config.theme == "onyx":
            self.setStyleSheet("""
                QAbstractItemView{ background-color: #707070; }
                QPushButton{ border-radius:10px; }
                QLineEdit{ background-color: #707070; color: black; border-radius: 10px; }
                QTextEdit{ background-color: #707070; color: black; }
                QTabBar::tab{ background-color: #4b5054; }
                QComboBox{ border-radius:10px; }
                QScrollArea{ border: 1px solid #919191; }
                """)
Пример #2
0
 def __init__(self, data_path, work_path, config_file, main_app, **kwargs):
     super().__init__()
     self.app = main_app
     self.log_dir = data_path / "logs"
     self.logs = Logs()
     self.changes = Changes()
     self.about = None
     self.init_menu()
     self.config_file = config_file
     self.main = Main(self, data_path, work_path, **kwargs)
     self.setCentralWidget(self.main)
     self.setMinimumSize(1200, 600)
     my_data = str(
         Path(pkg_resources.resource_filename(
             __name__, f"../data/icon.ico")).resolve())
     self.icon = QtGui.QIcon(my_data)
     self.setWindowIcon(self.icon)
Пример #3
0
    def __init__(self, app: FastFlixApp, **kwargs):
        super().__init__(None)
        self.app = app

        self.logs = Logs()
        self.changes = Changes()
        self.about = None
        self.profile_details = None

        self.init_menu()

        self.main = Main(self, app)
        self.profile = ProfileWindow(self.app, self.main)

        self.setCentralWidget(self.main)
        self.setMinimumSize(QtCore.QSize(1200, 650))
        self.icon = QtGui.QIcon(main_icon)
        self.setWindowIcon(self.icon)
Пример #4
0
class Container(QtWidgets.QMainWindow):
    def __init__(self, data_path, work_path, config_file, main_app, **kwargs):
        super().__init__()
        self.app = main_app
        self.log_dir = data_path / "logs"
        self.logs = Logs()
        self.changes = Changes()
        self.about = None
        self.init_menu()
        self.config_file = config_file
        self.main = Main(self, data_path, work_path, **kwargs)
        self.setCentralWidget(self.main)
        self.setMinimumSize(1200, 600)
        my_data = str(
            Path(pkg_resources.resource_filename(
                __name__, f"../data/icon.ico")).resolve())
        self.icon = QtGui.QIcon(my_data)
        self.setWindowIcon(self.icon)

    def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        if self.main.converting:
            sm = QtWidgets.QMessageBox()
            sm.setText("<h2>There is a conversion in process!</h2>")
            sm.addButton("Cancel Conversion", QtWidgets.QMessageBox.RejectRole)
            sm.addButton("Close GUI Only",
                         QtWidgets.QMessageBox.DestructiveRole)
            sm.addButton("Keep FastFlix Open",
                         QtWidgets.QMessageBox.AcceptRole)
            sm.exec_()
            if sm.clickedButton().text() == "Cancel Conversion":
                self.main.worker_queue.put(["cancel"])
                self.main.close()
            elif sm.clickedButton().text() == "Close GUI Only":
                self.main.close(no_cleanup=True)
                return super(Container, self).closeEvent(a0)
            else:
                a0.ignore()
                return

        for item in self.main.path.work.iterdir():
            if item.is_dir() and item.stem.startswith("temp_"):
                shutil.rmtree(item, ignore_errors=True)
            if item.name.lower().endswith((".jpg", ".jpeg", ".png", ".gif")):
                item.unlink()
        super(Container, self).closeEvent(a0)

    def init_menu(self):
        menubar = self.menuBar()

        file_menu = menubar.addMenu("&File")

        setting_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_FileDialogListView),
            "&Settings", self)
        setting_action.setShortcut("Ctrl+S")
        setting_action.triggered.connect(self.show_setting)

        exit_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_DialogCancelButton),
            "&Exit", self)
        exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))
        exit_action.setStatusTip("Exit application")
        exit_action.triggered.connect(self.close)

        file_menu.addAction(setting_action)
        file_menu.addSeparator()
        file_menu.addAction(exit_action)

        about_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_FileDialogInfoView),
            "&About", self)
        about_action.triggered.connect(self.show_about)

        changes_action = QtWidgets.QAction(
            self.style().standardIcon(
                QtWidgets.QStyle.SP_FileDialogDetailedView), "View &Changes",
            self)
        changes_action.triggered.connect(self.show_changes)

        log_dir_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_DialogOpenButton),
            "Open Log Directory", self)
        log_dir_action.triggered.connect(self.show_log_dir)

        log_action = QtWidgets.QAction(
            self.style().standardIcon(
                QtWidgets.QStyle.SP_FileDialogDetailedView),
            "View GUI Debug &Logs", self)
        log_action.triggered.connect(self.show_logs)

        report_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_DialogHelpButton),
            "Report &Issue", self)
        report_action.triggered.connect(self.open_issues)

        version_action = QtWidgets.QAction(
            self.style().standardIcon(QtWidgets.QStyle.SP_BrowserReload),
            "Check for Newer Version of FastFlix", self)
        version_action.triggered.connect(
            lambda: latest_fastflix(no_new_dialog=True))

        help_menu = menubar.addMenu("&Help")
        help_menu.addAction(changes_action)
        help_menu.addAction(report_action)
        help_menu.addAction(log_dir_action)
        help_menu.addAction(log_action)
        help_menu.addSeparator()
        help_menu.addAction(version_action)
        help_menu.addSeparator()
        help_menu.addAction(about_action)

    def show_about(self):
        self.about = About()
        self.about.show()

    def show_setting(self):
        self.setting = Settings(self.config_file, self.main)
        self.setting.show()

    def show_logs(self):
        self.logs.show()

    def show_changes(self):
        self.changes.show()

    def open_issues(self):
        QtGui.QDesktopServices.openUrl(
            QtCore.QUrl("https://github.com/cdgriffith/FastFlix/issues"))

    def show_log_dir(self):
        OpenFolder(self, self.log_dir).run()
Пример #5
0
class Container(QtWidgets.QMainWindow):
    def __init__(self, app: FastFlixApp, **kwargs):
        super().__init__(None)
        self.app = app

        self.logs = Logs()
        self.changes = Changes()
        self.about = None
        self.profile_details = None

        self.init_menu()

        self.main = Main(self, app)
        self.profile = ProfileWindow(self.app, self.main)

        self.setCentralWidget(self.main)
        # self.setMinimumSize(QtCore.QSize(1000, 650))
        self.setFixedSize(QtCore.QSize(1200, 650))
        self.icon = QtGui.QIcon(main_icon)
        self.setWindowIcon(self.icon)

    def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        if self.main.converting:
            sm = QtWidgets.QMessageBox()
            sm.setText(f"<h2>{t('There is a conversion in process!')}</h2>")
            sm.addButton(t("Cancel Conversion"),
                         QtWidgets.QMessageBox.RejectRole)
            sm.addButton(t("Close GUI Only"),
                         QtWidgets.QMessageBox.DestructiveRole)
            sm.addButton(t("Keep FastFlix Open"),
                         QtWidgets.QMessageBox.AcceptRole)
            sm.exec_()
            if sm.clickedButton().text() == "Cancel Conversion":
                self.app.fastflix.worker_queue.put(["cancel"])
                time.sleep(0.5)
                self.main.close()
            elif sm.clickedButton().text() == "Close GUI Only":
                self.main.close(no_cleanup=True)
                return super(Container, self).closeEvent(a0)
            else:
                a0.ignore()
                return

        for item in self.app.fastflix.config.work_path.iterdir():
            if item.is_dir() and item.stem.startswith("temp_"):
                shutil.rmtree(item, ignore_errors=True)
            if item.name.lower().endswith((".jpg", ".jpeg", ".png", ".gif")):
                item.unlink()
        self.main.close(from_container=True)
        super(Container, self).closeEvent(a0)

    def si(self, widget):
        return self.style().standardIcon(widget)

    def init_menu(self):
        menubar = self.menuBar()

        file_menu = menubar.addMenu("&File")

        setting_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_FileDialogListView), t("Settings"),
            self)
        setting_action.setShortcut("Ctrl+S")
        setting_action.triggered.connect(self.show_setting)

        exit_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_DialogCancelButton), t("Exit"), self)
        exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))
        exit_action.setStatusTip(t("Exit application"))
        exit_action.triggered.connect(self.close)

        file_menu.addAction(setting_action)
        file_menu.addSeparator()
        file_menu.addAction(exit_action)

        profile_menu = menubar.addMenu(t("Profiles"))
        new_profile_action = QtWidgets.QAction(t("New Profile"), self)
        new_profile_action.triggered.connect(self.new_profile)

        show_profile_action = QtWidgets.QAction(t("Current Profile Settings"),
                                                self)
        show_profile_action.triggered.connect(self.show_profile)

        delete_profile_action = QtWidgets.QAction(t("Delete Current Profile"),
                                                  self)
        delete_profile_action.triggered.connect(self.delete_profile)
        profile_menu.addAction(new_profile_action)
        profile_menu.addAction(show_profile_action)
        profile_menu.addAction(delete_profile_action)

        about_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_FileDialogInfoView), t("About"), self)
        about_action.triggered.connect(self.show_about)

        changes_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_FileDialogDetailedView),
            t("View Changes"), self)
        changes_action.triggered.connect(self.show_changes)

        log_dir_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_DialogOpenButton),
            t("Open Log Directory"), self)
        log_dir_action.triggered.connect(self.show_log_dir)

        log_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_FileDialogDetailedView),
            t("View GUI Debug Logs"), self)
        log_action.triggered.connect(self.show_logs)

        report_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_DialogHelpButton), t("Report Issue"),
            self)
        report_action.triggered.connect(self.open_issues)

        version_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_BrowserReload),
            t("Check for Newer Version of FastFlix"), self)
        version_action.triggered.connect(
            lambda: latest_fastflix(no_new_dialog=True))

        ffmpeg_update_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_ArrowDown),
            t("Download Newest FFmpeg"), self)
        ffmpeg_update_action.triggered.connect(self.download_ffmpeg)

        clean_logs_action = QtWidgets.QAction(
            self.si(QtWidgets.QStyle.SP_DialogResetButton),
            t("Clean Old Logs"), self)
        clean_logs_action.triggered.connect(self.clean_old_logs)

        help_menu = menubar.addMenu(t("Help"))
        help_menu.addAction(changes_action)
        help_menu.addAction(report_action)
        help_menu.addAction(log_dir_action)
        help_menu.addAction(log_action)
        help_menu.addAction(clean_logs_action)
        help_menu.addSeparator()
        help_menu.addAction(version_action)
        if reusables.win_based:
            help_menu.addAction(ffmpeg_update_action)
        help_menu.addSeparator()
        help_menu.addAction(about_action)

    def show_about(self):
        self.about = About()
        self.about.show()

    def show_setting(self):
        self.setting = Settings(self.app, self.main)
        self.setting.show()

    def new_profile(self):
        self.profile.show()

    def show_profile(self):
        self.profile_details = ProfileDetails(
            self.app.fastflix.config.selected_profile,
            self.app.fastflix.config.profile)
        self.profile_details.show()

    def delete_profile(self):
        self.profile.delete_current_profile()

    def show_logs(self):
        self.logs.show()

    def show_changes(self):
        self.changes.show()

    def open_issues(self):
        QtGui.QDesktopServices.openUrl(
            QtCore.QUrl("https://github.com/cdgriffith/FastFlix/issues"))

    def show_log_dir(self):
        OpenFolder(self, str(self.app.fastflix.log_path)).run()

    def download_ffmpeg(self):
        ffmpeg_folder = Path(
            user_data_dir("FFmpeg", appauthor=False, roaming=True)) / "bin"
        ffmpeg = ffmpeg_folder / "ffmpeg.exe"
        ffprobe = ffmpeg_folder / "ffprobe.exe"
        try:
            ProgressBar(self.app,
                        [Task(t("Downloading FFmpeg"), latest_ffmpeg)],
                        signal_task=True,
                        can_cancel=True)
        except FastFlixInternalException:
            print("Caught")
            pass
        except Exception as err:
            message(f"{t('Could not download the newest FFmpeg')}: {err}")
        else:
            if not ffmpeg.exists() or not ffprobe.exists():
                message(
                    f"{t('Could not locate the downloaded files at')} {ffmpeg_folder}!"
                )
            else:
                self.app.fastflix.config.ffmpeg = ffmpeg
                self.app.fastflix.config.ffprobe = ffprobe

    def clean_old_logs(self):
        try:
            ProgressBar(self.app, [Task(t("Clean Old Logs"), clean_logs)],
                        signal_task=True,
                        can_cancel=False)
        except Exception:
            error_message(t("Could not compress old logs"), traceback=True)
Пример #6
0
class Container(QtWidgets.QMainWindow):
    def __init__(self, app: FastFlixApp, **kwargs):
        super().__init__(None)
        self.app = app
        self.pb = None

        self.logs = Logs()
        self.changes = Changes()
        self.about = None
        self.profile_details = None

        self.init_menu()

        self.main = Main(self, app)
        self.profile = ProfileWindow(self.app, self.main)

        self.setCentralWidget(self.main)
        self.setBaseSize(QtCore.QSize(1350, 750))
        self.icon = QtGui.QIcon(main_icon)
        self.setWindowIcon(self.icon)
        self.main.set_profile()

        if self.app.fastflix.config.theme == "onyx":
            self.setStyleSheet(
                """
                QAbstractItemView{ background-color: #707070; }
                QPushButton{ border-radius:10px; }
                QLineEdit{ background-color: #707070; color: black; border-radius: 10px; }
                QTextEdit{ background-color: #707070; color: black; }
                QTabBar::tab{ background-color: #4b5054; }
                QComboBox{ border-radius:10px; }
                QScrollArea{ border: 1px solid #919191; }
                """
            )
        # self.setWindowFlags(QtCore.Qt.WindowType.FramelessWindowHint)
        self.moveFlag = False

    # def mousePressEvent(self, event):
    #     if event.button() == QtCore.Qt.LeftButton:
    #         self.moveFlag = True
    #         self.movePosition = event.globalPos() - self.pos()
    #         self.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))
    #         event.accept()
    #
    # def mouseMoveEvent(self, event):
    #     if QtCore.Qt.LeftButton and self.moveFlag:
    #         self.move(event.globalPos() - self.movePosition)
    #         event.accept()
    #
    # def mouseReleaseEvent(self, event):
    #     self.moveFlag = False
    #     self.setCursor(QtCore.Qt.ArrowCursor)

    def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        if self.pb:
            try:
                self.pb.stop_signal.emit()
            except Exception:
                pass
        if self.app.fastflix.currently_encoding:
            sm = QtWidgets.QMessageBox()
            sm.setText(f"<h2>{t('There is a conversion in process!')}</h2>")
            sm.addButton(t("Cancel Conversion"), QtWidgets.QMessageBox.RejectRole)
            sm.addButton(t("Close GUI Only"), QtWidgets.QMessageBox.DestructiveRole)
            sm.addButton(t("Keep FastFlix Open"), QtWidgets.QMessageBox.AcceptRole)
            sm.exec_()
            if sm.clickedButton().text() == "Cancel Conversion":
                self.app.fastflix.worker_queue.put(["cancel"])
                time.sleep(0.5)
                self.main.close()
            elif sm.clickedButton().text() == "Close GUI Only":
                self.main.close(no_cleanup=True)
                return super(Container, self).closeEvent(a0)
            else:
                a0.ignore()
                return

        for item in self.app.fastflix.config.work_path.iterdir():
            if item.is_dir() and item.stem.startswith("temp_"):
                shutil.rmtree(item, ignore_errors=True)
            if item.name.lower().endswith((".jpg", ".jpeg", ".png", ".gif", ".tiff", ".tif")):
                item.unlink()
        shutil.rmtree(self.app.fastflix.config.work_path / "covers", ignore_errors=True)
        if reusables.win_based:
            cleanup_windows_notification()
        self.main.close(from_container=True)
        super(Container, self).closeEvent(a0)

    def si(self, widget):
        return self.style().standardIcon(widget)

    def init_menu(self):
        menubar = self.menuBar()
        menubar.setNativeMenuBar(False)
        menubar.setFixedWidth(260)

        file_menu = menubar.addMenu(t("File"))

        setting_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogListView), t("Settings"), self)
        setting_action.setShortcut("Ctrl+S")
        setting_action.triggered.connect(self.show_setting)

        exit_action = QAction(self.si(QtWidgets.QStyle.SP_DialogCancelButton), t("Exit"), self)
        exit_action.setShortcut(QtGui.QKeySequence("Ctrl+Q"))
        exit_action.setStatusTip(t("Exit application"))
        exit_action.triggered.connect(self.close)

        file_menu.addAction(setting_action)
        file_menu.addSeparator()
        file_menu.addAction(exit_action)

        profile_menu = menubar.addMenu(t("Profiles"))
        new_profile_action = QAction(t("New Profile"), self)
        new_profile_action.triggered.connect(self.new_profile)

        show_profile_action = QAction(t("Current Profile Settings"), self)
        show_profile_action.triggered.connect(self.show_profile)

        delete_profile_action = QAction(t("Delete Current Profile"), self)
        delete_profile_action.triggered.connect(self.delete_profile)
        profile_menu.addAction(new_profile_action)
        profile_menu.addAction(show_profile_action)
        profile_menu.addAction(delete_profile_action)

        tools_menu = menubar.addMenu(t("Tools"))
        concat_action = QAction(
            QtGui.QIcon(get_icon("onyx-queue", self.app.fastflix.config.theme)), t("Concatenation Builder"), self
        )
        concat_action.triggered.connect(self.show_concat)
        tools_menu.addAction(concat_action)

        wiki_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogInfoView), t("FastFlix Wiki"), self)
        wiki_action.triggered.connect(self.show_wiki)

        about_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogInfoView), t("About"), self)
        about_action.triggered.connect(self.show_about)

        changes_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogDetailedView), t("View Changes"), self)
        changes_action.triggered.connect(self.show_changes)

        log_dir_action = QAction(self.si(QtWidgets.QStyle.SP_DialogOpenButton), t("Open Log Directory"), self)
        log_dir_action.triggered.connect(self.show_log_dir)

        log_action = QAction(self.si(QtWidgets.QStyle.SP_FileDialogDetailedView), t("View GUI Debug Logs"), self)
        log_action.triggered.connect(self.show_logs)

        report_action = QAction(self.si(QtWidgets.QStyle.SP_DialogHelpButton), t("Report Issue"), self)
        report_action.triggered.connect(self.open_issues)

        version_action = QAction(
            self.si(QtWidgets.QStyle.SP_BrowserReload), t("Check for Newer Version of FastFlix"), self
        )
        version_action.triggered.connect(lambda: latest_fastflix(no_new_dialog=True))

        ffmpeg_update_action = QAction(self.si(QtWidgets.QStyle.SP_ArrowDown), t("Download Newest FFmpeg"), self)
        ffmpeg_update_action.triggered.connect(self.download_ffmpeg)

        clean_logs_action = QAction(self.si(QtWidgets.QStyle.SP_DialogResetButton), t("Clean Old Logs"), self)
        clean_logs_action.triggered.connect(self.clean_old_logs)

        help_menu = menubar.addMenu(t("Help"))
        help_menu.addAction(wiki_action)
        help_menu.addSeparator()
        help_menu.addAction(changes_action)
        help_menu.addAction(report_action)
        help_menu.addAction(log_dir_action)
        help_menu.addAction(log_action)
        help_menu.addAction(clean_logs_action)
        help_menu.addSeparator()
        help_menu.addAction(version_action)
        if reusables.win_based:
            help_menu.addAction(ffmpeg_update_action)
        help_menu.addSeparator()
        help_menu.addAction(about_action)

    def show_wiki(self):
        QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/cdgriffith/FastFlix/wiki"))

    def show_concat(self):
        self.concat = ConcatWindow(app=self.app, main=self.main)
        self.concat.show()

    def show_about(self):
        self.about = About(app=self.app)
        self.about.show()

    def show_setting(self):
        self.setting = Settings(self.app, self.main)
        self.setting.show()

    def new_profile(self):
        if not self.app.fastflix.current_video:
            error_message(t("Please load in a video to configure a new profile"))
        else:
            self.profile.show()

    def show_profile(self):
        self.profile_details = ProfileDetails(
            self.app.fastflix.config.selected_profile, self.app.fastflix.config.profile
        )
        self.profile_details.show()

    def delete_profile(self):
        self.profile.delete_current_profile()

    def show_logs(self):
        self.logs.show()

    def show_changes(self):
        self.changes.show()

    def open_issues(self):
        QtGui.QDesktopServices.openUrl(QtCore.QUrl("https://github.com/cdgriffith/FastFlix/issues"))

    def show_log_dir(self):
        OpenFolder(self, str(self.app.fastflix.log_path)).run()

    def download_ffmpeg(self):
        ffmpeg_folder = Path(user_data_dir("FFmpeg", appauthor=False, roaming=True)) / "bin"
        ffmpeg = ffmpeg_folder / "ffmpeg.exe"
        ffprobe = ffmpeg_folder / "ffprobe.exe"
        try:
            self.pb = ProgressBar(
                self.app, [Task(t("Downloading FFmpeg"), latest_ffmpeg)], signal_task=True, can_cancel=True
            )
        except FastFlixInternalException:
            pass
        except Exception as err:
            message(f"{t('Could not download the newest FFmpeg')}: {err}")
        else:
            if not ffmpeg.exists() or not ffprobe.exists():
                message(f"{t('Could not locate the downloaded files at')} {ffmpeg_folder}!")
            else:
                self.app.fastflix.config.ffmpeg = ffmpeg
                self.app.fastflix.config.ffprobe = ffprobe
        self.pb = None

    def clean_old_logs(self):
        try:
            self.pb = ProgressBar(self.app, [Task(t("Clean Old Logs"), clean_logs)], signal_task=True, can_cancel=False)
        except Exception:
            error_message(t("Could not compress old logs"), traceback=True)
        self.pb = None