Skip to content

Commit f26ae7c

Browse files
committed
Teach Prev/Next Marker to jump to 0, end
- Prev Marker will always jump to the first frame on the Timeline - If nothing is selected, Next Marker will also jump to the very end
1 parent b797990 commit f26ae7c

File tree

1 file changed

+58
-51
lines changed

1 file changed

+58
-51
lines changed

src/windows/main_window.py

+58-51
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@
4747
from classes.app import get_app
4848
from classes.logger import log
4949
from classes.timeline import TimelineSync
50-
from classes.query import File, Clip, Transition, Marker, Track
51-
from classes.metrics import *
52-
from classes.version import *
50+
from classes.query import Clip, Transition, Marker, Track
51+
from classes.metrics import (
52+
track_metric_session, track_metric_screen,
53+
track_metric_error, track_exception_stacktrace,
54+
)
55+
from classes.version import get_current_Version
5356
from classes.conversion import zoomToSeconds, secondsToZoom
5457
from classes.thumbnail import httpThumbnailServerThread
5558
from windows.models.files_model import FilesModel
@@ -756,7 +759,7 @@ def promptImageSequence(self, filename=None):
756759
else:
757760
return False
758761

759-
def actionAdd_to_Timeline_trigger(self, event):
762+
def actionAdd_to_Timeline_trigger(self, checked=False):
760763
# Loop through selected files
761764
files = self.selected_files()
762765

@@ -779,7 +782,7 @@ def actionAdd_to_Timeline_trigger(self, event):
779782
else:
780783
log.info('canceled')
781784

782-
def actionExportVideo_trigger(self, event):
785+
def actionExportVideo_trigger(self, checked=True):
783786
# show window
784787
from windows.export import Export
785788
win = Export()
@@ -790,37 +793,37 @@ def actionExportVideo_trigger(self, event):
790793
else:
791794
log.info('Export Video add cancelled')
792795

793-
def actionExportEDL_trigger(self, event):
796+
def actionExportEDL_trigger(self, checked=True):
794797
"""Export EDL File"""
795798
export_edl()
796799

797-
def actionExportFCPXML_trigger(self, event):
800+
def actionExportFCPXML_trigger(self, checked=True):
798801
"""Export XML (Final Cut Pro) File"""
799802
export_xml()
800803

801-
def actionImportEDL_trigger(self, event):
804+
def actionImportEDL_trigger(self, checked=True):
802805
"""Import EDL File"""
803806
import_edl()
804807

805-
def actionImportFCPXML_trigger(self, event):
808+
def actionImportFCPXML_trigger(self, checked=True):
806809
"""Import XML (Final Cut Pro) File"""
807810
import_xml()
808811

809-
def actionUndo_trigger(self, event):
812+
def actionUndo_trigger(self, checked=True):
810813
log.info('actionUndo_trigger')
811814
get_app().updates.undo()
812815

813816
# Update the preview
814817
self.refreshFrameSignal.emit()
815818

816-
def actionRedo_trigger(self, event):
819+
def actionRedo_trigger(self, checked=True):
817820
log.info('actionRedo_trigger')
818821
get_app().updates.redo()
819822

820823
# Update the preview
821824
self.refreshFrameSignal.emit()
822825

823-
def actionPreferences_trigger(self, event):
826+
def actionPreferences_trigger(self, checked=True):
824827
# Stop preview thread
825828
self.SpeedSignal.emit(0)
826829
ui_util.setup_icon(self, self.actionPlay, "actionPlay", "media-playback-start")
@@ -846,74 +849,74 @@ def actionPreferences_trigger(self, event):
846849
# Restore normal cursor
847850
get_app().restoreOverrideCursor()
848851

849-
def actionFilesShowAll_trigger(self, event):
852+
def actionFilesShowAll_trigger(self, checked=True):
850853
self.refreshFilesSignal.emit()
851854

852-
def actionFilesShowVideo_trigger(self, event):
855+
def actionFilesShowVideo_trigger(self, checked=True):
853856
self.refreshFilesSignal.emit()
854857

855-
def actionFilesShowAudio_trigger(self, event):
858+
def actionFilesShowAudio_trigger(self, checked=True):
856859
self.refreshFilesSignal.emit()
857860

