Beispiel #1
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        #set events handlers
        self.cbosize.activated.connect(self.cbosize_changed)
        #self.spnsize.valueChanged(int).connect(self.spnsize_changed)

        #Init some variables

        #Populate compression-method
        compression_method = [_("Target File Size"), _("Constant Quality")]
        for method in compression_method:
            self.cbosize.addItem(method)

        self.hide_quality_values()
Beispiel #2
0
    def __init__(self):
        QMainWindow.__init__(self)

        # Руссифицируем QT диалоги
        log.info("Установка руссификации интерфейса QT")
        qt_base_translator = QTranslator(app)
        if qt_base_translator.load(":/i18n/qtbase_ru.qm"):
            app.installTranslator(qt_base_translator)
        else:
            log.error("Ошибка при установке руссификации интерфейса QT.")

        ui_util.load_ui(self, 'main_window')
        ui_util.init_ui(self)

        # Получить данные о текущей версии приложения через HTTP
        self.found_version_signal.connect(self.found_current_version)
        get_current_version()

        # Восстановить настройки расположения окна
        self.not_fullscreen_window_state = Qt.WindowNoState  # Переменная для хранения состояния до входа в полный экран
        self.restore_window_settings()

        self.setCorner(Qt.TopLeftCorner, Qt.LeftDockWidgetArea)
        self.setCorner(Qt.BottomLeftCorner, Qt.LeftDockWidgetArea)
        self.setCorner(Qt.TopRightCorner, Qt.RightDockWidgetArea)
        self.setCorner(Qt.BottomRightCorner, Qt.RightDockWidgetArea)

        # После инициализации приложения вызываем окно регистрации пользователя в системе
        app.app_loading_is_complete.connect(self.action_connect_db_trigger)
        app.user_is_registered.connect(self.when_user_is_registered)

        self.show()
