33
33
from classes import info
34
34
from classes .logger import log
35
35
from classes .app import get_app
36
+ from classes .thumbnail import GetThumbPath
36
37
37
38
38
39
class TimelineModel ():
@@ -60,14 +61,22 @@ def update_model(self, files=[], clear=True):
60
61
for file in self .files :
61
62
# Get attributes from file
62
63
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 ))
68
77
else :
69
78
# 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" ) )
71
80
72
81
row = []
73
82
@@ -76,8 +85,7 @@ def update_model(self, files=[], clear=True):
76
85
77
86
# Append thumbnail
78
87
col = QStandardItem ()
79
- col .setIcon (QIcon (thumb_path ))
80
- col .setText ((name [:9 ] + '...' ) if len (name ) > 10 else name )
88
+ col .setIcon (thumb_icon )
81
89
col .setToolTip (filename )
82
90
col .setFlags (Qt .ItemIsSelectable | Qt .ItemIsEnabled | Qt .ItemIsUserCheckable )
83
91
row .append (col )
@@ -89,13 +97,6 @@ def update_model(self, files=[], clear=True):
89
97
col .setFlags (Qt .ItemIsSelectable | Qt .ItemIsEnabled | Qt .ItemIsUserCheckable )
90
98
row .append (col )
91
99
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
-
99
100
# Add row
100
101
self .model .appendRow (row )
101
102
0 commit comments