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()
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")
def checkbox_metrics_callback(self, state): """ Callback for error and anonymous usage checkbox""" s = get_app().get_settings() if state == Qt.Checked: # Enabling metrics sending s.set("send_metrics", True) sentry.init_tracing() # Opt-in for metrics tracking track_metric_screen("metrics-opt-in") else: # Opt-out for metrics tracking track_metric_screen("metrics-opt-out") sentry.disable_tracing() # Disable metric sending s.set("send_metrics", False)
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 = get_app().get_settings() # Dynamically load tabs from settings data self.settings_data = self.s.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()
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)
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 & 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 © %(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")
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 translation object self.app = get_app() _ = self.app._tr # Get settings self.settings = self.app.get_settings() # 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) # Find display track number all_tracks = get_app().project.get("layers") display_count = len(all_tracks) for track in reversed(sorted(all_tracks, key=itemgetter('number'))): # Add to dropdown track_name = track.get('label') or _("Track %s") % display_count self.cmbTrack.addItem(track_name, track.get('number')) display_count -= 1 # 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: dir = group["dir"] files = group["files"] for filename in sorted(files): path = os.path.join(dir, filename) fileBaseName = os.path.splitext(filename)[0] # 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()
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 _ = get_app()._tr # Pause playback (to prevent crash since we are fixing to change the timeline's max size) get_app().window.actionPlay_trigger(None, force="pause") # Track metrics track_metric_screen("profile-screen") # Keep track of starting selection self.initial_index = 0 # 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): profile_path = os.path.join(profile_folder, file) try: # Load Profile profile = openshot.Profile(profile_path) # Add description of Profile to list profile_name = "%s (%sx%s)" % (profile.info.description, profile.info.width, profile.info.height) self.profile_names.append(profile_name) self.profile_paths[profile_name] = profile_path except RuntimeError as e: # This exception occurs when there's a problem parsing # the Profile file - display a message and continue log.error("Failed to parse file '%s' as a profile: %s" % (profile_path, e)) # Sort list self.profile_names.sort() # Loop through sorted profiles for box_index, profile_name in enumerate(self.profile_names): # Add to dropdown self.cboProfile.addItem(profile_name, self.profile_paths[profile_name]) # Set default (if it matches the project) if get_app().project.get(['profile']) in profile_name: self.initial_index = box_index # Connect signals self.cboProfile.currentIndexChanged.connect( self.dropdown_index_changed) self.cboProfile.activated.connect(self.dropdown_activated) # Set current item (from project) self.cboProfile.setCurrentIndex(self.initial_index)
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 filename = os.path.basename(self.file.data["path"]) file_extension = os.path.splitext(filename)[1] 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(self.file.data["path"]) 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(file_extension.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=2)) # 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)