@@ -92,10 +92,10 @@ def __init__(self):
92
92
self .delayed_fps_timer .stop ()
93
93
94
94
# Pause playback (to prevent crash since we are fixing to change the timeline's max size)
95
- get_app () .window .actionPlay_trigger (None , force = "pause" )
95
+ app .window .actionPlay_trigger (None , force = "pause" )
96
96
97
97
# Clear timeline preview cache (to get more available memory)
98
- get_app () .window .timeline_sync .timeline .ClearAllCache ()
98
+ app .window .timeline_sync .timeline .ClearAllCache ()
99
99
100
100
# Hide audio channels
101
101
self .lblChannels .setVisible (False )
@@ -106,12 +106,12 @@ def __init__(self):
106
106
openshot .Settings .Instance ().HIGH_QUALITY_SCALING = True
107
107
108
108
# Get the original timeline settings
109
- width = get_app () .window .timeline_sync .timeline .info .width
110
- height = get_app () .window .timeline_sync .timeline .info .height
111
- fps = get_app () .window .timeline_sync .timeline .info .fps
112
- sample_rate = get_app () .window .timeline_sync .timeline .info .sample_rate
113
- channels = get_app () .window .timeline_sync .timeline .info .channels
114
- channel_layout = get_app () .window .timeline_sync .timeline .info .channel_layout
109
+ width = app .window .timeline_sync .timeline .info .width
110
+ height = app .window .timeline_sync .timeline .info .height
111
+ fps = app .window .timeline_sync .timeline .info .fps
112
+ sample_rate = app .window .timeline_sync .timeline .info .sample_rate
113
+ channels = app .window .timeline_sync .timeline .info .channels
114
+ channel_layout = app .window .timeline_sync .timeline .info .channel_layout
115
115
116
116
# No keyframe rescaling has happened yet (due to differences in FPS)
117
117
self .keyframes_rescaled = False
@@ -120,16 +120,16 @@ def __init__(self):
120
120
self .timeline = openshot .Timeline (width , height , openshot .Fraction (fps .num , fps .den ),
121
121
sample_rate , channels , channel_layout )
122
122
# Init various properties
123
- self .timeline .info .channel_layout = get_app () .window .timeline_sync .timeline .info .channel_layout
124
- self .timeline .info .has_audio = get_app () .window .timeline_sync .timeline .info .has_audio
125
- self .timeline .info .has_video = get_app () .window .timeline_sync .timeline .info .has_video
126
- self .timeline .info .video_length = get_app () .window .timeline_sync .timeline .info .video_length
127
- self .timeline .info .duration = get_app () .window .timeline_sync .timeline .info .duration
128
- self .timeline .info .sample_rate = get_app () .window .timeline_sync .timeline .info .sample_rate
129
- self .timeline .info .channels = get_app () .window .timeline_sync .timeline .info .channels
123
+ self .timeline .info .channel_layout = app .window .timeline_sync .timeline .info .channel_layout
124
+ self .timeline .info .has_audio = app .window .timeline_sync .timeline .info .has_audio
125
+ self .timeline .info .has_video = app .window .timeline_sync .timeline .info .has_video
126
+ self .timeline .info .video_length = app .window .timeline_sync .timeline .info .video_length
127
+ self .timeline .info .duration = app .window .timeline_sync .timeline .info .duration
128
+ self .timeline .info .sample_rate = app .window .timeline_sync .timeline .info .sample_rate
129
+ self .timeline .info .channels = app .window .timeline_sync .timeline .info .channels
130
130
131
131
# Load the "export" Timeline reader with the JSON from the real timeline
132
- json_timeline = json .dumps (get_app () .project ._data )
132
+ json_timeline = json .dumps (app .project ._data )
133
133
self .timeline .SetJson (json_timeline )
134
134
135
135
# Open the "export" Timeline reader
@@ -140,7 +140,7 @@ def __init__(self):
140
140
if app .project .current_filepath :
141
141
recommended_path = os .path .dirname (app .project .current_filepath )
142
142
143
- export_path = get_app () .project .get ("export_path" )
143
+ export_path = app .project .get ("export_path" )
144
144
if export_path and os .path .exists (export_path ):
145
145
# Use last selected export path
146
146
self .txtExportFolder .setText (export_path )
@@ -149,13 +149,13 @@ def __init__(self):
149
149
self .txtExportFolder .setText (recommended_path )
150
150
151
151
# Is this a saved project?
152
- if not get_app () .project .current_filepath :
152
+ if not app .project .current_filepath :
153
153
# Not saved yet
154
154
self .txtFileName .setText (_ ("Untitled Project" ))
155
155
else :
156
156
# Yes, project is saved
157
157
# Get just the filename
158
- filename = os .path .basename (get_app () .project .current_filepath )
158
+ filename = os .path .basename (app .project .current_filepath )
159
159
filename = os .path .splitext (filename )[0 ]
160
160
self .txtFileName .setText (filename )
161
161
@@ -191,7 +191,7 @@ def __init__(self):
191
191
self .cboSimpleQuality .currentIndexChanged .connect (
192
192
functools .partial (self .cboSimpleQuality_index_changed , self .cboSimpleQuality ))
193
193
self .cboChannelLayout .currentIndexChanged .connect (self .updateChannels )
194
- get_app () .window .ExportFrame .connect (self .updateProgressBar )
194
+ app .window .ExportFrame .connect (self .updateProgressBar )
195
195
196
196
# ********* Advanced Profile List **********
197
197
# Loop through profiles
@@ -614,8 +614,6 @@ def btnBrowse_clicked(self):
614
614
615
615
if os .path .exists (file_path ):
616
616
self .txtExportFolder .setText (file_path )
617
- # update export folder path in project file
618
- app .updates .update_untracked (["export_path" ], file_path )
619
617
620
618
def convert_to_bytes (self , BitRateString ):
621
619
bit_rate_bytes = 0
@@ -690,7 +688,6 @@ def accept(self):
690
688
# Prompt error message
691
689
if self .txtStartFrame .value () == self .txtEndFrame .value ():
692
690
msg = QMessageBox ()
693
- _ = get_app ()._tr
694
691
msg .setWindowTitle (_ ("Export Error" ))
695
692
msg .setText (_ ("Sorry, please select a valid range of frames to export" ))
696
693
msg .exec_ ()
@@ -732,22 +729,23 @@ def accept(self):
732
729
export_file_path = os .path .join (self .txtExportFolder .text ().strip () or default_folder , file_name_with_ext )
733
730
log .info ("Invalid export path detected, changing to: %s" % export_file_path )
734
731
735
- # Translate object
736
- _ = get_app ()._tr
737
-
738
732
file = File .get (path = export_file_path )
739
733
if file :
740
- ret = QMessageBox .question (self , _ ("Export Video" ), _ ("%s is an input file.\n Please choose a different name." ) % file_name_with_ext ,
741
- QMessageBox .Ok )
734
+ ret = QMessageBox .question (self ,
735
+ _ ("Export Video" ),
736
+ _ ("%s is an input file.\n Please choose a different name." ) % file_name_with_ext ,
737
+ QMessageBox .Ok )
742
738
self .enableControls ()
743
739
self .exporting = False
744
740
return
745
741
746
742
# Handle exception
747
743
if os .path .exists (export_file_path ) and export_type in [_ ("Video & Audio" ), _ ("Video Only" ), _ ("Audio Only" )]:
748
744
# File already exists! Prompt user
749
- ret = QMessageBox .question (self , _ ("Export Video" ), _ ("%s already exists.\n Do you want to replace it?" ) % file_name_with_ext ,
750
- QMessageBox .No | QMessageBox .Yes )
745
+ ret = QMessageBox .question (self ,
746
+ _ ("Export Video" ),
747
+ _ ("%s already exists.\n Do you want to replace it?" ) % file_name_with_ext ,
748
+ QMessageBox .No | QMessageBox .Yes )
751
749
if ret == QMessageBox .No :
752
750
# Stop and don't do anything
753
751
# Re-enable controls
@@ -783,6 +781,11 @@ def accept(self):
783
781
else :
784
782
video_settings ["vcodec" ] = image_ext
785
783
784
+ # Store updated export folder path in project file
785
+ app .updates .update_untracked (["export_path" ], os .path .dirname (export_file_path ))
786
+ # Mark project file as unsaved
787
+ app .project .has_unsaved_changes = True
788
+
786
789
# Set MaxSize (so we don't have any downsampling)
787
790
self .timeline .SetMaxSize (video_settings .get ("width" ), video_settings .get ("height" ))
788
791
@@ -793,10 +796,10 @@ def accept(self):
793
796
# Rescale all keyframes and reload project
794
797
if self .export_fps_factor != 1.0 :
795
798
self .keyframes_rescaled = True
796
- get_app () .project .rescale_keyframes (self .export_fps_factor )
799
+ app .project .rescale_keyframes (self .export_fps_factor )
797
800
798
801
# Load the "export" Timeline reader with the JSON from the real timeline
799
- json_timeline = json .dumps (get_app () .project ._data )
802
+ json_timeline = json .dumps (app .project ._data )
800
803
self .timeline .SetJson (json_timeline )
801
804
802
805
# Re-update the timeline FPS again (since the timeline just got clobbered)
@@ -847,7 +850,7 @@ def accept(self):
847
850
848
851
# Notify window of export started
849
852
title_message = ""
850
- get_app () .window .ExportStarted .emit (export_file_path , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ))
853
+ app .window .ExportStarted .emit (export_file_path , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ))
851
854
852
855
progressstep = max (1 , round (( video_settings .get ("end_frame" ) - video_settings .get ("start_frame" ) ) / 1000 ))
853
856
start_time_export = time .time ()
@@ -868,7 +871,7 @@ def accept(self):
868
871
'fps' : fps_encode }
869
872
870
873
# Emit frame exported
871
- get_app () .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ), frame )
874
+ app .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ), frame )
872
875
873
876
# Process events (to show the progress bar moving)
874
877
QCoreApplication .processEvents ()
@@ -891,7 +894,7 @@ def accept(self):
891
894
'seconds' : seconds_run % 60 ,
892
895
'fps' : fps_encode }
893
896
894
- get_app () .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ),
897
+ app .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ),
895
898
video_settings .get ("end_frame" ), frame )
896
899
897
900
except Exception as e :
@@ -925,13 +928,12 @@ def accept(self):
925
928
926
929
# Prompt error message
927
930
msg = QMessageBox ()
928
- _ = get_app ()._tr
929
931
msg .setWindowTitle (_ ("Export Error" ))
930
932
msg .setText (_ ("Sorry, there was an error exporting your video: \n %s" ) % friendly_error )
931
933
msg .exec_ ()
932
934
933
935
# Notify window of export started
934
- get_app () .window .ExportEnded .emit (export_file_path )
936
+ app .window .ExportEnded .emit (export_file_path )
935
937
936
938
# Close timeline object
937
939
self .timeline .Close ()
@@ -950,7 +952,7 @@ def accept(self):
950
952
951
953
# Return keyframes to preview scaling
952
954
if self .keyframes_rescaled :
953
- get_app () .project .rescale_keyframes (self .original_fps_factor )
955
+ app .project .rescale_keyframes (self .original_fps_factor )
954
956
955
957
# Handle end of export (for non-canceled exports)
956
958
if self .s .get ("show_finished_window" ) and self .exporting :
0 commit comments