858-
def actionFilesShowImage_trigger(self, event):
861+
def actionFilesShowImage_trigger(self, checked=True):
859862
self.refreshFilesSignal.emit()
860863

861-
def actionTransitionsShowAll_trigger(self, event):
864+
def actionTransitionsShowAll_trigger(self, checked=True):
862865
self.refreshTransitionsSignal.emit()
863866

864-
def actionTransitionsShowCommon_trigger(self, event):
867+
def actionTransitionsShowCommon_trigger(self, checked=True):
865868
self.refreshTransitionsSignal.emit()
866869

867-
def actionHelpContents_trigger(self, event):
870+
def actionHelpContents_trigger(self, checked=True):
868871
try:
869872
webbrowser.open("https://www.openshot.org/%suser-guide/?app-menu" % info.website_language(), new=1)
870873
except Exception as ex:
871874
QMessageBox.information(self, "Error !", "Unable to open the online help")
872875
log.error("Unable to open the Help Contents: {}".format(str(ex)))
873876

874-
def actionAbout_trigger(self, event):
877+
def actionAbout_trigger(self, checked=True):
875878
"""Show about dialog"""
876879
from windows.about import About
877880
win = About()
878881
# Run the dialog event loop - blocking interaction on this window during this time
879882
win.exec_()
880883

881-
def actionReportBug_trigger(self, event):
884+
def actionReportBug_trigger(self, checked=True):
882885
try:
883886
webbrowser.open("https://www.openshot.org/%sissues/new/?app-menu" % info.website_language(), new=1)
884887
except Exception as ex:
885888
QMessageBox.information(self, "Error !", "Unable to open the Bug Report GitHub Issues web page")
886889
log.error("Unable to open the Bug Report page: {}".format(str(ex)))
887890

888-
def actionAskQuestion_trigger(self, event):
891+
def actionAskQuestion_trigger(self, checked=True):
889892
try:
890893
webbrowser.open("https://www.reddit.com/r/OpenShot/", new=1)
891894
except Exception as ex:
892895
QMessageBox.information(self, "Error !", "Unable to open the official OpenShot subreddit web page")
893896
log.error("Unable to open the subreddit page: {}".format(str(ex)))
894897

895-
def actionTranslate_trigger(self, event):
898+
def actionTranslate_trigger(self, checked=True):
896899
try:
897900
webbrowser.open("https://translations.launchpad.net/openshot/2.0", new=1)
898901
except Exception as ex:
899902
QMessageBox.information(self, "Error !", "Unable to open the Translation web page")
900903
log.error("Unable to open the translation page: {}".format(str(ex)))
901904

902-
def actionDonate_trigger(self, event):
905+
def actionDonate_trigger(self, checked=True):
903906
try:
904907
webbrowser.open("https://www.openshot.org/%sdonate/?app-menu" % info.website_language(), new=1)
905908
except Exception as ex:
906909
QMessageBox.information(self, "Error !", "Unable to open the Donate web page")
907910
log.error("Unable to open the donation page: {}".format(str(ex)))
908911

909-
def actionUpdate_trigger(self, event):
912+
def actionUpdate_trigger(self, checked=True):
910913
try:
911914
webbrowser.open("https://www.openshot.org/%sdownload/?app-toolbar" % info.website_language(), new=1)
912915
except Exception as ex:
913916
QMessageBox.information(self, "Error !", "Unable to open the Download web page")
914917
log.error("Unable to open the download page: {}".format(str(ex)))
915918

916-
def actionPlay_trigger(self, event, force=None):
919+
def actionPlay_trigger(self, checked, force=None):
917920

918921
# Determine max frame (based on clips)
919922
timeline_length = 0.0
@@ -941,7 +944,7 @@ def actionPlay_trigger(self, event, force=None):
941944
ui_util.setup_icon(self, self.actionPlay, "actionPlay") # to default
942945
self.PauseSignal.emit()
943946

944-
def actionPreview_File_trigger(self, event):
947+
def actionPreview_File_trigger(self, checked=True):
945948
""" Preview the selected media file """
946949
log.info('actionPreview_File_trigger')
947950

