Skip to content

Commit 23c71d8

Browse files
committed
Use friendly name for files on the timeline (instead of filename). This includes "split" clip names and names modified in the Profile Files dialog. Also, fixing thumbnails on "Add to Timeline" dialog for split clips.
1 parent 86e6f08 commit 23c71d8

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

src/windows/add_to_timeline.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def accept(self):
198198
new_clip["position"] = position
199199
new_clip["layer"] = track_num
200200
new_clip["file_id"] = file.id
201-
new_clip["title"] = filename
201+
new_clip["title"] = file.data.get("name", filename)
202202
new_clip["reader"] = file.data
203203

204204
# Skip any clips that are missing a 'reader' attribute
@@ -453,9 +453,6 @@ def __init__(self, files=None, position=0.0):
453453
# Update data in model
454454
self.treeFiles.timeline_model.update_model(files)
455455

456-
# Refresh view
457-
self.treeFiles.refresh_view()
458-
459456
# Init start position
460457
self.txtStartTime.setValue(position)
461458

src/windows/models/add_to_timeline_model.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from classes import info
3434
from classes.logger import log
3535
from classes.app import get_app
36+
from classes.thumbnail import GetThumbPath
3637

3738

3839
class TimelineModel():
@@ -60,14 +61,22 @@ def update_model(self, files=[], clear=True):
6061
for file in self.files:
6162
# Get attributes from file
6263
path, filename = os.path.split(file.data["path"])
63-
64-
# Get thumbnail path
65-
if (file.data["media_type"] == "video" or file.data["media_type"] == "image"):
66-
# Determine thumb path
67-
thumb_path = os.path.join(info.THUMBNAIL_PATH, "%s.png" % file.data["id"])
64+
media_type = file.data.get("media_type")
65+
66+
# Generate thumbnail for file (if needed)
67+
if media_type in ["video", "image"]:
68+
# Check for start and end attributes (optional)
69+
thumbnail_frame = 1
70+
if 'start' in file.data:
71+
fps = file.data["fps"]
72+
fps_float = float(fps["num"]) / float(fps["den"])
73+
thumbnail_frame = round(float(file.data['start']) * fps_float) + 1
74+
75+
# Get thumb path
76+
thumb_icon = QIcon(GetThumbPath(file.id, thumbnail_frame))
6877
else:
6978
# Audio file
70-
thumb_path = os.path.join(info.PATH, "images", "AudioThumbnail.svg")
79+
thumb_icon = QIcon(os.path.join(info.PATH, "images", "AudioThumbnail.svg"))
7180

7281
row = []
7382

@@ -76,8 +85,7 @@ def update_model(self, files=[], clear=True):
7685

7786
# Append thumbnail
7887
col = QStandardItem()
79-
col.setIcon(QIcon(thumb_path))
80-
col.setText((name[:9] + '...') if len(name) > 10 else name)
88+
col.setIcon(thumb_icon)
8189
col.setToolTip(filename)
8290
col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
8391
row.append(col)
@@ -89,13 +97,6 @@ def update_model(self, files=[], clear=True):
8997
col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
9098
row.append(col)
9199

92-
# Append Path
93-
col = QStandardItem("Path")
94-
col.setData(path, Qt.DisplayRole)
95-
col.setText(path)
96-
col.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsUserCheckable)
97-
row.append(col)
98-
99100
# Add row
100101
self.model.appendRow(row)
101102

src/windows/views/timeline.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3094,7 +3094,7 @@ def callback(self, data, callback_data):
30943094
# Append missing attributes to Clip JSON
30953095
new_clip = json.loads(c.Json())
30963096
new_clip["file_id"] = file.id
3097-
new_clip["title"] = filename
3097+
new_clip["title"] = file.data.get("name", filename)
30983098
new_clip["reader"] = file.data
30993099

31003100
# Skip any clips that are missing a 'reader' attribute

0 commit comments

Comments
 (0)