Skip to content

Commit

Permalink
Allow clearing the "Parent" and "Child Clip ID" properties of a clip …
Browse files Browse the repository at this point in the history
…/ effect, and allow setting of the initial value to work correctly.
  • Loading branch information
jonoomph committed Apr 13, 2023
1 parent d37894c commit bb85b5b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
6 changes: 4 additions & 2 deletions src/windows/models/properties_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,11 @@ def value_updated(self, item, interpolation=-1, value=None, interpolation_detail
clip_id, item_type = item.data()

# Get value (if any)
if item.text():
if item.text() or value:
# Set and format value based on property type
if value is not None:
if value == "None":
new_value = ""
elif value is not None:
# Override value
new_value = value
elif property_type == "string":
Expand Down
2 changes: 1 addition & 1 deletion src/windows/video_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def paintEvent(self, event, *args):

# Set scale as STRETCH if the clip is attached to an object
if (
raw_properties.get('parentObjectId').get('memo') != 'None'
raw_properties.get('parentObjectId').get('memo') != ''
and len(raw_properties.get('parentObjectId').get('memo')) > 0
):
scale = openshot.SCALE_STRETCH
Expand Down
24 changes: 6 additions & 18 deletions src/windows/views/properties_tableview.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,7 @@ def contextMenuEvent(self, event):
if (clip_path == clip_instance_path):
# Generate the clip icon to show in the selection menu
clip_instance_icon = clip_index.data(Qt.DecorationRole)
effect_choices = [{"name": "None",
"value": "None",
"selected": False,
"icon": QIcon()}]
effect_choices = []
# Iterate through clip's effects
for effect_data in clip_instance_data["effects"]:
# Make sure the user can only set a parent effect of the same type as this effect
Expand Down Expand Up @@ -528,12 +525,12 @@ def contextMenuEvent(self, event):

# Handle property to set the Tracked Object's child clip
if property_key == "child_clip_id" and not self.choices:
clip_choices = [{
self.choices.append({
"name": "None",
"value": "None",
"selected": False,
"icon": QIcon()
}]
})
# Instantiate the timeline
timeline_instance = get_app().window.timeline_sync.timeline
current_effect = timeline_instance.GetClipEffect(clip_id)
Expand Down Expand Up @@ -565,18 +562,8 @@ def contextMenuEvent(self, event):
# Handle clip attach options
if property_key == "parentObjectId" and not self.choices:
# Add all Clips as choices - initialize with None
tracked_choices = [{
"name": "None",
"value": "None",
"selected": False,
"icon": QIcon()
}]
clip_choices = [{
"name": "None",
"value": "None",
"selected": False,
"icon": QIcon()
}]
tracked_choices = []
clip_choices = []
# Instantiate the timeline
timeline_instance = get_app().window.timeline_sync.timeline
# Loop through timeline's clips
Expand Down Expand Up @@ -630,6 +617,7 @@ def contextMenuEvent(self, event):
"value": tracked_objects,
"selected": False,
"icon": clip_instance_icon})
self.choices.append({"name": _("None"), "value": "None", "selected": False, "icon": None})
self.choices.append({"name": _("Tracked Objects"), "value": tracked_choices, "selected": False, "icon": None})
self.choices.append({"name": _("Clips"), "value": clip_choices, "selected": False, "icon": None})

Expand Down

0 comments on commit bb85b5b

Please sign in to comment.