@@ -979,7 +982,7 @@ def SetPlayheadFollow(self, enable_follow):
979982
""" Enable / Disable follow mode """
980983
self.timeline.SetPlayheadFollow(enable_follow)
981984

982-
def actionFastForward_trigger(self, event):
985+
def actionFastForward_trigger(self, checked=True):
983986

984987
# Get the video player object
985988
player = self.preview_thread.player
@@ -992,7 +995,7 @@ def actionFastForward_trigger(self, event):
992995
if player.Mode() == openshot.PLAYBACK_PAUSED:
993996
self.actionPlay.trigger()
994997

995-
def actionRewind_trigger(self, event):
998+
def actionRewind_trigger(self, checked=True):
996999

9971000
# Get the video player object
9981001
player = self.preview_thread.player
@@ -1005,13 +1008,13 @@ def actionRewind_trigger(self, event):
10051008
if player.Mode() == openshot.PLAYBACK_PAUSED:
10061009
self.actionPlay.trigger()
10071010

1008-
def actionJumpStart_trigger(self, event):
1011+
def actionJumpStart_trigger(self, checked=True):
10091012
log.info("actionJumpStart_trigger")
10101013

10111014
# Seek to the 1st frame
10121015
self.SeekSignal.emit(1)
10131016

1014-
def actionJumpEnd_trigger(self, event):
1017+
def actionJumpEnd_trigger(self, checked=True):
10151018
log.info("actionJumpEnd_trigger")
10161019

10171020
# Determine max frame (based on clips)
@@ -1030,7 +1033,7 @@ def actionJumpEnd_trigger(self, event):
10301033
# Seek to the 1st frame
10311034
self.SeekSignal.emit(timeline_length_int)
10321035

1033-
def actionSaveFrame_trigger(self, event):
1036+
def actionSaveFrame_trigger(self, checked=True):
10341037
log.info("actionSaveFrame_trigger")
10351038

10361039
# Translate object
@@ -1185,7 +1188,7 @@ def renumber_all_layers(self, insert_at=None, stride=1000000):
11851188
" (inserted {} at {})".format(insert_num, insert_at) if insert_at else "")
11861189
)
11871190

1188-
def actionAddTrack_trigger(self, event):
1191+
def actionAddTrack_trigger(self, checked=True):
11891192
log.info("actionAddTrack_trigger")
11901193

11911194
# Get # of tracks
@@ -1198,7 +1201,7 @@ def actionAddTrack_trigger(self, event):
11981201
track.data = {"number": track_number, "y": 0, "label": "", "lock": False}
11991202
track.save()
12001203

1201-
def actionAddTrackAbove_trigger(self, event):
1204+
def actionAddTrackAbove_trigger(self, checked=True):
12021205
# Get selected track
12031206
all_tracks = get_app().project.get("layers")
12041207
selected_layer_id = self.selected_tracks[0]
@@ -1245,7 +1248,7 @@ def actionAddTrackAbove_trigger(self, event):
12451248
# Temporarily for debugging
12461249
log.info("Tracks after: {}".format([{x['number']: x['id']} for x in reversed(tracks)]))
12471250

1248-
def actionAddTrackBelow_trigger(self, event):
1251+
def actionAddTrackBelow_trigger(self, checked=True):
12491252
# Get selected track
12501253
all_tracks = get_app().project.get("layers")
12511254
selected_layer_id = self.selected_tracks[0]
@@ -1295,23 +1298,23 @@ def actionAddTrackBelow_trigger(self, event):
12951298
# Temporarily for debugging
12961299
log.info("Tracks after: {}".format([{x['number']: x['id']} for x in reversed(tracks)]))
12971300

1298-
def actionArrowTool_trigger(self, event):
1301+
def actionArrowTool_trigger(self, checked=True):
12991302
log.info("actionArrowTool_trigger")
13001303

1301-
def actionSnappingTool_trigger(self, event):
1304+
def actionSnappingTool_trigger(self, checked=True):
13021305
log.info("actionSnappingTool_trigger")
13031306

13041307
# Enable / Disable snapping mode
13051308
self.timeline.SetSnappingMode(self.actionSnappingTool.isChecked())
13061309

