177
177
) from ex
178
178
179
179
180
- class TimelineWebView (WebViewClass , updates .UpdateInterface ):
180
+ class TimelineWebView (updates .UpdateInterface , WebViewClass ):
181
181
""" A Web(Engine)View QWidget used to load the Timeline """
182
182
183
183
# Path to html file
@@ -191,11 +191,11 @@ def page_ready(self):
191
191
@pyqtSlot (result = str )
192
192
def get_thumb_address (self ):
193
193
"""Return the thumbnail HTTP server address"""
194
- thumb_server_details = get_app () .window .http_server_thread .server_address
194
+ thumb_server_details = self .window .http_server_thread .server_address
195
195
while not thumb_server_details :
196
196
log .info ('No HTTP thumbnail server found yet... keep waiting...' )
197
197
time .sleep (0.25 )
198
- thumb_server_details = get_app () .window .http_server_thread .server_address
198
+ thumb_server_details = self .window .http_server_thread .server_address
199
199
200
200
thumb_address = "http://%s:%s/thumbnails/" % (thumb_server_details [0 ], thumb_server_details [1 ])
201
201
return thumb_address
@@ -226,7 +226,7 @@ def changed(self, action):
226
226
if action .type == "load" :
227
227
# Set the scale again (to project setting)
228
228
initial_scale = get_app ().project .get ("scale" ) or 15
229
- get_app () .window .sliderZoom .setValue (secondsToZoom (initial_scale ))
229
+ self .window .sliderZoom .setValue (secondsToZoom (initial_scale ))
230
230
231
231
# The setValue() above doesn't trigger update_zoom when a project file is
232
232
# loaded on the command line (too early?), so also call the JS directly
@@ -275,8 +275,8 @@ def update_clip_data(self, clip_json, only_basic_props=True, ignore_reader=False
275
275
276
276
# Update the preview and reselect current frame in properties
277
277
if not ignore_refresh :
278
- get_app () .window .refreshFrameSignal .emit ()
279
- get_app () .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
278
+ self .window .refreshFrameSignal .emit ()
279
+ self .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
280
280
281
281
# Add missing transition
282
282
@pyqtSlot (str )
@@ -389,8 +389,8 @@ def update_transition_data(self, transition_json, only_basic_props=True, ignore_
389
389
390
390
# Update the preview and reselct current frame in properties
391
391
if not ignore_refresh :
392
- get_app () .window .refreshFrameSignal .emit ()
393
- get_app () .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
392
+ self .window .refreshFrameSignal .emit ()
393
+ self .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
394
394
395
395
# Prevent default context menu, and ignore, so that javascript can intercept
396
396
def contextMenuEvent (self , event ):
@@ -954,10 +954,10 @@ def Transform_Triggered(self, action, clip_ids):
954
954
# Emit signal to transform this clip (for the 1st clip id)
955
955
if clip_ids :
956
956
# Transform first clip in list
957
- get_app () .window .TransformSignal .emit (clip_ids [0 ])
957
+ self .window .TransformSignal .emit (clip_ids [0 ])
958
958
else :
959
959
# Clear transform
960
- get_app () .window .TransformSignal .emit ("" )
960
+ self .window .TransformSignal .emit ("" )
961
961
962
962
def Show_Waveform_Triggered (self , clip_ids ):
963
963
"""Show a waveform for the selected clip"""
@@ -974,7 +974,7 @@ def Show_Waveform_Triggered(self, clip_ids):
974
974
file_path = clip .data ["reader" ]["path" ]
975
975
976
976
# Find actual clip object from libopenshot
977
- c = get_app () .window .timeline_sync .timeline .GetClip (clip_id )
977
+ c = self .window .timeline_sync .timeline .GetClip (clip_id )
978
978
if c and c .Reader () and not c .Reader ().info .has_single_image :
979
979
# Find frame 1 channel_filter property
980
980
channel_filter = c .channel_filter .GetInt (1 )
@@ -2268,15 +2268,15 @@ def Time_Triggered(self, action, clip_ids, speed="1X", playhead_position=0.0):
2268
2268
del clip .data ["time" ]["Points" ][- 1 ]
2269
2269
2270
2270
# Find actual clip object from libopenshot
2271
- c = get_app () .window .timeline_sync .timeline .GetClip (clip_id )
2271
+ c = self .window .timeline_sync .timeline .GetClip (clip_id )
2272
2272
if c :
2273
2273
# Look up correct position from time curve
2274
2274
start_animation_frames_value = c .time .GetLong (start_animation_frames )
2275
2275
2276
2276
# Do we already have a volume curve? Look up intersecting frame # from volume curve
2277
2277
if len (clip .data ["volume" ]["Points" ]) > 1 :
2278
2278
# Find actual clip object from libopenshot
2279
- c = get_app () .window .timeline_sync .timeline .GetClip (clip_id )
2279
+ c = self .window .timeline_sync .timeline .GetClip (clip_id )
2280
2280
if c :
2281
2281
# Look up correct volume from time curve
2282
2282
start_volume_value = c .volume .GetValue (start_animation_frames )
@@ -3025,7 +3025,7 @@ def dropEvent(self, event):
3025
3025
3026
3026
elif self .item_type == "os_drop" :
3027
3027
# Add new files to project
3028
- get_app () .window .filesView .dropEvent (event )
3028
+ self .window .filesView .dropEvent (event )
3029
3029
3030
3030
# Add clips for each file dropped
3031
3031
for uri in event .mimeData ().urls ():
@@ -3045,8 +3045,8 @@ def dropEvent(self, event):
3045
3045
self .item_id = None
3046
3046
3047
3047
# Update the preview and reselct current frame in properties
3048
- get_app () .window .refreshFrameSignal .emit ()
3049
- get_app () .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
3048
+ self .window .refreshFrameSignal .emit ()
3049
+ self .window .propertyTableView .select_frame (self .window .preview_thread .player .Position ())
3050
3050
3051
3051
def dragLeaveEvent (self , event ):
3052
3052
"""A drag is in-progress and the user moves mouse outside of timeline"""
@@ -3056,7 +3056,7 @@ def dragLeaveEvent(self, event):
3056
3056
event .accept ()
3057
3057
3058
3058
# Clear selected clips
3059
- get_app () .window .removeSelection (self .item_id , self .item_type )
3059
+ self .window .removeSelection (self .item_id , self .item_type )
3060
3060
3061
3061
if self .item_type == "clip" :
3062
3062
# Delete dragging clip
@@ -3099,10 +3099,10 @@ def render_cache_json(self):
3099
3099
3100
3100
# Get final cache object from timeline
3101
3101
try :
3102
- cache_object = get_app () .window .timeline_sync .timeline .GetCache ()
3102
+ cache_object = self .window .timeline_sync .timeline .GetCache ()
3103
3103
if cache_object and cache_object .Count () > 0 :
3104
3104
# Get the JSON from the cache object (i.e. which frames are cached)
3105
- cache_json = get_app () .window .timeline_sync .timeline .GetCache ().Json ()
3105
+ cache_json = self .window .timeline_sync .timeline .GetCache ().Json ()
3106
3106
cache_dict = json .loads (cache_json )
3107
3107
cache_version = cache_dict ["version" ]
3108
3108
@@ -3118,28 +3118,29 @@ def __init__(self, window):
3118
3118
super ().__init__ ()
3119
3119
self .setObjectName ("TimelineWebView" )
3120
3120
3121
+ app = get_app ()
3121
3122
self .window = window
3122
3123
self .setAcceptDrops (True )
3123
3124
self .last_position_frames = None
3124
3125
3125
3126
# Get settings & logger
3126
- self .settings_obj = settings . get_settings ()
3127
+ self .settings_obj = get_settings ()
3127
3128
self .log_fn = log .log
3128
3129
3129
3130
# Add self as listener to project data updates (used to update the timeline)
3130
- get_app () .updates .add_listener (self )
3131
+ app .updates .add_listener (self )
3131
3132
3132
3133
# Connect zoom functionality
3133
3134
window .sliderZoom .valueChanged .connect (self .update_zoom )
3134
3135
3135
3136
# Connect waveform generation signal
3136
- get_app (). window .WaveformReady .connect (self .Waveform_Ready )
3137
+ window .WaveformReady .connect (self .Waveform_Ready )
3137
3138
3138
3139
# Local audio waveform cache
3139
3140
self .waveform_cache = {}
3140
3141
3141
3142
# Connect update thumbnail signal
3142
- get_app (). window .ThumbnailUpdated .connect (self .Thumbnail_Updated )
3143
+ window .ThumbnailUpdated .connect (self .Thumbnail_Updated )
3143
3144
3144
3145
# Copy clipboard
3145
3146
self .copy_clipboard = {}
@@ -3162,5 +3163,8 @@ def __init__(self, window):
3162
3163
self .cache_renderer .setInterval (500 )
3163
3164
self .cache_renderer .timeout .connect (self .render_cache_json )
3164
3165
3166
+ # Connect shutdown signals
3167
+ app .aboutToQuit .connect (self .redraw_audio_timer .stop )
3168
+ app .aboutToQuit .connect (self .cache_renderer .stop )
3165
3169
# Delay the start of cache rendering
3166
3170
QTimer .singleShot (1500 , self .cache_renderer .start )
0 commit comments