Beispiel #3
0
    def __init__(self, node, edge=None):
        _ = get_app()._tr

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        self.node = node
        self.edge = edge
        self.Accept = False

        self.pushButtonOK.clicked.connect(self.onAccept)
        self.pushButtonCancel.clicked.connect(self.onCancel)
        self.lineEditText.setText(node["text"])

        project = get_app().project
        coder = project.get(["coder"])
        nodes = coder["nodes"]
        self.comboBoxToNode.addItem("select", "-1")
        for node in nodes:
            if node["nodeType"] != 1:
                self.comboBoxToNode.addItem(node["text"], node["id"])
        '''
Beispiel #4
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("animated-title-screen")

        # Add blender treeview
        self.blenderTreeView = BlenderListView(self)
        self.verticalLayout.addWidget(self.blenderTreeView)

        # Add render button
        app = get_app()
        _ = app._tr
        self.buttonBox.addButton(QPushButton(_('Render')), QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(QPushButton(_('Cancel')), QDialogButtonBox.RejectRole)

        # Init variables
        self.unique_folder_name = str(uuid.uuid1())
        self.output_dir = os.path.join(info.USER_PATH, "blender")
        self.selected_template = ""
        self.is_rendering = False
        self.my_blender = None

        # Clear all child controls
        self.clear_effect_controls()
Beispiel #5
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Init license
        #license_path = os.path.join(path_xdg, 'COPYING')
        #license_path = os.path.join(info.PATH, 'COPYING')
        #my_license = open('license_path', "r")
        #content = my_license.read()
        #for text in license_path:
            #self.textBrowser.append(text)
        #self.textBrowser.append(content)
        with open("(os.path.join(info.PATH, 'COPYING'))", 'r') as my_license:
            text = my_license.read()
            self.textBrowser.append(text)
Beispiel #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Load UI from designer & init
        ui_util.load_ui(self, self.ui_path)
        ui_util.init_ui(self)

        metrics.track_metric_screen("animated-title-screen")

        app = get_app()
        _ = app._tr

        # Add render controls
        self.btnRender = QPushButton(_('Render'))
        self.btnCancel = QPushButton(_('Cancel'))
        self.buttonBox.addButton(self.btnRender, QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(self.btnCancel, QDialogButtonBox.RejectRole)

        # Hide render progress until needed
        self.statusContainer.hide()

        # Add blender view
        self.blenderView = BlenderListView(self)
        self.verticalLayout.addWidget(self.blenderView)

        # Init variables
        self.unique_folder_name = str(uuid.uuid1())
        self.output_dir = os.path.join(info.USER_PATH, "blender")
        self.selected_template = ""
        self.is_rendering = False
        self.my_blender = None

        # Clear all child controls
        self.clear_effect_controls()
Beispiel #7
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("animated-title-screen")

        # Add blender treeview
        self.blenderTreeView = BlenderListView(self)
        self.verticalLayout.addWidget(self.blenderTreeView)

        # Add render button
        app = get_app()
        _ = app._tr
        self.buttonBox.addButton(QPushButton(_('Render')), QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(QPushButton(_('Cancel')), QDialogButtonBox.RejectRole)

        # Init variables
        self.unique_folder_name = str(uuid.uuid1())
        self.output_dir = os.path.join(info.USER_PATH, "blender")
        self.selected_template = ""
        self.is_rendering = False
        self.my_blender = None

        # Clear all child controls
        self.clear_effect_controls()
Beispiel #8
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Track metrics
        track_metric_screen("profile-screen")

        # Loop through profiles
        self.profile_names = []
        self.profile_paths = {}
        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
            for file in os.listdir(profile_folder):
                # Load Profile
                profile_path = os.path.join(profile_folder, file)
                profile = openshot.Profile(profile_path)

                # Add description of Profile to list
                self.profile_names.append(profile.info.description)
                self.profile_paths[profile.info.description] = profile_path

        # Sort list
        self.profile_names.sort()

        # Loop through sorted profiles
        box_index = 0
        selected_index = 0
        for profile_name in self.profile_names:

            # Add to dropdown
            self.cboProfile.addItem(profile_name,
                                    self.profile_paths[profile_name])

            # Set default (if it matches the project)
            if app.project.get(['profile']) == profile_name:
                selected_index = box_index

            # increment item counter
            box_index += 1

        # Connect signal
        self.cboProfile.currentIndexChanged.connect(
            functools.partial(self.dropdown_index_changed, self.cboProfile))

        # Set current item (from project)
        self.cboProfile.setCurrentIndex(selected_index)
Beispiel #9
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Track metrics
        track_metric_screen("profile-screen")

        # Loop through profiles
        self.profile_names = []
        self.profile_paths = {}
        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
            for file in os.listdir(profile_folder):
                # Load Profile
                profile_path = os.path.join(profile_folder, file)
                profile = openshot.Profile(profile_path)

                # Add description of Profile to list
                self.profile_names.append(profile.info.description)
                self.profile_paths[profile.info.description] = profile_path

        # Sort list
        self.profile_names.sort()

        # Loop through sorted profiles
        box_index = 0
        selected_index = 0
        for profile_name in self.profile_names:

            # Add to dropdown
            self.cboProfile.addItem(profile_name, self.profile_paths[profile_name])

            # Set default (if it matches the project)
            if app.project.get(['profile']) == profile_name:
                selected_index = box_index

            # increment item counter
            box_index += 1


        # Connect signal
        self.cboProfile.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, self.cboProfile))

        # Set current item (from project)
        self.cboProfile.setCurrentIndex(selected_index)
Beispiel #10
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)
Beispiel #11
0
    def __init__(self):
        QDialog.__init__(self, parent=app.main_window)
        ui_util.load_ui(self, 'login')
        ui_util.init_ui(self)

        login = app.settings.value("registration/login", '')
        if login:
            self.edt_login.setText(login)
            self.edt_password.setFocus()
	def __init__(self):
		
		#Create Dockwidget class
		QDockWidget.__init__(self)
		
		#Load UI from designer
		ui_util.load_ui(self, self.ui_path)
		
		#Init UI
		ui_util.init_ui(self)
Beispiel #13
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        #Init authors
        authors = []
        for person in info.CREDITS['code']:
            name = person['name']
            email = person['email']
            authors.append("%s <%s>" % (name, email))
        self.textBrowserwritten.append(str(authors))

        #Init documentaters
        authors = []
        for person in info.CREDITS['documentation']:
            name = person['name']
            email = person['email']
            authors.append("%s <%s>" % (name, email))
        self.textBrowserdocumented.append(str(authors))

        #Init artwork
        artists = []
        for person in info.CREDITS['artwork']:
            name = person['name']
            email = person['email']
            artists.append("%s <%s>" % (name, email))
        self.textBrowserartwork.append(str(artists))

        #Init translation authors
        authors = []
        for person in info.CREDITS['translation']:
            name = person['name']
            email = person['email']
            authors.append("%s <%s>" % (name, email))
        self.textBrowsertranslated.append(str(authors))

        #Init Kicstarter Backers
        #backers = []
        #for person in info.CREDITS['backers']
        #name = person['name']
        #email = person['email']
        #backers.append("%s <%s>" % (name, email))
        #self.textBrowserkickstarter.append(str(backers))
Beispiel #14
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Add credits listview
        self.developersListView = CreditsTreeView(credits=info.CREDITS['code'], columns=["email", "website"])
        self.vboxDevelopers.addWidget(self.developersListView)
        self.txtDeveloperFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtDeveloperFilter, self.developersListView))

        # Get string of translators for the current language
        translator_credits = []
        translator_credits_string = _("translator-credits").replace("Launchpad Contributions:\n", "").replace("translator-credits","")
        if translator_credits_string:
            # Parse string into a list of dictionaries
            translator_rows = translator_credits_string.split("\n")
            for row in translator_rows:
                # Split each row into 2 parts (name and username)
                translator_parts = row.split("https://launchpad.net/")
                name = translator_parts[0].strip()
                username = translator_parts[0].strip()
                translator_credits.append({"name":name, "website":"https://launchpad.net/%s" % username})

            # Add translators listview
            self.translatorsListView = CreditsTreeView(translator_credits, columns=["website"])
            self.vboxTranslators.addWidget(self.translatorsListView)
            self.txtTranslatorFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtTranslatorFilter, self.translatorsListView))
        else:
            # No translations for this langauge, hide credits
            self.tabCredits.removeTab(1)

        # Get list of supporters
        supporter_list = []
        import codecs
        with codecs.open(os.path.join(info.PATH, 'settings', 'supporters.json'), 'r', 'utf-8') as supporter_file:
            supporter_string = supporter_file.read()
            supporter_list = json.loads(supporter_string)

        # Add supporters listview
        self.supportersListView = CreditsTreeView(supporter_list, columns=["website"])
        self.vboxSupporters.addWidget(self.supportersListView)
        self.txtSupporterFilter.textChanged.connect(partial(self.Filter_Triggered, self.txtSupporterFilter, self.supportersListView))
Beispiel #15
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Track metrics
        track_metric_screen("animation-screen")
Beispiel #16
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Track metrics
        track_metric_screen("animation-screen")
Beispiel #17
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Track metrics
        track_metric_screen("preferences-screen")

        # Load all user values
        self.params = {}
        for item in self.settings_data:
            if "setting" in item and "value" in item:
                self.params[item["setting"]] = item

        # Connect search textbox
        self.txtSearch.textChanged.connect(self.txtSearch_changed)

        self.requires_restart = False
        self.category_names = {}
        self.category_tabs = {}
        self.category_sort = {}
        self.visible_category_names = {}

        # Tested hardware modes (default cpu mode with graphics card 0)
        self.hardware_tests_cards = {
            0: [
                0,
            ]
        }

        # Populate preferences
        self.Populate()

        # Restore normal cursor
        get_app().restoreOverrideCursor()
Beispiel #18
0
    def __init__(self):
        QDialog.__init__(self, parent=app.main_window)

        ui_util.load_ui(self, 'license')
        ui_util.init_ui(self)

        # Инициализация лицензии
        license_file = QFile(':/license.txt')
        license_file.open(QFile.ReadOnly)
        license_text = bytes(license_file.readAll()).decode('UTF-8')
        self.text_browser.setText(license_text)
        license_file.close()

        # Прокручиваем текст в начало документа
        cursor = self.text_browser.textCursor()
        cursor.setPosition(0)
        self.text_browser.setTextCursor(cursor)
Beispiel #19
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        ##set even handlers
        self.cmbpresets.activated.connect(self.load_presets_list)
        self.btnclearpreset.clicked.connect(self.delete_preset)
        self.btnsavecurrent.clicked.connect(self.save_current_preset)
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        create_text = _('Create &amp; Edit Amazing Videos and Movies')
        description_text = _(
            'OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.'
        )
        learnmore_text = _('Learn more')
        copyright_text = _(
            'Copyright &copy; %(begin_year)s-%(current_year)s') % {
                'begin_year': '2008',
                'current_year': str(datetime.datetime.today().year)
            }
        about_html = '<html><head/><body><hr/><p align="center"><span style=" font-size:10pt; font-weight:600;">%s</span></p><p align="center"><span style=" font-size:10pt;">%s </span><a href="http://%s.openshot.org?r=about-us"><span style=" font-size:10pt; text-decoration: none; color:#55aaff;">%s</span></a><span style=" font-size:10pt;">.</span></p></body></html>' % (
            create_text, description_text, info.website_language(),
            learnmore_text)
        company_html = '<html><head/><body style="font-size:11pt; font-weight:400; font-style:normal;">\n<hr />\n<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">%s </span><a href="http://%s.openshotstudios.com?r=about-us"><span style=" font-size:10pt; font-weight:600; text-decoration: none; color:#55aaff;">OpenShot Studios, LLC<br /></span></a></p></body></html>' % (
            copyright_text, info.website_language())

        # Set description and company labels
        self.lblAboutDescription.setText(about_html)
        self.lblAboutCompany.setText(company_html)

        # set events handlers
        self.btncredit.clicked.connect(self.load_credit)
        self.btnlicense.clicked.connect(self.load_license)

        # Init some variables
        self.txtversion.setText(_("Version: %s") % info.VERSION)
        self.txtversion.setAlignment(Qt.AlignCenter)

        # Track metrics
        track_metric_screen("about-screen")
    def __init__(self):

        #Create dialog class
        QDialog.__init__(self)

        #Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        #Init UI
        ui_util.init_ui(self)

        #get translations
        self.app = get_app()
        _ = self.app._tr

        #set events handlers
        self.btnAdd.clicked.connect(self.add_preset)
        self.btnModified.clicked.connect(self.modified_preset)
        self.btnRename.clicked.connect(self.rename_preset)
        self.btnCopy.clicked.connect(self.copy_preset)
        self.btnDelete.clicked.connect(self.delete_preset)
Beispiel #22
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        #set events handlers
        self.btncredit.clicked.connect(self.load_credit)
        self.btnlicense.clicked.connect(self.load_license)

        #Init some variables
        self.txtversion.setText(info.VERSION)
        self.txtversion.setAlignment(Qt.AlignCenter)
Beispiel #23
0
    def __init__(self):
        QDialog.__init__(self, parent=app.main_window)

        ui_util.load_ui(self, 'about')
        ui_util.init_ui(self)

        header_html = """
                <html><head/><body>
                    <p align="center" style="font-size: 4em; font-weight: bold;">
                        {app_name} (Версия: {version})
                    </p>
                    <p align="center" style="font-size: 2em;">
                        {description}
                    </p>
                </body></html>
            """.format(app_name=constants.APP_NAME_RUS, version=constants.VERSION, description=constants.DESCRIPTION)
        description_text = constants.DESCRIPTION
        description_html = """
            <html><head/><body>
                <hr />
                <p align="center" style="font-size: 2em;">
                    Почта для замечаний и предложений<br />
                    <a href="mailto:{email}"><span style="text-decoration: none; color:#55aaff;">{email}</span></a>
                </p>
            </body></html>""".format(description=description_text, email=constants.COMPANY_EMAIL)
        author_html = """
            <html><head/><body style="font-weight:400; font-style:normal;">
                <hr />
                <p align="center">
                    <span style="font-weight: bold;">%s</span>
                    <br />
                </p>
            </body></html>
        """ % constants.COPYRIGHT

        # Устанавливаем информацию о версии программы, авторе и описание
        self.lbl_about_description.setText(description_html)
        self.lbl_about_autor.setText(author_html)
        self.lbl_version.setText(header_html)
        self.lbl_version.setAlignment(Qt.AlignCenter)
Beispiel #24
0
	def __init__(self):
		
		#Create dialog class
		QDialog.__init__(self)
		
		#Load UI from designer
		ui_util.load_ui(self, self.ui_path)
		
		#Init UI
		ui_util.init_ui(self)
		
		#Get translations
		app = get_app()
		_ = app._tr
	
	
		#set events handlers
		self.btncrop.clicked.connect(self.load_crop)
		self.btnsqueze.clicked.connect(self.load_squeze)
		self.btnletterbox.clicked.connect(self.load_letter_box)
		self.btnnone.clicked.connect(self.close_dialog)
		self.btnnone.pressed.connect(self.reject)
	def __init__(self):

		# Create dialog class
		QDialog.__init__(self)

		#Load UI from designer
		ui_util.load_ui(self, self.ui_path)

		#Init UI
		ui_util.init_ui(self)

		#get translations
		self.app = get_app()
		_ = self.app._tr

		#set events handlers
		self.btnImport.clicked.connect(self.choose_transition)
		self.btnImport.pressed.connect(self.import_transition)

		#Init some variables
		self.buttonBox.button(QDialogButtonBox.Ok).setVisible(False)
		self.transition_file = ""
Beispiel #26
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Init license
        with open(os.path.join(info.RESOURCES_PATH, 'license.txt'), 'r') as my_license:
            text = my_license.read()
            self.textBrowser.append(text)

        # Scroll to top
        cursor = self.textBrowser.textCursor()
        cursor.setPosition(0)
        self.textBrowser.setTextCursor(cursor)
Beispiel #27
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Init license
        with open(os.path.join(info.PATH, 'settings', 'license.txt'), 'r') as my_license:
            text = my_license.read()
            self.textBrowser.append(text)

        # Scroll to top
        cursor = self.textBrowser.textCursor()
        cursor.setPosition(0)
        self.textBrowser.setTextCursor(cursor)
Beispiel #28
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # set events handlers
        self.btncredit.clicked.connect(self.load_credit)
        self.btnlicense.clicked.connect(self.load_license)

        # Init some variables
        self.txtversion.setText(_("Version: %s") % info.VERSION)
        self.txtversion.setAlignment(Qt.AlignCenter)

        # Track metrics
        track_metric_screen("about-screen")
Beispiel #29
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Update supporter button
        supporter_text = _("Become a Supporter")
        supporter_html = '<html><head/><body><p align="center"><a href="http://%s.openshot.org/donate/?app-about-us"><span style=" text-decoration: underline; color:#55aaff;">%s</span></a></p></body></html>' % (
            info.website_language(), supporter_text)
        self.lblBecomeSupporter.setText(supporter_html)

        # Add credits listview
        self.developersListView = CreditsTreeView(credits=info.CREDITS['code'],
                                                  columns=["email", "website"])
        self.vboxDevelopers.addWidget(self.developersListView)
        self.txtDeveloperFilter.textChanged.connect(
            partial(self.Filter_Triggered, self.txtDeveloperFilter,
                    self.developersListView))

        # Get string of translators for the current language
        translator_credits = []
        translator_credits_string = _("translator-credits").replace(
            "Launchpad Contributions:\n", "").replace("translator-credits", "")
        if translator_credits_string:
            # Parse string into a list of dictionaries
            translator_rows = translator_credits_string.split("\n")
            for row in translator_rows:
                # Split each row into 2 parts (name and username)
                translator_parts = row.split("https://launchpad.net/")
                name = translator_parts[0].strip()
                username = translator_parts[1].strip()
                translator_credits.append({
                    "name":
                    name,
                    "website":
                    "https://launchpad.net/%s" % username
                })

            # Add translators listview
            self.translatorsListView = CreditsTreeView(translator_credits,
                                                       columns=["website"])
            self.vboxTranslators.addWidget(self.translatorsListView)
            self.txtTranslatorFilter.textChanged.connect(
                partial(self.Filter_Triggered, self.txtTranslatorFilter,
                        self.translatorsListView))
        else:
            # No translations for this langauge, hide credits
            self.tabCredits.removeTab(1)

        # Get list of supporters
        supporter_list = []
        import codecs
        with codecs.open(
                os.path.join(info.PATH, 'settings', 'supporters.json'), 'r',
                'utf-8') as supporter_file:
            supporter_string = supporter_file.read()
            supporter_list = json.loads(supporter_string)

        # Add supporters listview
        self.supportersListView = CreditsTreeView(supporter_list,
                                                  columns=["website"])
        self.vboxSupporters.addWidget(self.supportersListView)
        self.txtSupporterFilter.textChanged.connect(
            partial(self.Filter_Triggered, self.txtSupporterFilter,
                    self.supportersListView))
Beispiel #30
0
    def __init__(self, file=None):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("cutting-screen")

        self.start_frame = 1
        self.start_image = None
        self.end_frame = 1
        self.end_image = None

        # Keep track of file object
        self.file = file
        self.file_path = file.absolute_path()
        self.video_length = int(file.data['video_length'])
        self.fps_num = int(file.data['fps']['num'])
        self.fps_den = int(file.data['fps']['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)

        # Open video file with Reader
        log.info(self.file_path)
        self.r = openshot.FFmpegReader(self.file_path)
        self.r.Open()

        # Add Video Widget
        self.videoPreview = VideoWidget()
        self.videoPreview.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        self.verticalLayout.insertWidget(0, self.videoPreview)

        # Start the preview thread
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.r, self.videoPreview)
        self.preview_thread = self.preview_parent.worker

        # Set slider constraints
        self.sliderIgnoreSignal = False
        self.sliderVideo.setMinimum(1)
        self.sliderVideo.setMaximum(self.video_length)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setPageStep(24)

        # Determine if a start or end attribute is in this file
        start_frame = 1
        if 'start' in self.file.data.keys():
            start_frame = (float(self.file.data['start']) * self.fps) + 1

        # Display start frame (and then the previous frame)
        QTimer.singleShot(500, functools.partial(self.sliderVideo.setValue, start_frame + 1))
        QTimer.singleShot(600, functools.partial(self.sliderVideo.setValue, start_frame))

        # Connect signals
        self.btnPlay.clicked.connect(self.btnPlay_clicked)
        self.sliderVideo.valueChanged.connect(self.sliderVideo_valueChanged)
        self.btnStart.clicked.connect(self.btnStart_clicked)
        self.btnEnd.clicked.connect(self.btnEnd_clicked)
        self.btnClear.clicked.connect(self.btnClear_clicked)
        self.btnAddClip.clicked.connect(self.btnAddClip_clicked)
Beispiel #31
0
	def __init__(self):
		
		#Create dialog class
		QDialog.__init__(self)
		
		#Load UI from designer
		ui_util.load_ui(self, self.ui_path)
		
		#Init UI
		ui_util.init_ui(self)

		#get translations
		app = get_app()
		_ = app._tr
		
		# Get settings
		self.s = settings.get_settings()
		
		# Dynamically load tabs from settings data
		self.settings_data = settings.get_settings().get_all_settings()
		
		# Load all user values
		self.params = {}
		for item in self.settings_data:
			if "setting" in item and "value" in item:
				self.params[item["setting"]] = item
		
		self.category_names = {}
		self.category_tabs = {}
		# Loop through settings and find all unique categories
		for item in self.settings_data:
			category = item["category"]
			setting_type = item["type"]
			
			if not setting_type == "hidden":
				# Load setting
				if not category in self.category_names:
					self.category_names[category] = []
					
					# Add new category as a tab
					tabWidget = QWidget(self)
					self.tabCategories.addTab(tabWidget, _(category))
					self.category_tabs[category] = tabWidget
					
					# Add form layout to this tab
					layout = QFormLayout(tabWidget)
				
				# Append settings into correct category
				self.category_names[category].append(item)
				
		# Loop through each category setting, and add them to the tabs
		for category in self.category_tabs.keys():
			tabWidget = self.category_tabs[category]

			# Loop through settings for each category
			for param in self.category_names[category]:
				
				# Create Label
				widget = None
				label = QLabel()
				label.setText(_(param["title"]))
				label.setToolTip(_(param["title"]))
	
				if param["type"] == "spinner":
					# create spinner
					widget = QDoubleSpinBox()
					widget.setMinimum(float(param["min"]))
					widget.setMaximum(float(param["max"]))
					widget.setValue(float(param["value"]))
					widget.setSingleStep(1.0)
					widget.setToolTip(param["title"])
					widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))
					
				elif param["type"] == "text":
					# create spinner
					widget = QLineEdit()
					widget.setText(_(param["value"]))
					widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))
					
				elif param["type"] == "bool":
					# create spinner
					widget = QCheckBox()
					if param["value"] == True:
						widget.setCheckState(Qt.Checked)
					else:
						widget.setCheckState(Qt.Unchecked)
					widget.stateChanged.connect(functools.partial(self.bool_value_changed, widget, param))
					
				elif param["type"] == "dropdown":
	
					# create spinner
					widget = QComboBox()

					# Add normal values
					box_index = 0
					for value_item in param["values"]:
						k = value_item["name"]
						v = value_item["value"]
						# add dropdown item
						widget.addItem(_(k), v)
						
						# select dropdown (if default)
						if v == param["value"]:
							widget.setCurrentIndex(box_index)
						box_index = box_index + 1
						
					widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param))


				# Add Label and Widget to the form
				if (widget and label):
					tabWidget.layout().addRow(label, widget)
				elif (label):
					tabWidget.layout().addRow(label)
Beispiel #32
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        #Init UI
        ui_util.init_ui(self)

        #get translations
        self.app = get_app()
        _ = self.app._tr

        self.preset_name = ""
        self.project = self.app.project

        #set events handlers
        self.btnfolder.clicked.connect(self.choose_folder_output)
        self.btndeletepreset.clicked.connect(self.delete_preset)
        self.btnapplypreset.clicked.connect(self.apply_preset)
        self.cbopreset.activated.connect(self.load_preset)
        self.chkentiresequence.stateChanged.connect(self.lenght_group_state)
        self.chkprojectprofilesettings.stateChanged.connect(self.direction_group)
        self.cbosqueze.activated.connect(self.load_squeze)
        self.cmbformatvideo.activated.connect(self.load_format_video)
        self.cmbvideo.activated.connect(self.video_codecs)
        self.cmbcompressionmethod.activated.connect(self.load_compression_method_activated)
        self.btnpreserveratio.clicked.connect(self.preserve_ratio)
        self.spbrate.valueChanged.connect(self.rate_changed)
        self.spbmax.valueChanged.connect(self.max_changed)
        self.cmbaudio.activated.connect(self.audio_codecs)
        self.cmbsimplerate.activated.connect(self.simple_rate_changed)
        self.cmbchannels.activated.connect(self.channels_selected)
        self.sliderbitrate.valueChanged.connect(self.bitrate_changed)
        self.cmbformatimage.activated.connect(self.format_image)
        self.sliderquality.valueChanged.connect(self.quality_changed)
        self.spbdigits.valueChanged.connect(self.digits_changed)
        self.spbinterval.valueChanged.connect(self.interval_changed)
        self.spboffset.valueChanged.connect(self.offset_changed)
        self.lblprefix.textChanged.connect(self.new_prefix)
        self.lblsuffix.textChanged.connect(self.new_suffix)
        self.btnloadffmpegcommand.clicked.connect(self.load_ffmpeg_command)
        self.btnexportcommand.clicked.connect(self.load_export_command)
        self.btnexport.clicked.connect(self.run_progress_bar_export)
        #self.lblframename.textChanged.connect(self.new_frame_name)


        #Init some variables
        self.chkentiresequence.setEnabled(True)
        #self.chkentiresequence.setChecked()
        self.label_17.setEnabled(False)
        self.spbfrom.setEnabled(False)
        self.label_18.setEnabled(False)
        self.spbto.setEnabled(False)
        self.chkprojectprofilesettings.setEnabled(True)
        #self.chkprojectprofilesettings.isChecked(True)
        self.chkoriginalsize.setEnabled(False)
        self.label_20.setEnabled(False)
        self.spbwidth.setEnabled(False)
        self.label_21.setEnabled(False)
        self.btnpreserveratio.setEnabled(False)
        self.spbheight.setEnabled(False)
        self.chkdirectcopy.setEnabled(True)
        self.lblfilename.setText("My Awesome Movie")
        self.lblfilename.setFocus()
        self.lblfilename.selectAll()


        #Populate new preset name
        self.cbopreset.addItem("<Select a Preset or Create your own>")
        self.preset_path = os.path.join(info.PATH, 'presets')
        for file in sorted(os.listdir(self.preset_path)):
            if fnmatch.fnmatch(file, '*.xml'):
                (fileName, fileExtension) = os.path.splitext(file)
            self.cbopreset.addItem(file.replace("_", " "))

        #populate compression method

        compression_method = [_("Average Bit Rate")]
        for method in compression_method:
            self.cmbcompressionmethod.addItem(method)

        # populate image format Qcombobox
        image_extension = [_(".jpg"), _(".jpeg"), _(".png"), _(".bmp"), _(".svg"), _(".thm"), _(".gif"), _(".ppm"),
                           _(".pgm"),
                           _(".tif"), _(".tiff")]
        for extension in image_extension:
            self.cmbformatimage.addItem(extension)

        #populate format combo
        format_video = [_('.mkv'), _('.mov'), _('.mp4'), _('.dnxhd'), _('.dvd'), _('vob'), _('.mpg'), _('mpegts'), _('mpegps'),
                        _('.dv'), _('.avi'), _('.webm'), _('.ts'), _('.ogg'), _('.3gp2'), _('.3gp'), _('.roq'), _('rm'),
                        _('.divx'), _('.xvid'), _('.m2ts'), _('.r3d'), _('.MPG'), _('.flv'), _('avm2'), _('.asf'), _('.m4v'),
                        _('.h264'), _('.ac3'), _('.mp2'), _('.mp3'), _('.wav'), _('.ogg'), _('.flac'), _('.aac'), _('.wma'),
                        _('.opus'), _('.alaw'), _('.mulaw'), _('.mka')]

        for keys in format_video:
            self.cmbformatvideo.addItem(keys)

        for extension in format_video:
            self.cmbextension.addItem(extension)

        #populate video codecs combo
        video_codec = {'Xvid': 'libxvid', 'H264/MPEG-4 AVC':'libx264', 'OGG VORBIS': 'ogg', 'DV': 'dv', 'VP8': 'libvpx', 'Motion JPEG': 'mjepg',
                       'VP9': 'libvpx', 'H261': 'h261', 'H263': '263', 'Theora': '', 'Dirac': 'dirac', 'WMV': 'wmv', 'FLV': 'flv'}
        for keys in video_codec:
            self.cmbvideo.addItem(keys)

        aspect_ratio = [_('4/3'), _('16/9')]
        for ratio in aspect_ratio:
            self.cmbaspectratio.addItem(ratio)

        frame_per_seconds = [_('23.976'), _('24'), _('25'), _('29.976'), _('30'), _('50'), _('60')]
        for fps in frame_per_seconds:
            self.cmbfps.addItem(fps)

        #populate audio codecs combo
        audio_codec = {'MP3': 'libmp3lame', 'OGG VORBIS': 'oggvorbis','MP2': 'mpeg2audio', 'FLAC': 'flac',
                       'AAC-LC': 'aac', 'WAVE': 'wav', 'AC3': 'ac3', 'DTS': 'dts', 'WMA': 'wma', 'AMR-NB': '',
                       'PCM 8 bits': 'u8', 'PCM 16 bits little-endian': 'u16le', 'PCM 16 bits big-endian': 'u16be'}
        for keys in audio_codec:
            self.cmbaudio.addItem(keys)

        #Populate simplerate combo
        simple_rate = [_('Copy'), _('8000'), _('11025'), _('16000'), _('22050'), _('24000'), _('32000'), _('44100'),
                       _('48000')]
        for rate in simple_rate:
            self.cmbsimplerate.addItem(rate)

        #populate audio channels
        audio_channels = [_('Copy'), _('Mono'), _('Stereo'), _('Join Stereo'), _('DTS')]
        for channels in audio_channels:
            self.cmbchannels.addItem(channels)
Beispiel #33
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        self.app = get_app()
        self.project = self.app.project

        # Get translation object
        _ = self.app._tr

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("title-screen")

        # Initialize variables
        self.template_name = ""
        imp = minidom.getDOMImplementation()
        self.xmldoc = imp.createDocument(None, "any", None)

        self.bg_color_code = ""
        self.font_color_code = "#ffffff"

        self.bg_style_string = ""
        self.title_style_string = ""
        self.subtitle_style_string = ""

        self.font_weight = 'normal'
        self.font_style = 'normal'

        self.new_title_text = ""
        self.sub_title_text = ""
        self.subTitle = False

        self.display_name = ""
        self.font_family = "Bitstream Vera Sans"
        self.tspan_node = None

        # Hide all textboxes
        self.hide_textboxes()

        # Remove temp file (if found)
        temp_svg_path = os.path.join(info.TITLE_PATH, "temp.svg")
        if os.path.exists(temp_svg_path):
            os.remove(temp_svg_path)

        # load the template files
        self.cmbTemplate.addItem(_("<Select a template>"))

        # Add user-defined titles (if any)
        for file in sorted(os.listdir(info.TITLE_PATH)):
            # pretty up the filename for display purposes
            if fnmatch.fnmatch(file, '*.svg'):
                (fileName, fileExtension) = os.path.splitext(file)
            self.cmbTemplate.addItem(fileName.replace("_", " "), os.path.join(info.TITLE_PATH, file))

        # Add built-in titles
        self.template_dir = os.path.join(info.PATH, 'titles')
        for file in sorted(os.listdir(self.template_dir)):
            # pretty up the filename for display purposes
            if fnmatch.fnmatch(file, '*.svg'):
                (fileName, fileExtension) = os.path.splitext(file)
            self.cmbTemplate.addItem(fileName.replace("_", " "), os.path.join(self.template_dir, file))

        # set event handlers
        self.cmbTemplate.activated.connect(functools.partial(self.cmbTemplate_activated))
        self.btnFontColor.clicked.connect(functools.partial(self.btnFontColor_clicked))
        self.btnBackgroundColor.clicked.connect(functools.partial(self.btnBackgroundColor_clicked))
        self.btnFont.clicked.connect(functools.partial(self.btnFont_clicked))
        self.btnAdvanced.clicked.connect(functools.partial(self.btnAdvanced_clicked))
        self.txtLine1.textChanged.connect(functools.partial(self.txtLine_changed))
        self.txtLine2.textChanged.connect(functools.partial(self.txtLine_changed))
        self.txtLine3.textChanged.connect(functools.partial(self.txtLine_changed))
        self.txtLine4.textChanged.connect(functools.partial(self.txtLine_changed))
        self.txtLine5.textChanged.connect(functools.partial(self.txtLine_changed))
        self.txtLine6.textChanged.connect(functools.partial(self.txtLine_changed))
Beispiel #34
0
    def __init__(self, edit_file_path=None, duplicate=False):

        # Create dialog class
        QDialog.__init__(self)

        self.app = get_app()
        self.project = self.app.project
        self.edit_file_path = edit_file_path
        self.duplicate = duplicate

        # Get translation object
        _ = self.app._tr

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("title-screen")

        # Initialize variables
        self.template_name = ""
        imp = minidom.getDOMImplementation()
        self.xmldoc = imp.createDocument(None, "any", None)

        self.bg_color_code = QtGui.QColor(Qt.black)
        self.font_color_code = QtGui.QColor(Qt.white)

        self.bg_style_string = ""
        self.title_style_string = ""
        self.subtitle_style_string = ""

        self.font_weight = 'normal'
        self.font_style = 'normal'

        self.new_title_text = ""
        self.sub_title_text = ""
        self.subTitle = False

        self.display_name = ""
        self.font_family = "Bitstream Vera Sans"
        self.tspan_node = None

        # Add titles list view
        self.titlesTreeView = TitlesListView(self)
        self.verticalLayout.addWidget(self.titlesTreeView)

        # Disable Save button on window load
        self.buttonBox.button(self.buttonBox.Save).setEnabled(False)

        # If editing existing title svg file
        if self.edit_file_path:
            # Hide list of templates
            self.widget.setVisible(False)

            # Create temp version of title
            self.create_temp_title(self.edit_file_path)

            # Add all widgets for editing
            self.load_svg_template()

            # Display image (slight delay to allow screen to be shown first)
            QTimer.singleShot(50, self.display_svg)
Beispiel #35
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Track metrics
        track_metric_screen("preferences-screen")

        # Load all user values
        self.params = {}
        for item in self.settings_data:
            if "setting" in item and "value" in item:
                self.params[item["setting"]] = item

        self.requires_restart = False
        self.category_names = {}
        self.category_tabs = {}
        # Loop through settings and find all unique categories
        for item in self.settings_data:
            category = item["category"]
            setting_type = item["type"]

            if not setting_type == "hidden":
                # Load setting
                if not category in self.category_names:
                    self.category_names[category] = []

                    # Add new category as a tab
                    tabWidget = QWidget(self)
                    self.tabCategories.addTab(tabWidget, _(category))
                    self.category_tabs[category] = tabWidget

                    # Add form layout to this tab
                    layout = QFormLayout(tabWidget)

                # Append settings into correct category
                self.category_names[category].append(item)

        # Loop through each category setting, and add them to the tabs
        for category in self.category_tabs.keys():
            tabWidget = self.category_tabs[category]

            # Loop through settings for each category
            for param in self.category_names[category]:

                # Create Label
                widget = None
                label = QLabel()
                label.setText(_(param["title"]))
                label.setToolTip(_(param["title"]))

                if param["type"] == "spinner":
                    # create QDoubleSpinBox
                    widget = QDoubleSpinBox()
                    widget.setMinimum(float(param["min"]))
                    widget.setMaximum(float(param["max"]))
                    widget.setValue(float(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(
                        functools.partial(self.spinner_value_changed, param))

                if param["type"] == "spinner-int":
                    # create QDoubleSpinBox
                    widget = QSpinBox()
                    widget.setMinimum(int(param["min"]))
                    widget.setMaximum(int(param["max"]))
                    widget.setValue(int(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(
                        functools.partial(self.spinner_value_changed, param))

                elif param["type"] == "text":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(
                        functools.partial(self.text_value_changed, widget,
                                          param))

                elif param["type"] == "bool":
                    # create spinner
                    widget = QCheckBox()
                    if param["value"] == True:
                        widget.setCheckState(Qt.Checked)
                    else:
                        widget.setCheckState(Qt.Unchecked)
                    widget.stateChanged.connect(
                        functools.partial(self.bool_value_changed, widget,
                                          param))

                elif param["type"] == "dropdown":

                    # create spinner
                    widget = QComboBox()

                    # Get values
                    value_list = param["values"]
                    # Overwrite value list (for profile dropdown)
                    if param["setting"] == "default-profile":
                        value_list = []
                        # Loop through profiles
                        for profile_folder in [
                                info.USER_PROFILES_PATH, info.PROFILES_PATH
                        ]:
                            for file in os.listdir(profile_folder):
                                # Load Profile and append description
                                profile_path = os.path.join(
                                    profile_folder, file)
                                profile = openshot.Profile(profile_path)
                                value_list.append({
                                    "name":
                                    profile.info.description,
                                    "value":
                                    profile.info.description
                                })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))

                    # Overwrite value list (for language dropdown)
                    if param["setting"] == "default-language":
                        value_list = []
                        # Loop through languages
                        for locale, language, country in get_all_languages():
                            # Load Profile and append description
                            if language:
                                lang_name = "%s (%s)" % (language, locale)
                                value_list.append({
                                    "name": lang_name,
                                    "value": locale
                                })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))
                        # Add Default to top of list
                        value_list.insert(0, {
                            "name": _("Default"),
                            "value": "Default"
                        })

                    # Add normal values
                    box_index = 0
                    for value_item in value_list:
                        k = value_item["name"]
                        v = value_item["value"]
                        # add dropdown item
                        widget.addItem(_(k), v)

                        # select dropdown (if default)
                        if v == param["value"]:
                            widget.setCurrentIndex(box_index)
                        box_index = box_index + 1

                    widget.currentIndexChanged.connect(
                        functools.partial(self.dropdown_index_changed, widget,
                                          param))

                # Add Label and Widget to the form
                if (widget and label):
                    tabWidget.layout().addRow(label, widget)
                elif (label):
                    tabWidget.layout().addRow(label)
Beispiel #36
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Track metrics
        track_metric_screen("preferences-screen")

        # Load all user values
        self.params = {}
        for item in self.settings_data:
            if "setting" in item and "value" in item:
                self.params[item["setting"]] = item

        self.requires_restart = False
        self.category_names = {}
        self.category_tabs = {}
        self.category_sort = {}

        # Loop through settings and find all unique categories
        for item in self.settings_data:
            category = item.get("category")
            setting_type = item.get("type")
            sort_category = item.get("sort")

            # Indicate sorted category
            if sort_category:
                self.category_sort[category] = sort_category

            if not setting_type == "hidden":
                # Load setting
                if not category in self.category_names:
                    self.category_names[category] = []

                    # Create scrollarea
                    scroll_area = QScrollArea(self)
                    scroll_area.setWidgetResizable(True)
                    scroll_area.setVerticalScrollBarPolicy(
                        Qt.ScrollBarAsNeeded)
                    scroll_area.setSizePolicy(QSizePolicy.Expanding,
                                              QSizePolicy.Expanding)

                    # Create tab widget and layout
                    layout = QVBoxLayout()
                    tabWidget = QWidget(self)
                    tabWidget.setSizePolicy(QSizePolicy.Preferred,
                                            QSizePolicy.Preferred)
                    tabWidget.setLayout(layout)
                    scroll_area.setWidget(tabWidget)

                    # Add tab
                    self.tabCategories.addTab(scroll_area, _(category))
                    self.category_tabs[category] = tabWidget

                # Append translated title
                item["title_tr"] = _(item.get("title"))

                # Append settings into correct category
                self.category_names[category].append(item)

        # Loop through each category setting, and add them to the tabs
        for category in self.category_tabs.keys():
            tabWidget = self.category_tabs[category]

            # Get list of items in category
            params = self.category_names[category]
            if self.category_sort.get(category):
                # Sort this category by translated title
                params.sort(key=operator.itemgetter("title_tr"))

            # Loop through settings for each category
            for param in params:

                # Create Label
                widget = None
                extraWidget = None
                label = QLabel()
                label.setText(_(param["title"]))
                label.setToolTip(_(param["title"]))

                if param["type"] == "spinner":
                    # create QDoubleSpinBox
                    widget = QDoubleSpinBox()
                    widget.setMinimum(float(param["min"]))
                    widget.setMaximum(float(param["max"]))
                    widget.setValue(float(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(
                        functools.partial(self.spinner_value_changed, param))

                if param["type"] == "spinner-int":
                    # create QDoubleSpinBox
                    widget = QSpinBox()
                    widget.setMinimum(int(param["min"]))
                    widget.setMaximum(int(param["max"]))
                    widget.setValue(int(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(
                        functools.partial(self.spinner_value_changed, param))

                elif param["type"] == "text":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(
                        functools.partial(self.text_value_changed, widget,
                                          param))

                elif param["type"] == "browse":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(
                        functools.partial(self.text_value_changed, widget,
                                          param))
                    extraWidget = QPushButton(_("Browse..."))
                    extraWidget.clicked.connect(
                        functools.partial(self.selectExecutable, widget,
                                          param))

                elif param["type"] == "bool":
                    # create spinner
                    widget = QCheckBox()
                    if param["value"] == True:
                        widget.setCheckState(Qt.Checked)
                    else:
                        widget.setCheckState(Qt.Unchecked)
                    widget.stateChanged.connect(
                        functools.partial(self.bool_value_changed, widget,
                                          param))

                elif param["type"] == "dropdown":

                    # create spinner
                    widget = QComboBox()

                    # Get values
                    value_list = param["values"]
                    # Overwrite value list (for profile dropdown)
                    if param["setting"] == "default-profile":
                        value_list = []
                        # Loop through profiles
                        for profile_folder in [
                                info.USER_PROFILES_PATH, info.PROFILES_PATH
                        ]:
                            for file in os.listdir(profile_folder):
                                # Load Profile and append description
                                profile_path = os.path.join(
                                    profile_folder, file)
                                profile = openshot.Profile(profile_path)
                                value_list.append({
                                    "name":
                                    profile.info.description,
                                    "value":
                                    profile.info.description
                                })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))

                    # Overwrite value list (for language dropdown)
                    if param["setting"] == "default-language":
                        value_list = []
                        # Loop through languages
                        for locale, language, country in get_all_languages():
                            # Load Profile and append description
                            if language:
                                lang_name = "%s (%s)" % (language, locale)
                                value_list.append({
                                    "name": lang_name,
                                    "value": locale
                                })
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))
                        # Add Default to top of list
                        value_list.insert(0, {
                            "name": _("Default"),
                            "value": "Default"
                        })

                    # Add normal values
                    box_index = 0
                    for value_item in value_list:
                        k = value_item["name"]
                        v = value_item["value"]
                        # add dropdown item
                        widget.addItem(_(k), v)

                        # select dropdown (if default)
                        if v == param["value"]:
                            widget.setCurrentIndex(box_index)
                        box_index = box_index + 1

                    widget.currentIndexChanged.connect(
                        functools.partial(self.dropdown_index_changed, widget,
                                          param))

                # Add Label and Widget to the form
                if (widget and label):
                    # Add minimum size
                    label.setMinimumWidth(180)
                    label.setSizePolicy(QSizePolicy.Preferred,
                                        QSizePolicy.Preferred)
                    widget.setSizePolicy(QSizePolicy.Expanding,
                                         QSizePolicy.Preferred)

                    # Create HBox layout
                    layout_hbox = QHBoxLayout()
                    layout_hbox.addWidget(label)
                    layout_hbox.addWidget(widget)

                    if (extraWidget):
                        layout_hbox.addWidget(extraWidget)

                    # Add widget to layout
                    tabWidget.layout().addLayout(layout_hbox)
                elif (label):
                    # Add widget to layout
                    tabWidget.layout().addWidget(label)

            # Add stretch to bottom of layout
            tabWidget.layout().addStretch()
Beispiel #37
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Track metrics
        track_metric_screen("preferences-screen")

        # Load all user values
        self.params = {}
        for item in self.settings_data:
            if "setting" in item and "value" in item:
                self.params[item["setting"]] = item

        self.requires_restart = False
        self.category_names = {}
        self.category_tabs = {}
        # Loop through settings and find all unique categories
        for item in self.settings_data:
            category = item["category"]
            setting_type = item["type"]

            if not setting_type == "hidden":
                # Load setting
                if not category in self.category_names:
                    self.category_names[category] = []

                    # Add new category as a tab
                    tabWidget = QWidget(self)
                    self.tabCategories.addTab(tabWidget, _(category))
                    self.category_tabs[category] = tabWidget

                    # Add form layout to this tab
                    layout = QFormLayout(tabWidget)

                # Append settings into correct category
                self.category_names[category].append(item)

        # Loop through each category setting, and add them to the tabs
        for category in self.category_tabs.keys():
            tabWidget = self.category_tabs[category]

            # Loop through settings for each category
            for param in self.category_names[category]:

                # Create Label
                widget = None
                label = QLabel()
                label.setText(_(param["title"]))
                label.setToolTip(_(param["title"]))

                if param["type"] == "spinner":
                    # create QDoubleSpinBox
                    widget = QDoubleSpinBox()
                    widget.setMinimum(float(param["min"]))
                    widget.setMaximum(float(param["max"]))
                    widget.setValue(float(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                if param["type"] == "spinner-int":
                    # create QDoubleSpinBox
                    widget = QSpinBox()
                    widget.setMinimum(int(param["min"]))
                    widget.setMaximum(int(param["max"]))
                    widget.setValue(int(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                elif param["type"] == "text":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))

                elif param["type"] == "bool":
                    # create spinner
                    widget = QCheckBox()
                    if param["value"] == True:
                        widget.setCheckState(Qt.Checked)
                    else:
                        widget.setCheckState(Qt.Unchecked)
                    widget.stateChanged.connect(functools.partial(self.bool_value_changed, widget, param))

                elif param["type"] == "dropdown":

                    # create spinner
                    widget = QComboBox()

                    # Get values
                    value_list = param["values"]
                    # Overwrite value list (for profile dropdown)
                    if param["setting"] == "default-profile":
                        value_list = []
                        # Loop through profiles
                        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
                            for file in os.listdir(profile_folder):
                                # Load Profile and append description
                                profile_path = os.path.join(profile_folder, file)
                                profile = openshot.Profile(profile_path)
                                value_list.append({"name":profile.info.description, "value":profile.info.description})
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))

                    # Overwrite value list (for language dropdown)
                    if param["setting"] == "default-language":
                        value_list = []
                        # Loop through languages
                        for locale, language, country in get_all_languages():
                            # Load Profile and append description
                            if language:
                                lang_name = "%s (%s)" % (language, locale)
                                value_list.append({"name":lang_name, "value":locale})
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))
                        # Add Default to top of list
                        value_list.insert(0, {"name":_("Default"), "value":"Default"})


                    # Add normal values
                    box_index = 0
                    for value_item in value_list:
                        k = value_item["name"]
                        v = value_item["value"]
                        # add dropdown item
                        widget.addItem(_(k), v)

                        # select dropdown (if default)
                        if v == param["value"]:
                            widget.setCurrentIndex(box_index)
                        box_index = box_index + 1

                    widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param))


                # Add Label and Widget to the form
                if (widget and label):
                    tabWidget.layout().addRow(label, widget)
                elif (label):
                    tabWidget.layout().addRow(label)
Beispiel #38
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        _ = get_app()._tr

        # Connections to objects imported from .ui file
        tab = {
            "openshot-qt": self.tab_openshot_qt,
            "libopenshot": self.tab_libopenshot,
            "libopenshot-audio": self.tab_libopenshot_audio,
        }
        vbox = {
            "openshot-qt": self.vbox_openshot_qt,
            "libopenshot": self.vbox_libopenshot,
            "libopenshot-audio": self.vbox_libopenshot_audio,
        }
        filter = {
            "openshot-qt": self.txtChangeLogFilter_openshot_qt,
            "libopenshot": self.txtChangeLogFilter_libopenshot,
            "libopenshot-audio": self.txtChangeLogFilter_libopenshot_audio,
        }

        # Update github link button
        github_text = _("OpenShot on GitHub")
        github_html = '''
            <html><head/><body>
            <p align="center">
                <a href="https://github.com/OpenShot/">
                <span style=" text-decoration: underline; color:#55aaff;">%s</span>
                </a>
            </p>
            </body></html>
            ''' % (github_text)
        self.lblGitHubLink.setText(github_html)

        # Read changelog file for each project
        for project in ['openshot-qt', 'libopenshot', 'libopenshot-audio']:
            new_changelog_path = os.path.join(info.PATH, 'resources', '{}.log'.format(project))
            old_changelog_path = os.path.join(info.PATH, 'settings', '{}.log'.format(project))
            if os.path.exists(new_changelog_path):
                log.debug("Reading changelog file: {}".format(new_changelog_path))
                changelog_list = parse_new_changelog(new_changelog_path)
            elif os.path.isfile(old_changelog_path):
                log.debug("Reading legacy changelog file: {}".format(old_changelog_path))
                changelog_list = parse_changelog(old_changelog_path)
            else:
                changelog_list = None
            # Hopefully we found ONE of the two
            if changelog_list is None:
                log.warn("Could not load changelog for {}".format(project))
                # Hide the tab for this changelog
                tabindex = self.tabChangelog.indexOf(tab[project])
                if tabindex >= 0:
                    self.tabChangelog.removeTab(tabindex)
                continue
            # Populate listview widget with changelog data
            cl_treeview = ChangelogTreeView(
                commits=changelog_list,
                commit_url="https://github.com/OpenShot/{}/commit/%s/".format(project))
            vbox[project].addWidget(cl_treeview)
            filter[project].textChanged.connect(
                partial(self.Filter_Triggered, filter[project], cl_treeview))
Beispiel #39
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer & init
        ui_util.load_ui(self, self.ui_path)
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Hide chnagelog button by default
        self.btnchangelog.setVisible(False)

        projects = ['openshot-qt', 'libopenshot', 'libopenshot-audio']
        # Old paths
        paths = [os.path.join(info.PATH, 'settings', '{}.log'.format(p)) for p in projects]
        # New paths
        paths.extend([os.path.join(info.PATH, 'resources', '{}.log'.format(p)) for p in projects])
        if any([os.path.exists(path) for path in paths]):
            self.btnchangelog.setVisible(True)
        else:
            log.warn("No changelog files found, disabling button")

        create_text = _('Create &amp; Edit Amazing Videos and Movies')
        description_text = _(
            "OpenShot Video Editor 2.x is the next generation of the award-winning <br/>"
            "OpenShot video editing platform.")
        learnmore_text = _('Learn more')
        copyright_text = _('Copyright &copy; %(begin_year)s-%(current_year)s') % {
            'begin_year': '2008',
            'current_year': str(datetime.datetime.today().year)
            }
        about_html = '''
            <html><head/><body><hr/>
            <p align="center">
            <span style=" font-size:10pt; font-weight:600;">%s</span>
            </p>
            <p align="center">
            <span style=" font-size:10pt;">%s </span>
            <a href="https://www.openshot.org/%s?r=about-us">
                <span style=" font-size:10pt; text-decoration: none; color:#55aaff;">%s</span>
            </a>
            <span style=" font-size:10pt;">.</span>
            </p>
            </body></html>
            ''' % (
                create_text,
                description_text,
                info.website_language(),
                learnmore_text)
        company_html = '''
            <html><head/>
            <body style="font-size:11pt; font-weight:400; font-style:normal;">
            <hr />
            <p align="center"
               style="margin:12px 12px 0 0; -qt-block-indent:0; text-indent:0;">
               <span style="font-size:10pt; font-weight:600;">%s </span>
               <a href="http://www.openshotstudios.com?r=about-us">
               <span style="font-size:10pt; font-weight:600; text-decoration: none; color:#55aaff;">
               OpenShot Studios, LLC<br /></span></a>
            </p>
            </body></html>
            ''' % (copyright_text)

        # Set description and company labels
        self.lblAboutDescription.setText(about_html)
        self.lblAboutCompany.setText(company_html)

        # set events handlers
        self.btncredit.clicked.connect(self.load_credit)
        self.btnlicense.clicked.connect(self.load_license)
        self.btnchangelog.clicked.connect(self.load_changelog)

        # Look for frozen version info
        frozen_version_label = ""
        version_path = os.path.join(info.PATH, "settings", "version.json")
        if os.path.exists(version_path):
            with open(version_path, "r", encoding="UTF-8") as f:
                version_info = json.loads(f.read())
                if version_info:
                    frozen_version_label = "<br/><br/><b>%s</b><br/>Build Date: %s" % \
                        (version_info.get('build_name'), version_info.get('date'))

        # Init some variables
        openshot_qt_version = _("Version: %s") % info.VERSION
        libopenshot_version = "libopenshot: %s" % openshot.OPENSHOT_VERSION_FULL
        self.txtversion.setText(
            "<b>%s</b><br/>%s%s" % (openshot_qt_version, libopenshot_version, frozen_version_label))
        self.txtversion.setAlignment(Qt.AlignCenter)

        # Track metrics
        track_metric_screen("about-screen")
Beispiel #40
0
    def __init__(self, file):
        self.file = file

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Track metrics
        track_metric_screen("file-properties-screen")

        # Add buttons to interface
        self.update_button = QPushButton(_('Update'))
        self.buttonBox.addButton(self.update_button, QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(QPushButton(_('Cancel')), QDialogButtonBox.RejectRole)

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Get file properties
        path, filename = os.path.split(self.file.data["path"])
        baseFilename, ext = os.path.splitext(filename)
        fps_float = float(self.file.data["fps"]["num"]) / float(self.file.data["fps"]["den"])

        tags = ""
        if "tags" in self.file.data.keys():
            tags = self.file.data["tags"]
        name = filename
        if "name" in self.file.data.keys():
            name = self.file.data["name"]

        # Populate fields
        self.txtFileName.setText(name)
        self.txtTags.setText(tags)
        self.txtFilePath.setText(os.path.join(path, filename))
        self.btnBrowse.clicked.connect(self.browsePath)

        # Populate video fields
        self.txtWidth.setValue(self.file.data["width"])
        self.txtHeight.setValue(self.file.data["height"])
        self.txtFrameRateNum.setValue(self.file.data["fps"]["num"])
        self.txtFrameRateDen.setValue(self.file.data["fps"]["den"])
        self.txtAspectRatioNum.setValue(self.file.data["display_ratio"]["num"])
        self.txtAspectRatioDen.setValue(self.file.data["display_ratio"]["den"])
        self.txtPixelRatioNum.setValue(self.file.data["pixel_ratio"]["num"])
        self.txtPixelRatioDen.setValue(self.file.data["pixel_ratio"]["den"])

        # Disable Framerate if audio stream found
        if self.file.data["has_audio"]:
            self.txtFrameRateNum.setEnabled(False)
            self.txtFrameRateDen.setEnabled(False)

        self.txtStartFrame.setMaximum(int(self.file.data["video_length"]))
        if 'start' not in file.data.keys():
            self.txtStartFrame.setValue(1)
        else:
            self.txtStartFrame.setValue(round(float(file.data["start"]) * fps_float) + 1)

        self.txtEndFrame.setMaximum(int(self.file.data["video_length"]))
        if 'end' not in file.data.keys():
            self.txtEndFrame.setValue(int(self.file.data["video_length"]))
        else:
            self.txtEndFrame.setValue(round(float(file.data["end"]) * fps_float) + 1)

        # Populate video & audio format
        self.txtVideoFormat.setText(ext.replace(".", ""))
        self.txtVideoCodec.setText(self.file.data["vcodec"])
        self.txtAudioCodec.setText(self.file.data["acodec"])
        self.txtSampleRate.setValue(int(self.file.data["sample_rate"]))
        self.txtChannels.setValue(int(self.file.data["channels"]))
        self.txtVideoBitRate.setValue(int(self.file.data["video_bit_rate"]))
        self.txtAudioBitRate.setValue(int(self.file.data["audio_bit_rate"]))

        # Populate output field
        self.txtOutput.setText(json.dumps(file.data, sort_keys=True, indent=4, separators=(',', ': ')))

        # Add channel layouts
        channel_layout_index = 0
        selected_channel_layout_index = 0
        current_channel_layout = 0
        if self.file.data["has_audio"]:
            current_channel_layout = int(self.file.data["channel_layout"])
        self.channel_layout_choices = []
        for layout in [(0, _("Unknown")),
                       (openshot.LAYOUT_MONO, _("Mono (1 Channel)")),
                       (openshot.LAYOUT_STEREO, _("Stereo (2 Channel)")),
                       (openshot.LAYOUT_SURROUND, _("Surround (3 Channel)")),
                       (openshot.LAYOUT_5POINT1, _("Surround (5.1 Channel)")),
                       (openshot.LAYOUT_7POINT1, _("Surround (7.1 Channel)"))]:
            log.info(layout)
            self.channel_layout_choices.append(layout[0])
            self.cboChannelLayout.addItem(layout[1], layout[0])
            if current_channel_layout == layout[0]:
                selected_channel_layout_index = channel_layout_index
            channel_layout_index += 1

        # Select matching channel layout
        self.cboChannelLayout.setCurrentIndex(selected_channel_layout_index)

        # Load the interlaced options
        self.cboInterlaced.clear()
        self.cboInterlaced.addItem(_("Yes"), "Yes")
        self.cboInterlaced.addItem(_("No"), "No")
        if self.file.data["interlaced_frame"]:
            self.cboInterlaced.setCurrentIndex(0)
        else:
            self.cboInterlaced.setCurrentIndex(1)

        # Switch to 1st page
        self.toolBox.setCurrentIndex(0)
    def __init__(self):
        QDialog.__init__(self, parent=app.main_window)
        ui_util.load_ui(self, 'settings_db')
        ui_util.init_ui(self)

        self._fill_settings_fields()
Beispiel #42
0
    def __init__(self, file=None, preview=False):
        _ = get_app()._tr

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("cutting-screen")

        # If preview, hide cutting controls
        if preview:
            self.lblInstructions.setVisible(False)
            self.widgetControls.setVisible(False)
            self.setWindowTitle(_("Preview"))

        self.start_frame = 1
        self.start_image = None
        self.end_frame = 1
        self.end_image = None

        # Keep track of file object
        self.file = file
        self.file_path = file.absolute_path()
        self.video_length = int(file.data['video_length'])
        self.fps_num = int(file.data['fps']['num'])
        self.fps_den = int(file.data['fps']['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)
        self.width = int(file.data['width'])
        self.height = int(file.data['height'])
        self.sample_rate = int(file.data['sample_rate'])
        self.channels = int(file.data['channels'])
        self.channel_layout = int(file.data['channel_layout'])

        # Open video file with Reader
        log.info(self.file_path)

        # Create an instance of a libopenshot Timeline object
        self.r = openshot.Timeline(self.width, self.height, openshot.Fraction(self.fps_num, self.fps_den), self.sample_rate, self.channels, self.channel_layout)
        self.r.info.channel_layout = self.channel_layout

        try:
            # Add clip for current preview file
            self.clip = openshot.Clip(self.file_path)

            # Show waveform for audio files
            if not self.clip.Reader().info.has_video and self.clip.Reader().info.has_audio:
                self.clip.Waveform(True)

            # Set has_audio property
            self.r.info.has_audio = self.clip.Reader().info.has_audio

            if preview:
                # Display frame #'s during preview
                self.clip.display = openshot.FRAME_DISPLAY_CLIP

            self.r.AddClip(self.clip)
        except:
            log.error('Failed to load media file into preview player: %s' % self.file_path)
            return

        # Add Video Widget
        self.videoPreview = VideoWidget()
        self.videoPreview.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Expanding)
        self.verticalLayout.insertWidget(0, self.videoPreview)

        # Set max size of video preview (for speed)
        viewport_rect = self.videoPreview.centeredViewport(self.videoPreview.width(), self.videoPreview.height())
        self.r.SetMaxSize(viewport_rect.width(), viewport_rect.height())

        # Open reader
        self.r.Open()

        # Start the preview thread
        self.initialized = False
        self.transforming_clip = False
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.r, self.videoPreview)
        self.preview_thread = self.preview_parent.worker

        # Set slider constraints
        self.sliderIgnoreSignal = False
        self.sliderVideo.setMinimum(1)
        self.sliderVideo.setMaximum(self.video_length)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setPageStep(24)

        # Determine if a start or end attribute is in this file
        start_frame = 1
        if 'start' in self.file.data.keys():
            start_frame = (float(self.file.data['start']) * self.fps) + 1

        # Display start frame (and then the previous frame)
        QTimer.singleShot(500, functools.partial(self.sliderVideo.setValue, start_frame + 1))
        QTimer.singleShot(600, functools.partial(self.sliderVideo.setValue, start_frame))

        # Connect signals
        self.actionPlay.triggered.connect(self.actionPlay_Triggered)
        self.btnPlay.clicked.connect(self.btnPlay_clicked)
        self.sliderVideo.valueChanged.connect(self.sliderVideo_valueChanged)
        self.btnStart.clicked.connect(self.btnStart_clicked)
        self.btnEnd.clicked.connect(self.btnEnd_clicked)
        self.btnClear.clicked.connect(self.btnClear_clicked)
        self.btnAddClip.clicked.connect(self.btnAddClip_clicked)
        self.initialized = True
Beispiel #43
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Track metrics
        track_metric_screen("export-screen")

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Add buttons to interface
        self.export_button = QPushButton(_('Export Video'))
        self.buttonBox.addButton(self.export_button,
                                 QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(QPushButton(_('Cancel')),
                                 QDialogButtonBox.RejectRole)
        self.exporting = False

        # Clear timeline preview cache (to get more avaiable memory)
        if get_app().window.cache_object:
            get_app().window.cache_object.Clear()

        # Hide audio channels
        self.lblChannels.setVisible(False)
        self.txtChannels.setVisible(False)

        # Get the original timeline settings
        width = get_app().window.timeline_sync.timeline.info.width
        height = get_app().window.timeline_sync.timeline.info.height
        fps = get_app().window.timeline_sync.timeline.info.fps
        sample_rate = get_app().window.timeline_sync.timeline.info.sample_rate
        channels = get_app().window.timeline_sync.timeline.info.channels
        channel_layout = get_app(
        ).window.timeline_sync.timeline.info.channel_layout

        # Create new "export" openshot.Timeline object
        self.timeline = openshot.Timeline(width, height,
                                          openshot.Fraction(fps.num, fps.den),
                                          sample_rate, channels,
                                          channel_layout)
        # Init various properties
        self.timeline.info.channel_layout = get_app(
        ).window.timeline_sync.timeline.info.channel_layout
        self.timeline.info.has_audio = get_app(
        ).window.timeline_sync.timeline.info.has_audio
        self.timeline.info.has_video = get_app(
        ).window.timeline_sync.timeline.info.has_video
        self.timeline.info.video_length = get_app(
        ).window.timeline_sync.timeline.info.video_length
        self.timeline.info.duration = get_app(
        ).window.timeline_sync.timeline.info.duration
        self.timeline.info.sample_rate = get_app(
        ).window.timeline_sync.timeline.info.sample_rate
        self.timeline.info.channels = get_app(
        ).window.timeline_sync.timeline.info.channels

        # Load the "export" Timeline reader with the JSON from the real timeline
        json_timeline = json.dumps(get_app().project._data)
        self.timeline.SetJson(json_timeline)

        # Open the "export" Timeline reader
        self.timeline.Open()

        # Default export path
        recommended_path = recommended_path = os.path.join(info.HOME_PATH)
        if app.project.current_filepath:
            recommended_path = os.path.dirname(app.project.current_filepath)

        export_path = get_app().project.get(["export_path"])
        if os.path.exists(export_path):
            # Use last selected export path
            self.txtExportFolder.setText(export_path)
        else:
            # Default to home dir
            self.txtExportFolder.setText(recommended_path)

        # Is this a saved project?
        if not get_app().project.current_filepath:
            # Not saved yet
            self.txtFileName.setText(_("Untitled Project"))
        else:
            # Yes, project is saved
            # Get just the filename
            parent_path, filename = os.path.split(
                get_app().project.current_filepath)
            filename, ext = os.path.splitext(filename)
            self.txtFileName.setText(
                filename.replace("_", " ").replace("-", " ").capitalize())

        # Default image type
        self.txtImageFormat.setText("%05.png")

        # Loop through Export To options
        export_options = [_("Video & Audio"), _("Image Sequence")]
        for option in export_options:
            # append profile to list
            self.cboExportTo.addItem(option)

        # Add channel layouts
        self.channel_layout_choices = []
        for layout in [(openshot.LAYOUT_MONO, _("Mono (1 Channel)")),
                       (openshot.LAYOUT_STEREO, _("Stereo (2 Channel)")),
                       (openshot.LAYOUT_SURROUND, _("Surround (3 Channel)")),
                       (openshot.LAYOUT_5POINT1, _("Surround (5.1 Channel)")),
                       (openshot.LAYOUT_7POINT1, _("Surround (7.1 Channel)"))]:
            log.info(layout)
            self.channel_layout_choices.append(layout[0])
            self.cboChannelLayout.addItem(layout[1], layout[0])

        # Connect signals
        self.btnBrowse.clicked.connect(
            functools.partial(self.btnBrowse_clicked))
        self.cboSimpleProjectType.currentIndexChanged.connect(
            functools.partial(self.cboSimpleProjectType_index_changed,
                              self.cboSimpleProjectType))
        self.cboProfile.currentIndexChanged.connect(
            functools.partial(self.cboProfile_index_changed, self.cboProfile))
        self.cboSimpleTarget.currentIndexChanged.connect(
            functools.partial(self.cboSimpleTarget_index_changed,
                              self.cboSimpleTarget))
        self.cboSimpleVideoProfile.currentIndexChanged.connect(
            functools.partial(self.cboSimpleVideoProfile_index_changed,
                              self.cboSimpleVideoProfile))
        self.cboSimpleQuality.currentIndexChanged.connect(
            functools.partial(self.cboSimpleQuality_index_changed,
                              self.cboSimpleQuality))
        self.cboChannelLayout.currentIndexChanged.connect(self.updateChannels)
        get_app().window.ExportFrame.connect(self.updateProgressBar)

        # ********* Advaned Profile List **********
        # Loop through profiles
        self.profile_names = []
        self.profile_paths = {}
        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
            for file in os.listdir(profile_folder):
                # Load Profile
                profile_path = os.path.join(profile_folder, file)
                profile = openshot.Profile(profile_path)

                # Add description of Profile to list
                self.profile_names.append(profile.info.description)
                self.profile_paths[profile.info.description] = profile_path

        # Sort list
        self.profile_names.sort()

        # Loop through sorted profiles
        box_index = 0
        self.selected_profile_index = 0
        for profile_name in self.profile_names:

            # Add to dropdown
            self.cboProfile.addItem(profile_name,
                                    self.profile_paths[profile_name])

            # Set default (if it matches the project)
            if app.project.get(['profile']) == profile_name:
                self.selected_profile_index = box_index

            # increment item counter
            box_index += 1

        # ********* Simple Project Type **********
        # load the simple project type dropdown
        presets = []
        for file in os.listdir(info.EXPORT_PRESETS_DIR):
            xmldoc = xml.parse(os.path.join(info.EXPORT_PRESETS_DIR, file))
            type = xmldoc.getElementsByTagName("type")
            presets.append(_(type[0].childNodes[0].data))

        # Exclude duplicates
        type_index = 0
        selected_type = 0
        presets = list(set(presets))
        for item in sorted(presets):
            self.cboSimpleProjectType.addItem(item, item)
            if item == _("All Formats"):
                selected_type = type_index
            type_index += 1

        # Always select 'All Formats' option
        self.cboSimpleProjectType.setCurrentIndex(selected_type)

        # Populate all profiles
        self.populateAllProfiles(app.project.get(['profile']))

        # Connect framerate signals
        self.txtFrameRateNum.valueChanged.connect(self.updateFrameRate)
        self.txtFrameRateDen.valueChanged.connect(self.updateFrameRate)
        self.txtWidth.valueChanged.connect(self.updateFrameRate)
        self.txtHeight.valueChanged.connect(self.updateFrameRate)
        self.txtSampleRate.valueChanged.connect(self.updateFrameRate)
        self.txtChannels.valueChanged.connect(self.updateFrameRate)
        self.cboChannelLayout.currentIndexChanged.connect(self.updateFrameRate)

        # Determine the length of the timeline (in frames)
        self.updateFrameRate()
Beispiel #44
0
    def __init__(self):

        # Create main window base class
        QMainWindow.__init__(self)

        # set window on app for reference during initialization of children
        get_app().window = self

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Load user settings for window
        s = settings.get_settings()
        self.recent_menu = None

        # Init UI
        ui_util.init_ui(self)

        # Setup toolbars that aren't on main window, set initial state of items, etc
        self.setup_toolbars()

        # Add window as watcher to receive undo/redo status updates
        get_app().updates.add_watcher(self)

        # Track the selected file(s)
        self.selected_files = []
        self.selected_clips = []
        self.selected_transitions = []
        self.selected_markers = []
        self.selected_tracks = []
        self.selected_effects = []

        # Init fullscreen menu visibility
        self.init_fullscreen_menu()

        # Setup timeline
        self.timeline = TimelineWebView(self)
        self.frameWeb.layout().addWidget(self.timeline)

        # Set Window title
        self.SetWindowTitle()

        # Setup files tree
        if s.get("file_view") == "details":
            self.filesTreeView = FilesTreeView(self)
        else:
            self.filesTreeView = FilesListView(self)
        self.tabFiles.layout().addWidget(self.filesTreeView)

        # Setup transitions tree
        if s.get("transitions_view") == "details":
            self.transitionsTreeView = TransitionsTreeView(self)
        else:
            self.transitionsTreeView = TransitionsListView(self)
        self.tabTransitions.layout().addWidget(self.transitionsTreeView)

        # Setup effects tree
        if s.get("effects_view") == "details":
            self.effectsTreeView = EffectsTreeView(self)
        else:
            self.effectsTreeView = EffectsListView(self)
        self.tabEffects.layout().addWidget(self.effectsTreeView)

        # Setup properties table
        self.propertyTableView = PropertiesTableView(self)
        self.dockPropertiesContent.layout().addWidget(self.propertyTableView, 3, 1)

        # Setup video preview QWidget
        self.videoPreview = VideoWidget()
        self.tabVideo.layout().insertWidget(0, self.videoPreview)

        # Load window state and geometry
        self.load_settings()

        # Create the timeline sync object (used for previewing timeline)
        self.timeline_sync = TimelineSync()

        # Start the preview thread
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.timeline_sync.timeline)
        self.preview_thread = self.preview_parent.worker
Beispiel #45
0
    def __init__(self, files=None, position=0.0):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from Designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Get settings
        self.settings = settings.get_settings()

        # Get translation object
        self.app = get_app()
        _ = self.app._tr

        # Track metrics
        track_metric_screen("add-to-timeline-screen")

        # Add custom treeview to window
        self.treeFiles = TimelineTreeView(self)
        self.vboxTreeParent.insertWidget(0, self.treeFiles)

        # Update data in model
        self.treeFiles.timeline_model.update_model(files)

        # Refresh view
        self.treeFiles.refresh_view()

        # Init start position
        self.txtStartTime.setValue(position)

        # Init default image length
        self.txtImageLength.setValue(self.settings.get("default-image-length"))
        self.txtImageLength.valueChanged.connect(self.updateTotal)
        self.cmbTransition.currentIndexChanged.connect(self.updateTotal)
        self.cmbFade.currentIndexChanged.connect(self.updateTotal)
        self.txtFadeLength.valueChanged.connect(self.updateTotal)
        self.txtTransitionLength.valueChanged.connect(self.updateTotal)

        # Add all tracks to dropdown
        tracks = Track.filter()
        for track in reversed(tracks):
            # Add to dropdown
            self.cmbTrack.addItem(_('Track %s' % track.data['number']),
                                  track.data['number'])

        # Add all fade options
        self.cmbFade.addItem(_('None'), None)
        self.cmbFade.addItem(_('Fade In'), 'Fade In')
        self.cmbFade.addItem(_('Fade Out'), 'Fade Out')
        self.cmbFade.addItem(_('Fade In & Out'), 'Fade In & Out')

        # Add all zoom options
        self.cmbZoom.addItem(_('None'), None)
        self.cmbZoom.addItem(_('Random'), 'Random')
        self.cmbZoom.addItem(_('Zoom In'), 'Zoom In')
        self.cmbZoom.addItem(_('Zoom Out'), 'Zoom Out')

        # Add all transitions
        transitions_dir = os.path.join(info.PATH, "transitions")
        common_dir = os.path.join(transitions_dir, "common")
        extra_dir = os.path.join(transitions_dir, "extra")
        transition_groups = [{
            "type": "common",
            "dir": common_dir,
            "files": os.listdir(common_dir)
        }, {
            "type": "extra",
            "dir": extra_dir,
            "files": os.listdir(extra_dir)
        }]

        self.cmbTransition.addItem(_('None'), None)
        self.cmbTransition.addItem(_('Random'), 'random')
        self.transitions = []
        for group in transition_groups:
            type = group["type"]
            dir = group["dir"]
            files = group["files"]

            for filename in sorted(files):
                path = os.path.join(dir, filename)
                (fileBaseName, fileExtension) = os.path.splitext(filename)

                # Skip hidden files (such as .DS_Store, etc...)
                if filename[0] == "." or "thumbs.db" in filename.lower():
                    continue

                # split the name into parts (looking for a number)
                suffix_number = None
                name_parts = fileBaseName.split("_")
                if name_parts[-1].isdigit():
                    suffix_number = name_parts[-1]

                # get name of transition
                trans_name = fileBaseName.replace("_", " ").capitalize()

                # replace suffix number with placeholder (if any)
                if suffix_number:
                    trans_name = trans_name.replace(suffix_number, "%s")
                    trans_name = _(trans_name) % suffix_number
                else:
                    trans_name = _(trans_name)

                # Check for thumbnail path (in build-in cache)
                thumb_path = os.path.join(info.IMAGES_PATH, "cache",
                                          "{}.png".format(fileBaseName))

                # Check built-in cache (if not found)
                if not os.path.exists(thumb_path):
                    # Check user folder cache
                    thumb_path = os.path.join(info.CACHE_PATH,
                                              "{}.png".format(fileBaseName))

                # Add item
                self.transitions.append(path)
                self.cmbTransition.addItem(QIcon(thumb_path), _(trans_name),
                                           path)

        # Connections
        self.btnMoveUp.clicked.connect(self.btnMoveUpClicked)
        self.btnMoveDown.clicked.connect(self.btnMoveDownClicked)
        self.btnShuffle.clicked.connect(self.btnShuffleClicked)
        self.btnRemove.clicked.connect(self.btnRemoveClicked)
        self.btnBox.accepted.connect(self.accept)
        self.btnBox.rejected.connect(self.reject)

        # Update total
        self.updateTotal()
Beispiel #46
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Update github link button
        github_text = _("OpenShot on GitHub")
        github_html = '<html><head/><body><p align="center"><a href="https://github.com/OpenShot/"><span style=" text-decoration: underline; color:#55aaff;">%s</span></a></p></body></html>' % (
            github_text)
        self.lblGitHubLink.setText(github_html)

        # Get changelog for openshot-qt (if any)
        changelog_list = []
        changelog_path = os.path.join(info.PATH, 'settings', 'openshot-qt.log')
        if os.path.exists(changelog_path):
            # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
            for encoding_name in ('utf-8', 'utf_16_le'):
                try:
                    with codecs.open(changelog_path,
                                     'r',
                                     encoding=encoding_name) as changelog_file:
                        for line in changelog_file:
                            changelog_list.append({
                                'hash': line[:9].strip(),
                                'date': line[9:20].strip(),
                                'author': line[20:45].strip(),
                                'subject': line[45:].strip()
                            })
                        break
                except:
                    # Ignore decoding errors
                    pass
        self.openshot_qt_ListView = ChangelogTreeView(
            commits=changelog_list,
            commit_url="https://github.com/OpenShot/openshot-qt/commit/%s/")
        self.vbox_openshot_qt.addWidget(self.openshot_qt_ListView)
        self.txtChangeLogFilter_openshot_qt.textChanged.connect(
            partial(self.Filter_Triggered, self.txtChangeLogFilter_openshot_qt,
                    self.openshot_qt_ListView))

        # Get changelog for libopenshot (if any)
        changelog_list = []
        changelog_path = os.path.join(info.PATH, 'settings', 'libopenshot.log')
        if os.path.exists(changelog_path):
            # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
            for encoding_name in ('utf-8', 'utf_16_le'):
                try:
                    with codecs.open(changelog_path,
                                     'r',
                                     encoding=encoding_name) as changelog_file:
                        for line in changelog_file:
                            changelog_list.append({
                                'hash': line[:9].strip(),
                                'date': line[9:20].strip(),
                                'author': line[20:45].strip(),
                                'subject': line[45:].strip()
                            })
                except:
                    # Ignore decoding errors
                    pass
        self.libopenshot_ListView = ChangelogTreeView(
            commits=changelog_list,
            commit_url="https://github.com/OpenShot/libopenshot/commit/%s/")
        self.vbox_libopenshot.addWidget(self.libopenshot_ListView)
        self.txtChangeLogFilter_libopenshot.textChanged.connect(
            partial(self.Filter_Triggered, self.txtChangeLogFilter_libopenshot,
                    self.libopenshot_ListView))

        # Get changelog for libopenshot-audio (if any)
        changelog_list = []
        changelog_path = os.path.join(info.PATH, 'settings',
                                      'libopenshot-audio.log')
        if os.path.exists(changelog_path):
            # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
            for encoding_name in ('utf-8', 'utf_16_le'):
                try:
                    with codecs.open(changelog_path,
                                     'r',
                                     encoding=encoding_name) as changelog_file:
                        for line in changelog_file:
                            changelog_list.append({
                                'hash': line[:9].strip(),
                                'date': line[9:20].strip(),
                                'author': line[20:45].strip(),
                                'subject': line[45:].strip()
                            })
                except:
                    # Ignore decoding errors
                    pass
        self.libopenshot_audio_ListView = ChangelogTreeView(
            commits=changelog_list,
            commit_url=
            "https://github.com/OpenShot/libopenshot-audio/commit/%s/")
        self.vbox_libopenshot_audio.addWidget(self.libopenshot_audio_ListView)
        self.txtChangeLogFilter_libopenshot_audio.textChanged.connect(
            partial(self.Filter_Triggered,
                    self.txtChangeLogFilter_libopenshot_audio,
                    self.libopenshot_audio_ListView))
Beispiel #47
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Add buttons to interface
        self.export_button = QPushButton(_('Export Video'))
        self.buttonBox.addButton(self.export_button, QDialogButtonBox.AcceptRole)
        self.buttonBox.addButton(QPushButton(_('Cancel')), QDialogButtonBox.RejectRole)
        self.exporting = False

        # Default export path
        recommended_path = recommended_path = os.path.join(info.HOME_PATH)
        if app.project.current_filepath:
            recommended_path = os.path.dirname(app.project.current_filepath)

        export_path = get_app().project.get(["export_path"])
        if os.path.exists(export_path):
            # Use last selected export path
            self.txtExportFolder.setText(export_path)
        else:
            # Default to home dir
            self.txtExportFolder.setText(recommended_path)

        # Is this a saved project?
        if not get_app().project.current_filepath:
            # Not saved yet
            self.txtFileName.setText(_("Untitled Project"))
        else:
            # Yes, project is saved
            # Get just the filename
            parent_path, filename = os.path.split(get_app().project.current_filepath)
            filename, ext = os.path.splitext(filename)
            self.txtFileName.setText(filename.replace("_", " ").replace("-", " ").capitalize())

        # Default image type
        self.txtImageFormat.setText("%05.png")

        # Loop through Export To options
        export_options = [_("Video & Audio"), _("Image Sequence")]
        for option in export_options:
            # append profile to list
            self.cboExportTo.addItem(option)

        # Connect signals
        self.btnBrowse.clicked.connect(functools.partial(self.btnBrowse_clicked))
        self.cboSimpleProjectType.currentIndexChanged.connect(
            functools.partial(self.cboSimpleProjectType_index_changed, self.cboSimpleProjectType))
        self.cboProfile.currentIndexChanged.connect(functools.partial(self.cboProfile_index_changed, self.cboProfile))
        self.cboSimpleTarget.currentIndexChanged.connect(
            functools.partial(self.cboSimpleTarget_index_changed, self.cboSimpleTarget))
        self.cboSimpleVideoProfile.currentIndexChanged.connect(
            functools.partial(self.cboSimpleVideoProfile_index_changed, self.cboSimpleVideoProfile))
        self.cboSimpleQuality.currentIndexChanged.connect(
            functools.partial(self.cboSimpleQuality_index_changed, self.cboSimpleQuality))


        # ********* Advaned Profile List **********
        # Loop through profiles
        self.profile_names = []
        self.profile_paths = {}
        for file in os.listdir(info.PROFILES_PATH):
            # Load Profile
            profile_path = os.path.join(info.PROFILES_PATH, file)
            profile = openshot.Profile(profile_path)

            # Add description of Profile to list
            self.profile_names.append(profile.info.description)
            self.profile_paths[profile.info.description] = profile_path

        # Sort list
        self.profile_names.sort()

        # Loop through sorted profiles
        box_index = 0
        self.selected_profile_index = 0
        for profile_name in self.profile_names:

            # Add to dropdown
            self.cboProfile.addItem(profile_name, self.profile_paths[profile_name])

            # Set default (if it matches the project)
            if app.project.get(['profile']) == profile_name:
                self.selected_profile_index = box_index

            # increment item counter
            box_index += 1


        # ********* Simple Project Type **********
        # load the simple project type dropdown
        presets = []
        for file in os.listdir(info.EXPORT_PRESETS_DIR):
            xmldoc = xml.parse(os.path.join(info.EXPORT_PRESETS_DIR, file))
            type = xmldoc.getElementsByTagName("type")
            presets.append(_(type[0].childNodes[0].data))

        # Exclude duplicates
        presets = list(set(presets))
        for item in sorted(presets):
            self.cboSimpleProjectType.addItem(item, item)

        # Populate all profiles
        self.populateAllProfiles(app.project.get(['profile']))

        # Connect framerate signals
        self.txtFrameRateNum.valueChanged.connect(self.updateFrameRate)
        self.txtFrameRateDen.valueChanged.connect(self.updateFrameRate)
        self.txtWidth.valueChanged.connect(self.updateFrameRate)
        self.txtHeight.valueChanged.connect(self.updateFrameRate)
        self.txtSampleRate.valueChanged.connect(self.updateFrameRate)
        self.txtChannels.valueChanged.connect(self.updateFrameRate)

        # Determine the length of the timeline (in frames)
        self.updateFrameRate()
Beispiel #48
0
    def __init__(self):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init Ui
        ui_util.init_ui(self)

        # get translations
        self.app = get_app()
        _ = self.app._tr

        # Hide chnagelog button by default
        self.btnchangelog.setVisible(False)
        for project in ['openshot-qt', 'libopenshot', 'libopenshot-audio']:
            changelog_path = os.path.join(info.PATH, 'settings',
                                          '%s.log' % project)
            if os.path.exists(changelog_path):
                # Attempt to open changelog with utf-8, and then utf-16-le (for unix / windows support)
                for encoding_name in ('utf-8', 'utf_16_le'):
                    try:
                        with codecs.open(
                                changelog_path, 'r',
                                encoding=encoding_name) as changelog_file:
                            if changelog_file.read():
                                self.btnchangelog.setVisible(True)
                                break
                    except:
                        # Ignore decoding errors
                        pass

        create_text = _('Create &amp; Edit Amazing Videos and Movies')
        description_text = _(
            'OpenShot Video Editor 2.x is the next generation of the award-winning <br/>OpenShot video editing platform.'
        )
        learnmore_text = _('Learn more')
        copyright_text = _(
            'Copyright &copy; %(begin_year)s-%(current_year)s') % {
                'begin_year': '2008',
                'current_year': str(datetime.datetime.today().year)
            }
        about_html = '<html><head/><body><hr/><p align="center"><span style=" font-size:10pt; font-weight:600;">%s</span></p><p align="center"><span style=" font-size:10pt;">%s </span><a href="https://www.openshot.org/%s?r=about-us"><span style=" font-size:10pt; text-decoration: none; color:#55aaff;">%s</span></a><span style=" font-size:10pt;">.</span></p></body></html>' % (
            create_text, description_text, info.website_language(),
            learnmore_text)
        company_html = '<html><head/><body style="font-size:11pt; font-weight:400; font-style:normal;">\n<hr />\n<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt; font-weight:600;">%s </span><a href="http://www.openshotstudios.com?r=about-us"><span style=" font-size:10pt; font-weight:600; text-decoration: none; color:#55aaff;">OpenShot Studios, LLC<br /></span></a></p></body></html>' % (
            copyright_text)

        # Set description and company labels
        self.lblAboutDescription.setText(about_html)
        self.lblAboutCompany.setText(company_html)

        # set events handlers
        self.btncredit.clicked.connect(self.load_credit)
        self.btnlicense.clicked.connect(self.load_license)
        self.btnchangelog.clicked.connect(self.load_changelog)

        # Init some variables
        openshot_qt_version = _("Version: %s") % info.VERSION
        libopenshot_version = "libopenshot: %s" % openshot.OPENSHOT_VERSION_FULL
        self.txtversion.setText("<b>%s</b><br/>%s" %
                                (openshot_qt_version, libopenshot_version))
        self.txtversion.setAlignment(Qt.AlignCenter)

        # Track metrics
        track_metric_screen("about-screen")
Beispiel #49
0
    def __init__(self, edit_file_path=None, duplicate=False):

        # Create dialog class
        QDialog.__init__(self)

        self.app = get_app()
        self.project = self.app.project
        self.edit_file_path = edit_file_path
        self.duplicate = duplicate

        # Get translation object
        _ = self.app._tr

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("title-screen")

        # Initialize variables
        self.template_name = ""
        imp = minidom.getDOMImplementation()
        self.xmldoc = imp.createDocument(None, "any", None)

        self.bg_color_code = QtGui.QColor(Qt.black)
        self.font_color_code = QtGui.QColor(Qt.white)

        self.bg_style_string = ""
        self.title_style_string = ""
        self.subtitle_style_string = ""

        self.font_weight = 'normal'
        self.font_style = 'normal'

        self.new_title_text = ""
        self.sub_title_text = ""
        self.subTitle = False

        self.display_name = ""
        self.font_family = "Bitstream Vera Sans"
        self.tspan_node = None

        self.qfont = QtGui.QFont(self.font_family)

        # Add titles list view
        self.titlesTreeView = TitlesListView(self)
        self.verticalLayout.addWidget(self.titlesTreeView)

        # Disable Save button on window load
        self.buttonBox.button(self.buttonBox.Save).setEnabled(False)

        # If editing existing title svg file
        if self.edit_file_path:
            # Hide list of templates
            self.widget.setVisible(False)

            # Create temp version of title
            self.create_temp_title(self.edit_file_path)

            # Add all widgets for editing
            self.load_svg_template()

            # Display image (slight delay to allow screen to be shown first)
            QTimer.singleShot(50, self.display_svg)
Beispiel #50
0
    def __init__(self, file=None):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("cutting-screen")

        self.start_frame = 1
        self.start_image = None
        self.end_frame = 1
        self.end_image = None

        # Keep track of file object
        self.file = file
        self.file_path = file.absolute_path()
        self.video_length = int(file.data['video_length'])
        self.fps_num = int(file.data['fps']['num'])
        self.fps_den = int(file.data['fps']['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)

        # Open video file with Reader
        log.info(self.file_path)
        self.r = openshot.FFmpegReader(self.file_path)
        self.r.Open()

        # Add Video Widget
        self.videoPreview = VideoWidget()
        self.videoPreview.setSizePolicy(QSizePolicy.Preferred,
                                        QSizePolicy.Expanding)
        self.verticalLayout.insertWidget(0, self.videoPreview)

        # Start the preview thread
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.r, self.videoPreview)
        self.preview_thread = self.preview_parent.worker

        # Set slider constraints
        self.sliderIgnoreSignal = False
        self.sliderVideo.setMinimum(1)
        self.sliderVideo.setMaximum(self.video_length)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setPageStep(24)

        # Determine if a start or end attribute is in this file
        start_frame = 1
        if 'start' in self.file.data.keys():
            start_frame = (float(self.file.data['start']) * self.fps) + 1

        # Display start frame (and then the previous frame)
        QTimer.singleShot(
            500, functools.partial(self.sliderVideo.setValue, start_frame + 1))
        QTimer.singleShot(
            600, functools.partial(self.sliderVideo.setValue, start_frame))

        # Connect signals
        self.btnPlay.clicked.connect(self.btnPlay_clicked)
        self.sliderVideo.valueChanged.connect(self.sliderVideo_valueChanged)
        self.btnStart.clicked.connect(self.btnStart_clicked)
        self.btnEnd.clicked.connect(self.btnEnd_clicked)
        self.btnClear.clicked.connect(self.btnClear_clicked)
        self.btnAddClip.clicked.connect(self.btnAddClip_clicked)
    def __init__(self, files=None, position=0.0):
        # Create dialog class
        QDialog.__init__(self)

        # Load UI from Designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Get settings
        self.settings = settings.get_settings()

        # Get translation object
        self.app = get_app()
        _ = self.app._tr

        # Track metrics
        track_metric_screen("add-to-timeline-screen")

        # Add custom treeview to window
        self.treeFiles = TimelineTreeView(self)
        self.vboxTreeParent.insertWidget(0, self.treeFiles)

        # Update data in model
        self.treeFiles.timeline_model.update_model(files)

        # Refresh view
        self.treeFiles.refresh_view()

        # Init start position
        self.txtStartTime.setValue(position)

        # Init default image length
        self.txtImageLength.setValue(self.settings.get("default-image-length"))
        self.txtImageLength.valueChanged.connect(self.updateTotal)
        self.cmbTransition.currentIndexChanged.connect(self.updateTotal)
        self.cmbFade.currentIndexChanged.connect(self.updateTotal)
        self.txtFadeLength.valueChanged.connect(self.updateTotal)
        self.txtTransitionLength.valueChanged.connect(self.updateTotal)

        # Add all tracks to dropdown
        tracks = Track.filter()
        for track in reversed(tracks):
            # Add to dropdown
            self.cmbTrack.addItem(_('Track %s' % track.data['number']), track.data['number'])

        # Add all fade options
        self.cmbFade.addItem(_('None'), None)
        self.cmbFade.addItem(_('Fade In'), 'Fade In')
        self.cmbFade.addItem(_('Fade Out'), 'Fade Out')
        self.cmbFade.addItem(_('Fade In & Out'), 'Fade In & Out')

        # Add all zoom options
        self.cmbZoom.addItem(_('None'), None)
        self.cmbZoom.addItem(_('Random'), 'Random')
        self.cmbZoom.addItem(_('Zoom In'), 'Zoom In')
        self.cmbZoom.addItem(_('Zoom Out'), 'Zoom Out')

        # Add all transitions
        transitions_dir = os.path.join(info.PATH, "transitions")
        common_dir = os.path.join(transitions_dir, "common")
        extra_dir = os.path.join(transitions_dir, "extra")
        transition_groups = [{"type": "common", "dir": common_dir, "files": os.listdir(common_dir)},
                             {"type": "extra", "dir": extra_dir, "files": os.listdir(extra_dir)}]

        self.cmbTransition.addItem(_('None'), None)
        self.cmbTransition.addItem(_('Random'), 'random')
        self.transitions = []
        for group in transition_groups:
            type = group["type"]
            dir = group["dir"]
            files = group["files"]

            for filename in sorted(files):
                path = os.path.join(dir, filename)
                (fileBaseName, fileExtension) = os.path.splitext(filename)

                # Skip hidden files (such as .DS_Store, etc...)
                if filename[0] == "." or "thumbs.db" in filename.lower():
                    continue

                # split the name into parts (looking for a number)
                suffix_number = None
                name_parts = fileBaseName.split("_")
                if name_parts[-1].isdigit():
                    suffix_number = name_parts[-1]

                # get name of transition
                trans_name = fileBaseName.replace("_", " ").capitalize()

                # replace suffix number with placeholder (if any)
                if suffix_number:
                    trans_name = trans_name.replace(suffix_number, "%s")
                    trans_name = _(trans_name) % suffix_number
                else:
                    trans_name = _(trans_name)

                # Check for thumbnail path (in build-in cache)
                thumb_path = os.path.join(info.IMAGES_PATH, "cache",  "{}.png".format(fileBaseName))

                # Check built-in cache (if not found)
                if not os.path.exists(thumb_path):
                    # Check user folder cache
                    thumb_path = os.path.join(info.CACHE_PATH, "{}.png".format(fileBaseName))

                # Add item
                self.transitions.append(path)
                self.cmbTransition.addItem(QIcon(thumb_path), _(trans_name), path)

        # Connections
        self.btnMoveUp.clicked.connect(self.btnMoveUpClicked)
        self.btnMoveDown.clicked.connect(self.btnMoveDownClicked)
        self.btnShuffle.clicked.connect(self.btnShuffleClicked)
        self.btnRemove.clicked.connect(self.btnRemoveClicked)
        self.btnBox.accepted.connect(self.accept)
        self.btnBox.rejected.connect(self.reject)

        # Update total
        self.updateTotal()
Beispiel #52
0
    def __init__(self):

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # get translations
        app = get_app()
        _ = app._tr

        # Get settings
        self.s = settings.get_settings()

        # Dynamically load tabs from settings data
        self.settings_data = settings.get_settings().get_all_settings()

        # Track metrics
        track_metric_screen("preferences-screen")

        # Load all user values
        self.params = {}
        for item in self.settings_data:
            if "setting" in item and "value" in item:
                self.params[item["setting"]] = item

        self.requires_restart = False
        self.category_names = {}
        self.category_tabs = {}
        self.category_sort = {}

        # Loop through settings and find all unique categories
        for item in self.settings_data:
            category = item.get("category")
            setting_type = item.get("type")
            sort_category = item.get("sort")

            # Indicate sorted category
            if sort_category:
                self.category_sort[category] = sort_category

            if not setting_type == "hidden":
                # Load setting
                if not category in self.category_names:
                    self.category_names[category] = []

                    # Create scrollarea
                    scroll_area = QScrollArea(self)
                    scroll_area.setWidgetResizable(True)
                    scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
                    scroll_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

                    # Create tab widget and layout
                    layout = QVBoxLayout()
                    tabWidget = QWidget(self)
                    tabWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
                    tabWidget.setLayout(layout)
                    scroll_area.setWidget(tabWidget)

                    # Add tab
                    self.tabCategories.addTab(scroll_area, _(category))
                    self.category_tabs[category] = tabWidget

                # Append translated title
                item["title_tr"] = _(item.get("title"))

                # Append settings into correct category
                self.category_names[category].append(item)

        # Loop through each category setting, and add them to the tabs
        for category in self.category_tabs.keys():
            tabWidget = self.category_tabs[category]

            # Get list of items in category
            params = self.category_names[category]
            if self.category_sort.get(category):
                # Sort this category by translated title
                params.sort(key=operator.itemgetter("title_tr"))

            # Loop through settings for each category
            for param in params:

                # Create Label
                widget = None
                extraWidget = None
                label = QLabel()
                label.setText(_(param["title"]))
                label.setToolTip(_(param["title"]))

                if param["type"] == "spinner":
                    # create QDoubleSpinBox
                    widget = QDoubleSpinBox()
                    widget.setMinimum(float(param["min"]))
                    widget.setMaximum(float(param["max"]))
                    widget.setValue(float(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                if param["type"] == "spinner-int":
                    # create QDoubleSpinBox
                    widget = QSpinBox()
                    widget.setMinimum(int(param["min"]))
                    widget.setMaximum(int(param["max"]))
                    widget.setValue(int(param["value"]))
                    widget.setSingleStep(1.0)
                    widget.setToolTip(param["title"])
                    widget.valueChanged.connect(functools.partial(self.spinner_value_changed, param))

                elif param["type"] == "text":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))

                elif param["type"] == "browse":
                    # create QLineEdit
                    widget = QLineEdit()
                    widget.setText(_(param["value"]))
                    widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))
                    extraWidget = QPushButton(_("Browse..."))
                    extraWidget.clicked.connect(functools.partial(self.selectExecutable, widget, param))

                elif param["type"] == "bool":
                    # create spinner
                    widget = QCheckBox()
                    if param["value"] == True:
                        widget.setCheckState(Qt.Checked)
                    else:
                        widget.setCheckState(Qt.Unchecked)
                    widget.stateChanged.connect(functools.partial(self.bool_value_changed, widget, param))

                elif param["type"] == "dropdown":

                    # create spinner
                    widget = QComboBox()

                    # Get values
                    value_list = param["values"]
                    # Overwrite value list (for profile dropdown)
                    if param["setting"] == "default-profile":
                        value_list = []
                        # Loop through profiles
                        for profile_folder in [info.USER_PROFILES_PATH, info.PROFILES_PATH]:
                            for file in os.listdir(profile_folder):
                                # Load Profile and append description
                                profile_path = os.path.join(profile_folder, file)
                                profile = openshot.Profile(profile_path)
                                value_list.append({"name":profile.info.description, "value":profile.info.description})
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))

                    # Overwrite value list (for language dropdown)
                    if param["setting"] == "default-language":
                        value_list = []
                        # Loop through languages
                        for locale, language, country in get_all_languages():
                            # Load Profile and append description
                            if language:
                                lang_name = "%s (%s)" % (language, locale)
                                value_list.append({"name":lang_name, "value":locale})
                        # Sort profile list
                        value_list.sort(key=operator.itemgetter("name"))
                        # Add Default to top of list
                        value_list.insert(0, {"name":_("Default"), "value":"Default"})


                    # Add normal values
                    box_index = 0
                    for value_item in value_list:
                        k = value_item["name"]
                        v = value_item["value"]
                        # add dropdown item
                        widget.addItem(_(k), v)

                        # select dropdown (if default)
                        if v == param["value"]:
                            widget.setCurrentIndex(box_index)
                        box_index = box_index + 1

                    widget.currentIndexChanged.connect(functools.partial(self.dropdown_index_changed, widget, param))


                # Add Label and Widget to the form
                if (widget and label):
                    # Add minimum size
                    label.setMinimumWidth(180);
                    label.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
                    widget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)

                    # Create HBox layout
                    layout_hbox = QHBoxLayout()
                    layout_hbox.addWidget(label)
                    layout_hbox.addWidget(widget)

                    if (extraWidget):
                        layout_hbox.addWidget(extraWidget)

                    # Add widget to layout
                    tabWidget.layout().addLayout(layout_hbox)
                elif (label):
                    # Add widget to layout
                    tabWidget.layout().addWidget(label)

            # Add stretch to bottom of layout
            tabWidget.layout().addStretch()
    def __init__(self, cuts_json, clips_json, preview=False):
        _ = get_app()._tr

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("cutting-screen")

        # If preview, hide cutting controls
        if preview:
            self.lblInstructions.setVisible(False)
            self.widgetControls.setVisible(False)
            self.setWindowTitle(_("Preview"))

        self.start_frame = 1
        self.start_image = None
        self.end_frame = 1
        self.end_image = None

        project = get_app().project

        # Keep track of file object
        #self.file = file
        self.file_path = file.absolute_path()
        self.video_length = int(file.data['video_length'])
        self.fps_num = int(file.data['fps']['num'])
        self.fps_den = int(file.data['fps']['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)
        self.width = int(file.data['width'])
        self.height = int(file.data['height'])
        self.sample_rate = int(file.data['sample_rate'])
        self.channels = int(file.data['channels'])
        self.channel_layout = int(file.data['channel_layout'])

        # Open video file with Reader
        log.info(self.file_path)

        # Create an instance of a libopenshot Timeline object
        self.r = openshot.Timeline(
            self.width, self.height,
            openshot.Fraction(self.fps_num, self.fps_den), self.sample_rate,
            self.channels, self.channel_layout)
        self.r.info.channel_layout = self.channel_layout

        try:
            # Add clip for current preview file
            self.clip = openshot.Clip(self.file_path)

            # Show waveform for audio files
            if not self.clip.Reader().info.has_video and self.clip.Reader(
            ).info.has_audio:
                self.clip.Waveform(True)

            # Set has_audio property
            self.r.info.has_audio = self.clip.Reader().info.has_audio

            if preview:
                # Display frame #'s during preview
                self.clip.display = openshot.FRAME_DISPLAY_CLIP

            self.r.AddClip(self.clip)
        except:
            log.error('Failed to load media file into preview player: %s' %
                      self.file_path)
            return

        # Add Video Widget
        self.videoPreview = VideoWidget()
        self.videoPreview.setSizePolicy(QSizePolicy.Preferred,
                                        QSizePolicy.Expanding)
        self.verticalLayout.insertWidget(0, self.videoPreview)

        # Set max size of video preview (for speed)
        viewport_rect = self.videoPreview.centeredViewport(
            self.videoPreview.width(), self.videoPreview.height())
        self.r.SetMaxSize(viewport_rect.width(), viewport_rect.height())

        # Open reader
        self.r.Open()

        # Start the preview thread
        self.initialized = False
        self.transforming_clip = False
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.r, self.videoPreview)
        self.preview_thread = self.preview_parent.worker

        # Set slider constraints
        self.sliderIgnoreSignal = False
        self.sliderVideo.setMinimum(1)
        self.sliderVideo.setMaximum(self.video_length)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setPageStep(24)

        # Determine if a start or end attribute is in this file
        start_frame = 1
        if 'start' in self.file.data.keys():
            start_frame = (float(self.file.data['start']) * self.fps) + 1

        # Display start frame (and then the previous frame)
        QTimer.singleShot(
            500, functools.partial(self.sliderVideo.setValue, start_frame + 1))
        QTimer.singleShot(
            600, functools.partial(self.sliderVideo.setValue, start_frame))

        # Connect signals
        self.actionPlay.triggered.connect(self.actionPlay_Triggered)
        self.btnPlay.clicked.connect(self.btnPlay_clicked)
        self.sliderVideo.valueChanged.connect(self.sliderVideo_valueChanged)
        self.btnStart.clicked.connect(self.btnStart_clicked)
        self.btnEnd.clicked.connect(self.btnEnd_clicked)
        self.btnClear.clicked.connect(self.btnClear_clicked)
        self.btnAddClip.clicked.connect(self.btnAddClip_clicked)
        self.initialized = True
    def __init__(self, cuts=[], preview=False):
        _ = get_app()._tr

        # Create dialog class
        QDialog.__init__(self)

        # Load UI from designer
        ui_util.load_ui(self, self.ui_path)

        # Init UI
        ui_util.init_ui(self)

        # Track metrics
        track_metric_screen("cutting-screen")

        # If preview, hide cutting controls
        if preview:
            self.lblInstructions.setVisible(False)
            self.widgetControls.setVisible(False)
            self.setWindowTitle(_("Preview"))

        self.start_frame = 1
        self.start_image = None
        self.end_frame = 1
        self.end_image = None

        #timeline = get_app().window.timeline_sync.timeline
        #app = get_app()
        #project = app.project

        # Get some settings from the project
        '''
        self.fps = project.get(["fps"])
        self.width = project.get(["width"])
        self.height = project.get(["height"])
        self.sample_rate = project.get(["sample_rate"])
        self.channels = project.get(["channels"])
        self.channel_layout = project.get(["channel_layout"])
        self.fps_num = int(self.fps['num'])
        self.fps_den = int(self.fps['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)
        '''
        # Get the original timeline settings
        self.width = get_app().window.timeline_sync.timeline.info.width
        self.height = get_app().window.timeline_sync.timeline.info.height
        self.fps = get_app().window.timeline_sync.timeline.info.fps
        self.sample_rate = get_app(
        ).window.timeline_sync.timeline.info.sample_rate
        self.channels = get_app().window.timeline_sync.timeline.info.channels
        self.channel_layout = get_app(
        ).window.timeline_sync.timeline.info.channel_layout
        self.fps_num = int(self.fps.num)
        self.fps_den = int(self.fps.den)
        #self.fps = float(self.fps_num) / float(self.fps_den)
        '''
        # Keep track of file object
        self.file = file
        self.file_path = file.absolute_path()
        self.video_length = 0
        self.fps_num = int(file.data['fps']['num'])
        self.fps_den = int(file.data['fps']['den'])
        self.fps = float(self.fps_num) / float(self.fps_den)
        self.width = int(file.data['width'])
        self.height = int(file.data['height'])
        self.sample_rate = int(file.data['sample_rate'])
        self.channels = int(file.data['channels'])
        self.channel_layout = int(file.data['channel_layout'])

        # Open video file with Reader
        log.info(self.file_path)
        '''

        self.video_length = 0
        # Create an instance of a libopenshot Timeline object
        self.r = openshot.Timeline(
            self.width, self.height,
            openshot.Fraction(self.fps_num, self.fps_den), self.sample_rate,
            self.channels, self.channel_layout)
        self.r.info.channel_layout = self.channel_layout
        '''
        #cuts = [{"start_seconds":8.466666666666667, "end_seconds":15.3}, {"start_seconds":18.9, "end_seconds":22.133333333333333}]
        position = 0

        print(cuts)

        cs = app.window.timeline_sync.timeline.Clips()
        for c in cs:
            print("-----id=", c.Id())
            clip_json = Clip.filter(id=c.Id())
            path = clip_json[0].data["reader"]["path"]
            print("==============", path, c.Position())
            offset = c.Position()

            for cut in cuts:
                try:
                    # Add clip for current preview file
                    clip = openshot.Clip(path)
                    self.clips.append(clip)

                    # Show waveform for audio files
                    if not clip.Reader().info.has_video and clip.Reader().info.has_audio:
                        clip.Waveform(True)

                    # Set has_audio property
                    self.r.info.has_audio = clip.Reader().info.has_audio

                    if preview:
                        # Display frame #'s during preview
                        clip.display = openshot.FRAME_DISPLAY_CLIP
                    
                    start = float(cut["start_seconds"] - offset)
                    end = float(cut["end_seconds"] - offset)
                    print("=======================-------start:", start, "end:", end)
                    clip.Start(start)
                    clip.End(end)
                    #clip.Position(0)
                    clip.Position(position)
                    position = position + (end - start) - offset
                    #clip.Duration(end-start)
                    self.r.AddClip(clip)
                    self.video_length = self.video_length + (end - start)
                except:
                    log.error('Failed to load media file into preview player: %s' % self.file_path)
                    return
        '''

        self.clips, self.video_length = CutsToClips(cuts)
        for clip in self.clips:
            # Show waveform for audio files
            if not clip.Reader().info.has_video and clip.Reader(
            ).info.has_audio:
                clip.Waveform(True)
            if preview:
                # Display frame #'s during preview
                clip.display = openshot.FRAME_DISPLAY_CLIP
            self.r.AddClip(clip)

        #self.video_length = self.video_length * self.fps_num / self.fps_den
        # Add Video Widget
        self.videoPreview = VideoWidget()
        self.videoPreview.setSizePolicy(QSizePolicy.Preferred,
                                        QSizePolicy.Expanding)
        self.verticalLayout.insertWidget(0, self.videoPreview)

        # Set max size of video preview (for speed)
        viewport_rect = self.videoPreview.centeredViewport(
            self.videoPreview.width(), self.videoPreview.height())
        self.r.SetMaxSize(viewport_rect.width(), viewport_rect.height())

        # Open reader
        self.r.Open()

        # Start the preview thread
        self.initialized = False
        self.transforming_clip = False
        self.preview_parent = PreviewParent()
        self.preview_parent.Init(self, self.r, self.videoPreview)
        self.preview_thread = self.preview_parent.worker

        # Set slider constraints
        self.sliderIgnoreSignal = False
        self.sliderVideo.setMinimum(1)
        self.sliderVideo.setMaximum(self.video_length)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setSingleStep(1)
        self.sliderVideo.setPageStep(24)

        # Determine if a start or end attribute is in this file
        start_frame = 1
        #if 'start' in self.file.data.keys():
        #    start_frame = (float(self.file.data['start']) * self.fps) + 1

        # Display start frame (and then the previous frame)
        QTimer.singleShot(
            500, functools.partial(self.sliderVideo.setValue, start_frame + 1))
        QTimer.singleShot(
            600, functools.partial(self.sliderVideo.setValue, start_frame))

        # Connect signals
        self.actionPlay.triggered.connect(self.actionPlay_Triggered)
        self.btnPlay.clicked.connect(self.btnPlay_clicked)
        self.sliderVideo.valueChanged.connect(self.sliderVideo_valueChanged)
        self.btnStart.clicked.connect(self.btnStart_clicked)
        self.btnEnd.clicked.connect(self.btnEnd_clicked)
        self.btnClear.clicked.connect(self.btnClear_clicked)
        self.btnAddClip.clicked.connect(self.btnAddClip_clicked)
        self.initialized = True