1307-
def actionRazorTool_trigger(self, event):
1310+
def actionRazorTool_trigger(self, checked=True):
13081311
"""Toggle razor tool on and off"""
13091312
log.info('actionRazorTool_trigger')
13101313

13111314
# Enable / Disable razor mode
1312-
self.timeline.SetRazorMode(self.actionRazorTool.isChecked())
1315+
self.timeline.SetRazorMode(checked)
13131316

1314-
def actionAddMarker_trigger(self, event):
1317+
def actionAddMarker_trigger(self, checked=True):
13151318
log.info("actionAddMarker_trigger")
13161319

13171320
# Get player object
@@ -1329,7 +1332,6 @@ def actionAddMarker_trigger(self, event):
13291332
marker.data = {"position": position, "icon": "blue.png"}
13301333
marker.save()
13311334

1332-
13331335
def findAllMarkerPositions(self):
13341336
"""Build and return a list of all seekable locations for the currently-selected timeline elements"""
13351337

@@ -1349,31 +1351,36 @@ def getTimelineObjectPositions(obj):
13491351
positions.append(clip_stop_time)
13501352

13511353
# add all keyframes
1352-
for property in obj.data :
1353-
try :
1354-
for point in obj.data[property]["Points"] :
1354+
for property in obj.data:
1355+
try:
1356+
for point in obj.data[property]["Points"]:
13551357
keyframe_time = (point["co"]["X"]-1)/fps_float - obj.data["start"] + obj.data["position"]
1356-
if keyframe_time > clip_start_time and keyframe_time < clip_stop_time :
1358+
if clip_start_time < keyframe_time < clip_stop_time:
13571359
positions.append(keyframe_time)
13581360
except (TypeError, KeyError):
13591361
pass
13601362

1361-
13621363
# Add all Effect keyframes
13631364
if "effects" in obj.data:
13641365
for effect_data in obj.data["effects"]:
13651366
for property in effect_data:
13661367
try:
13671368
for point in effect_data[property]["Points"]:
13681369
keyframe_time = (point["co"]["X"]-1)/fps_float + clip_orig_time
1369-
if keyframe_time > clip_start_time and keyframe_time < clip_stop_time:
1370+
if clip_start_time < keyframe_time < clip_stop_time:
13701371
positions.append(keyframe_time)
13711372
except (TypeError, KeyError):
13721373
pass
13731374

13741375
return positions
13751376

1376-
all_marker_positions = []
1377+
# We can always jump to the beginning of the timeline
1378+
all_marker_positions = [0]
1379+
1380+
# If nothing is selected, also add the end of the last clip
1381+
if not self.selected_clips + self.selected_transitions:
1382+
all_marker_positions.append(
1383+
get_app().window.timeline_sync.timeline.GetMaxTime())
13771384

13781385
# Get list of marker and important positions (like selected clip bounds)
13791386
for marker in Marker.filter():
@@ -1398,7 +1405,7 @@ def getTimelineObjectPositions(obj):
13981405

13991406
return all_marker_positions
14001407

1401-
def actionPreviousMarker_trigger(self, event):
1408+
def actionPreviousMarker_trigger(self, checked=True):
14021409
log.info("actionPreviousMarker_trigger")
14031410

14041411
# Calculate current position (in seconds)
@@ -1430,7 +1437,7 @@ def actionPreviousMarker_trigger(self, event):
14301437
get_app().window.refreshFrameSignal.emit()
14311438
get_app().window.propertyTableView.select_frame(frame_to_seek)
14321439

1433-
def actionNextMarker_trigger(self, event):
1440+
def actionNextMarker_trigger(self, checked=True):
14341441
log.info("actionNextMarker_trigger")
14351442

14361443
# Calculate current position (in seconds)
@@ -1462,7 +1469,7 @@ def actionNextMarker_trigger(self, event):
14621469
get_app().window.refreshFrameSignal.emit()
14631470
get_app().window.propertyTableView.select_frame(frame_to_seek)
14641471

1465-
def actionCenterOnPlayhead_trigger(self, event):
1472+
def actionCenterOnPlayhead_trigger(self, checked=True):
14661473
""" Center the timeline on the current playhead position """
14671474
self.timeline.centerOnPlayhead()
14681475

0 commit comments

Comments
 (0)