Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def actionUndo_trigger(self, event):
log.info('actionUndo_trigger')
app = get_app()
app.updates.undo()
# Update the preview
self.refreshFrameSignal.emit()
b = openshot.Keyframe()
b.AddPoint(1, 1.0, openshot.BEZIER)
b.AddPoint(round(duration * fps_float) + 1, -1.0, openshot.BEZIER)
brightness = json.loads(b.Json())
# Only include the basic properties (performance boost)
if only_basic_props:
existing_item.data = {}
existing_item.data["id"] = transition_data["id"]
existing_item.data["layer"] = transition_data["layer"]
existing_item.data["position"] = transition_data["position"]
existing_item.data["start"] = transition_data["start"]
existing_item.data["end"] = transition_data["end"]
log.info('transition start: %s' % transition_data["start"])
log.info('transition end: %s' % transition_data["end"])
if brightness:
existing_item.data["brightness"] = brightness
if contrast:
existing_item.data["contrast"] = contrast
# Save transition
existing_item.save()
# Update the preview and reselct current frame in properties
get_app().window.refreshFrameSignal.emit()
get_app().window.propertyTableView.select_frame(self.window.preview_thread.player.Position())
def refreshFrame(self):
""" Refresh a certain frame """
log.info("refreshFrame")
# Always load back in the timeline reader
self.parent.LoadFileSignal.emit('')
# Mark frame number for processing (if parent is done initializing)
self.Seek(self.player.Position())
log.info("self.player.Position(): %s" % self.player.Position())
def actionRemoveTrack_trigger(self, event):
log.info('actionRemoveTrack_trigger')
# Get translation function
_ = get_app()._tr
track_id = self.selected_tracks[0]
max_track_number = len(get_app().project.get(["layers"]))
# Get details of selected track
selected_track = Track.get(id=track_id)
selected_track_number = int(selected_track.data["number"])
# Don't allow user to delete final track
if max_track_number == 1:
# Show error and do nothing
QMessageBox.warning(self, _("Error Removing Track"), _("You must keep at least 1 track"))
return
def actionAnimatedTitle_trigger(self, event):
# show dialog
from windows.animated_title import AnimatedTitle
win = AnimatedTitle()
# Run the dialog event loop - blocking interaction on this window during that time
result = win.exec_()
if result == QDialog.Accepted:
log.info('animated title add confirmed')
else:
log.info('animated title add cancelled')
def modified_preset(self):
""" Modified a preset previously created """
log.info('A preset has been modified')
windo = Presets()
windo.exec_()
def updateProperty(self, id, frame_number, property_key, new_value):
"""Update a keyframe property to a new value, adding or updating keyframes as needed"""
found_point = False
clip_updated = False
c = Clip.get(id=id)
if not c:
# No clip found
return
for point in c.data[property_key]["Points"]:
log.info("looping points: co.X = %s" % point["co"]["X"])
if point["co"]["X"] == frame_number:
found_point = True
clip_updated = True
point["interpolation"] = openshot.BEZIER
point["co"]["Y"] = float(new_value)
if not found_point and new_value != None:
clip_updated = True
log.info("Created new point at X=%s" % frame_number)
c.data[property_key]["Points"].append({'co': {'X': frame_number, 'Y': new_value}, 'interpolation': openshot.BEZIER})
# Reduce # of clip properties we are saving (performance boost)
c.data = {property_key: c.data.get(property_key)}
# Save changes
def actionTranslate_trigger(self, event):
try:
webbrowser.open("https://translations.launchpad.net/openshot/2.0")
log.info("Open the Translate launchpad web page with success")
except:
QMessageBox.information(self, "Error !", "Unable to open the Translation web page")
def load_export_command(self):
"""" Display Export FFmpeg Command Pesonalized """
log.info('FFmpeg Command Personlized screen has been called')
windo = Presets()
windo.exec_()
def actionRemoveEffect_trigger(self, event):
log.info('actionRemoveEffect_trigger')
# Loop through selected clips
for effect_id in deepcopy(self.selected_effects):
log.info("effect id: %s" % effect_id)
# Find matching file
clips = Clip.filter()
found_effect = None
for c in clips:
found_effect = False
log.info("c.data[effects]: %s" % c.data["effects"])
for effect in c.data["effects"]:
if effect["id"] == effect_id:
found_effect = effect
break
if found_effect:
# Remove found effect from clip data and save clip
c.data["effects"].remove(found_effect)