def main(): """"Initialize settings (not implemented) and create main window/application.""" parser = ArgumentParser(description='OpenShot version ' + info.SETUP['version']) parser.add_argument('-l', '--lang', action='store', help='language code for interface (overrides ' 'preferences and system environment)') parser.add_argument('--list-languages', dest='list_languages', action='store_true', help='List all language ' 'codes supported by OpenShot') parser.add_argument('-V', '--version', action='store_true') parser.add_argument('remain', nargs=REMAINDER) args = parser.parse_args() # Display version and exit (if requested) if args.version: print("OpenShot version %s" % info.SETUP['version']) sys.exit() if args.list_languages: print("Supported Languages:") for lang in get_all_languages(): print(" {:>12} {}".format(lang[0], lang[1])) sys.exit() if args.lang: if args.lang in info.SUPPORTED_LANGUAGES: info.CMDLINE_LANGUAGE = args.lang else: print("Unsupported language '{}'! (See --list-languages)".format( args.lang)) sys.exit(-1) reroute_output() log.info("------------------------------------------------") log.info(" OpenShot (version %s)" % info.SETUP['version']) log.info("------------------------------------------------") # Create Qt application, pass any unprocessed arguments argv = [sys.argv[0]] for arg in args.remain: argv.append(arg) app = OpenShotApp(argv) # Run and return result sys.exit(app.run())
def main(): """"Initialize settings (not implemented) and create main window/application.""" parser = ArgumentParser(description = 'OpenShot version ' + info.SETUP['version']) parser.add_argument('-l', '--lang', action='store', help='language code for interface (overrides ' 'preferences and system environment)') parser.add_argument('--list-languages', dest='list_languages', action='store_true', help='List all language ' 'codes supported by OpenShot') parser.add_argument('-V', '--version', action='store_true') parser.add_argument('remain', nargs=REMAINDER) args = parser.parse_args() # Display version and exit (if requested) if args.version: print("OpenShot version %s" % info.SETUP['version']) sys.exit() if args.list_languages: print("Supported Languages:") for lang in get_all_languages(): print(" {:>12} {}".format(lang[0],lang[1])) sys.exit() if args.lang: if args.lang in info.SUPPORTED_LANGUAGES: info.CMDLINE_LANGUAGE = args.lang else: print("Unsupported language '{}'! (See --list-languages)".format(args.lang)) sys.exit(-1) reroute_output() log.info("------------------------------------------------") log.info(" OpenShot (version %s)" % info.SETUP['version']) log.info("------------------------------------------------") # Create Qt application, pass any unprocessed arguments argv = [sys.argv[0]] for arg in args.remain: argv.append(arg) app = OpenShotApp(argv) # Run and return result sys.exit(app.run())
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)
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): # 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): # 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)
def main(): """"Initialize settings (not implemented) and create main window/application.""" parser = argparse.ArgumentParser(description='OpenShot version ' + info.SETUP['version']) parser.add_argument('-l', '--lang', action='store', help='language code for interface (overrides ' 'preferences and system environment)') parser.add_argument('--list-languages', dest='list_languages', action='store_true', help='List all language ' 'codes supported by OpenShot') parser.add_argument('--path', dest='py_path', action='append', help='Additional locations to search for modules ' '(PYTHONPATH). Can be used multiple times.') parser.add_argument('-V', '--version', action='store_true') parser.add_argument('remain', nargs=argparse.REMAINDER, help=argparse.SUPPRESS) args = parser.parse_args() # Display version and exit (if requested) if args.version: print("OpenShot version %s" % info.SETUP['version']) sys.exit() if args.list_languages: from classes.language import get_all_languages print("Supported Languages:") for lang in get_all_languages(): print(" {:>12} {}".format(lang[0], lang[1])) sys.exit() if args.py_path: for p in args.py_path: try: if os.path.exists(os.path.realpath(p)): sys.path.insert(0, os.path.realpath(p)) print("Added {} to PYTHONPATH".format(os.path.realpath(p))) else: print("{} does not exist".format(os.path.realpath(p))) except TypeError as ex: print("Bad path {}: {}".format(p, ex)) continue if args.lang: if args.lang in info.SUPPORTED_LANGUAGES: info.CMDLINE_LANGUAGE = args.lang else: print("Unsupported language '{}'! (See --list-languages)".format( args.lang)) sys.exit(-1) # Create Qt application, pass any unprocessed arguments from classes.app import OpenShotApp argv = [sys.argv[0]] for arg in args.remain: argv.append(arg) app = OpenShotApp(argv) # Run and return result sys.exit(app.run())
def main(): """"Initialize settings (not implemented) and create main window/application.""" global app # Configure argument handling for commandline launches parser = argparse.ArgumentParser(description='OpenShot version ' + info.SETUP['version']) parser.add_argument( '-l', '--lang', action='store', help='language code for interface (overrides ' 'preferences and system environment)') parser.add_argument( '--list-languages', dest='list_languages', action='store_true', help='List all language codes supported by OpenShot') parser.add_argument( '--path', dest='py_path', action='append', help='Additional locations to search for modules ' '(PYTHONPATH). Can be used multiple times.') parser.add_argument( '--test-models', dest='modeltest', action='store_true', help="Load Qt's QAbstractItemModelTester into data models " '(requires Qt 5.11+)') parser.add_argument( '-b', '--web-backend', action='store', choices=['auto', 'webkit', 'webengine'], default='auto', help="Web backend to use for Timeline") parser.add_argument( '-d', '--debug', action='store_true', help='Enable debugging output') parser.add_argument( '--debug-file', action='store_true', help='Debugging output (logfile only)') parser.add_argument( '--debug-console', action='store_true', help='Debugging output (console only)') parser.add_argument('-V', '--version', action='store_true') parser.add_argument( 'remain', nargs=argparse.REMAINDER, help=argparse.SUPPRESS) args, extra_args = parser.parse_known_args() # Display version and exit (if requested) if args.version: print(info.SETUP['version']) sys.exit() # Set up debugging log level to requested streams if args.debug or args.debug_file: info.LOG_LEVEL_FILE = 'DEBUG' if args.debug or args.debug_console: info.LOG_LEVEL_CONSOLE = 'DEBUG' if args.list_languages: from classes.language import get_all_languages print("Supported Languages:") for code, lang, country in get_all_languages(): print(" {:>12} {}".format(code, lang)) sys.exit() if args.py_path: for p in args.py_path: try: if os.path.exists(os.path.realpath(p)): sys.path.insert(0, os.path.realpath(p)) print("Added {} to PYTHONPATH".format(os.path.realpath(p))) else: print("{} does not exist".format(os.path.realpath(p))) except TypeError as ex: print("Bad path {}: {}".format(p, ex)) continue if args.modeltest: info.MODEL_TEST = True # Set default logging rules, if the user didn't if os.getenv('QT_LOGGING_RULES') is None: os.putenv('QT_LOGGING_RULES', 'qt.modeltest.debug=true') if args.web_backend: info.WEB_BACKEND = args.web_backend.lower() if args.lang: if args.lang in info.SUPPORTED_LANGUAGES: info.CMDLINE_LANGUAGE = args.lang else: print("Unsupported language '{}'! (See --list-languages)".format(args.lang)) sys.exit(-1) # Normal startup, print module path and lauch application print("Loaded modules from: %s" % info.PATH) # Initialize sentry exception tracing from classes import sentry sentry.init_tracing() # Create Qt application, pass any unprocessed arguments from classes.app import OpenShotApp argv = [sys.argv[0]] argv.extend(extra_args) argv.extend(args.remain) app = OpenShotApp(argv) # Setup Qt application details app.setApplicationName('openshot') app.setApplicationVersion(info.SETUP['version']) try: # Qt 5.7+ only app.setDesktopFile("org.openshot.OpenShot") except AttributeError: pass # Launch GUI and start event loop app.gui() sys.exit(app.exec_())
def Populate(self, filter=""): """Populate all preferences and tabs""" # get translations app = get_app() _ = app._tr # Delete all tabs and widgets self.DeleteAllTabs() self.category_names = {} self.category_tabs = {} self.category_sort = {} self.visible_category_names = {} # 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) scroll_area.setMinimumSize(675, 100) # 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 dict(self.category_tabs).keys(): tabWidget = self.category_tabs[category] filterFound = False # 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: # Is filter found? if filter and (filter.lower() in _(param["title"]).lower() or filter.lower() in _(category).lower()): filterFound = True elif not filter: filterFound = True else: filterFound = False # Visible Category if filterFound: self.visible_category_names[category] = tabWidget # 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" or param["type"] == "browse": # create QLineEdit widget = QLineEdit() widget.setText(_(param["value"])) widget.textChanged.connect( functools.partial(self.text_value_changed, widget, param)) if param["type"] == "browse": # Add filesystem browser button 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 audio device list dropdown) if param["setting"] == "playback-audio-device": value_list = [] # Loop through audio devices value_list.append({"name": "Default", "value": ""}) for audio_device in get_app( ).window.preview_thread.player.GetAudioDeviceNames(): value_list.append({ "name": "%s: %s" % (audio_device.type, audio_device.name), "value": audio_device.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" }) # Overwrite value list (for hardware acceleration modes) os_platform = platform.system() if param["setting"] == "hw-decoder": for value_item in list(value_list): v = value_item["value"] # Remove items that are operating system specific if os_platform == "Darwin" and v not in ("0", "5", "7", "2"): value_list.remove(value_item) elif os_platform == "Windows" and v not in ( "0", "3", "4", "7"): value_list.remove(value_item) elif os_platform == "Linux" and v not in ("0", "1", "2", "6", "7"): value_list.remove(value_item) # Remove hardware mode items which cannot decode the example video for value_item in list(value_list): v = value_item["value"] if not self.testHardwareDecode(v, 0) and \ not self.testHardwareDecode(v, 1): value_list.remove(value_item) # Replace %s dropdown values for hardware acceleration if param["setting"] in ("graca_number_en", "graca_number_de"): for card_index in range(0, 3): # Test each graphics card, and only include valid ones if card_index in self.hardware_tests_cards and self.hardware_tests_cards.get( card_index): # Loop through valid modes supported by this card for mode in self.hardware_tests_cards.get( card_index): # Add supported graphics card for each mode (duplicates are okay) if mode == 0: # cpu only value_list.append({ "value": card_index, "name": _("No acceleration"), "icon": mode }) else: # hardware accelerated value_list.append({ "value": card_index, "name": _("Graphics Card %s") % (card_index + 1), "icon": mode }) if os_platform in ["Darwin", "Windows"]: # Disable graphics card selection for Mac and Windows (since libopenshot # only supports device selection on Linux) widget.setEnabled(False) widget.setToolTip( _("Graphics card selection not supported in %s" ) % os_platform) # Add normal values box_index = 0 for value_item in value_list: k = value_item["name"] v = value_item["value"] i = value_item.get("icon", None) # Override icons for certain values # TODO: Find a more elegant way to do this icon = None if k == "Linux VA-API" or i == 1: icon = QIcon(":/hw/hw-accel-vaapi.svg") elif k == "Nvidia NVDEC" or i == 2: icon = QIcon(":/hw/hw-accel-nvdec.svg") elif k == "Linux VDPAU" or i == 6: icon = QIcon(":/hw/hw-accel-vdpau.svg") elif k == "Windows D3D9" or i == 3: icon = QIcon(":/hw/hw-accel-dx.svg") elif k == "Windows D3D11" or i == 4: icon = QIcon(":/hw/hw-accel-dx.svg") elif k == "MacOS" or i == 5: icon = QIcon(":/hw/hw-accel-vtb.svg") elif k == "Intel QSV" or i == 7: icon = QIcon(":/hw/hw-accel-qsv.svg") elif k == "No acceleration" or i == 0: icon = QIcon(":/hw/hw-accel-none.svg") # add dropdown item if icon: widget.setIconSize(QSize(60, 18)) widget.addItem(icon, _(k), v) else: 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 and filterFound): # 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 and filterFound): # Add widget to layout tabWidget.layout().addWidget(label) # Add stretch to bottom of layout tabWidget.layout().addStretch() # Delete all tabs and widgets self.DeleteAllTabs(onlyInVisible=True)