29
29
30
30
import os
31
31
import shutil
32
- import sys
33
32
import webbrowser
34
33
from copy import deepcopy
35
34
from time import sleep
46
45
QMessageBox , QDialog , QFileDialog , QInputDialog ,
47
46
QAction , QActionGroup , QSizePolicy ,
48
47
QStatusBar , QToolBar , QToolButton ,
49
- QLineEdit , QSlider , QLabel , QComboBox , QTextEdit
48
+ QLineEdit , QComboBox , QTextEdit
50
49
)
51
50
52
51
from classes import exceptions , info , settings , qt_types , ui_util , updates
53
52
from classes .app import get_app
54
- from classes .conversion import zoomToSeconds , secondsToZoom
55
53
from classes .exporters .edl import export_edl
56
54
from classes .exporters .final_cut_pro import export_xml
57
55
from classes .importers .edl import import_edl
@@ -109,6 +107,13 @@ class MainWindow(updates.UpdateWatcher, QMainWindow):
109
107
FileUpdated = pyqtSignal (str )
110
108
CaptionTextUpdated = pyqtSignal (str , object )
111
109
CaptionTextLoaded = pyqtSignal (str , object )
110
+ TimelineZoom = pyqtSignal (float ) # Signal to zoom into timeline from zoom slider
111
+ TimelineScrolled = pyqtSignal (list ) # Scrollbar changed signal from timeline
112
+ TimelineScroll = pyqtSignal (float ) # Signal to force scroll timeline to specific point
113
+ TimelineCenter = pyqtSignal () # Signal to force center scroll on playhead
114
+ SelectionAdded = pyqtSignal (str , str , bool ) # Signal to add a selection
115
+ SelectionRemoved = pyqtSignal (str , str ) # Signal to remove a selection
116
+ SelectionChanged = pyqtSignal () # Signal after selections have been changed (added/removed)
112
117
113
118
# Docks are closable, movable and floatable
114
119
docks_frozen = False
@@ -1869,10 +1874,10 @@ def actionRemoveMarker_trigger(self):
1869
1874
m .delete ()
1870
1875
1871
1876
def actionTimelineZoomIn_trigger (self ):
1872
- self .sliderZoom . setValue ( self . sliderZoom . value () - self . sliderZoom . singleStep () )
1877
+ self .sliderZoomWidget . zoomIn ( )
1873
1878
1874
1879
def actionTimelineZoomOut_trigger (self ):
1875
- self .sliderZoom . setValue ( self . sliderZoom . value () + self . sliderZoom . singleStep () )
1880
+ self .sliderZoomWidget . zoomOut ( )
1876
1881
1877
1882
def actionFullscreen_trigger (self ):
1878
1883
# Toggle fullscreen state (current state mask XOR WindowFullScreen)
@@ -2287,6 +2292,9 @@ def addSelection(self, item_id, item_type, clear_existing=False):
2287
2292
self .show_property_type = item_type
2288
2293
self .show_property_timer .start ()
2289
2294
2295
+ # Notify UI that selection has been potentially changed
2296
+ self .selection_timer .start ()
2297
+
2290
2298
# Remove from the selected items
2291
2299
def removeSelection (self , item_id , item_type ):
2292
2300
# Remove existing selection (if any)
@@ -2318,8 +2326,14 @@ def removeSelection(self, item_id, item_type):
2318
2326
self .show_property_id = self .selected_effects [0 ]
2319
2327
self .show_property_type = item_type
2320
2328
2321
- # Change selected item in properties view
2329
+ # Change selected item
2322
2330
self .show_property_timer .start ()
2331
+ self .selection_timer .start ()
2332
+
2333
+ def emit_selection_signal (self ):
2334
+ """Emit a signal for selection changed. Callback for selection timer."""
2335
+ # Notify UI that selection has been potentially changed
2336
+ self .SelectionChanged .emit ()
2323
2337
2324
2338
def selected_files (self ):
2325
2339
""" Return a list of File objects for the Project Files dock's selection """
@@ -2550,35 +2564,24 @@ def setup_toolbars(self):
2550
2564
2551
2565
# Hook up caption editor signal
2552
2566
self .captionTextEdit .textChanged .connect (self .captionTextEdit_TextChanged )
2553
- self .caption_save_timer = QTimer ()
2567
+ self .caption_save_timer = QTimer (self )
2554
2568
self .caption_save_timer .setInterval (100 )
2555
2569
self .caption_save_timer .setSingleShot (True )
2556
2570
self .caption_save_timer .timeout .connect (self .caption_editor_save )
2557
2571
self .CaptionTextLoaded .connect (self .caption_editor_load )
2558
2572
self .caption_model_row = None
2559
2573
2560
2574
# Get project's initial zoom value
2561
- initial_scale = get_app ().project .get ("scale" ) or 15
2562
- # Round non-exponential scale down to next lowest power of 2
2563
- initial_zoom = secondsToZoom (initial_scale )
2564
-
2565
- # Setup Zoom slider
2566
- self .sliderZoom = QSlider (Qt .Horizontal , self )
2567
- self .sliderZoom .setPageStep (1 )
2568
- self .sliderZoom .setRange (0 , 30 )
2569
- self .sliderZoom .setValue (initial_zoom )
2570
- self .sliderZoom .setInvertedControls (True )
2571
- self .sliderZoom .resize (100 , 16 )
2572
-
2573
- self .zoomScaleLabel = QLabel (
2574
- _ ("{} seconds" ).format (zoomToSeconds (self .sliderZoom .value ()))
2575
- )
2575
+ initial_scale = get_app ().project .get ("scale" ) or 15.0
2576
+
2577
+ # Setup Zoom Slider widget
2578
+ from windows .views .zoom_slider import ZoomSlider
2579
+ self .sliderZoomWidget = ZoomSlider (self )
2580
+ self .sliderZoomWidget .setMinimumSize (200 , 20 )
2581
+ self .sliderZoomWidget .setZoomFactor (initial_scale )
2576
2582
2577
2583
# add zoom widgets
2578
- self .timelineToolbar .addAction (self .actionTimelineZoomIn )
2579
- self .timelineToolbar .addWidget (self .sliderZoom )
2580
- self .timelineToolbar .addAction (self .actionTimelineZoomOut )
2581
- self .timelineToolbar .addWidget (self .zoomScaleLabel )
2584
+ self .timelineToolbar .addWidget (self .sliderZoomWidget )
2582
2585
2583
2586
# Add timeline toolbar to web frame
2584
2587
self .frameWeb .addWidget (self .timelineToolbar )
@@ -2866,11 +2869,19 @@ def __init__(self, *args, mode=None):
2866
2869
# to update the property model hundreds of times)
2867
2870
self .show_property_id = None
2868
2871
self .show_property_type = None
2869
- self .show_property_timer = QTimer ()
2872
+ self .show_property_timer = QTimer (self )
2870
2873
self .show_property_timer .setInterval (100 )
2871
2874
self .show_property_timer .setSingleShot (True )
2872
2875
self .show_property_timer .timeout .connect (self .show_property_timeout )
2873
2876
2877
+ # Selection timer
2878
+ # Timer to use a delay before emitting selection signal (to prevent a mass selection from trying
2879
+ # to update the zoom slider widget hundreds of times)
2880
+ self .selection_timer = QTimer (self )
2881
+ self .selection_timer .setInterval (100 )
2882
+ self .selection_timer .setSingleShot (True )
2883
+ self .selection_timer .timeout .connect (self .emit_selection_signal )
2884
+
2874
2885
# Setup video preview QWidget
2875
2886
self .videoPreview = VideoWidget ()
2876
2887
self .tabVideo .layout ().insertWidget (0 , self .videoPreview )
@@ -2886,6 +2897,7 @@ def __init__(self, *args, mode=None):
2886
2897
self .preview_parent = PreviewParent ()
2887
2898
self .preview_parent .Init (self , self .timeline_sync .timeline , self .videoPreview )
2888
2899
self .preview_thread = self .preview_parent .worker
2900
+ self .sliderZoomWidget .connect_playback ()
2889
2901
2890
2902
# Set pause callback
2891
2903
self .PauseSignal .connect (self .handlePausedVideo )
@@ -2956,6 +2968,10 @@ def __init__(self, *args, mode=None):
2956
2968
# Connect OpenProject Signal
2957
2969
self .OpenProjectSignal .connect (self .open_project )
2958
2970
2971
+ # Connect Selection signals
2972
+ self .SelectionAdded .connect (self .addSelection )
2973
+ self .SelectionRemoved .connect (self .removeSelection )
2974
+
2959
2975
# Show window
2960
2976
if self .mode != "unittest" :
2961
2977
self .show ()
0 commit comments