Skip to content

Commit 46a50e0

Browse files
committed
Mark project as dirty on export
1 parent 005791d commit 46a50e0

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

src/windows/export.py

+40-38
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ def __init__(self):
9292
self.delayed_fps_timer.stop()
9393

9494
# 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")
9696

9797
# Clear timeline preview cache (to get more available memory)
98-
get_app().window.timeline_sync.timeline.ClearAllCache()
98+
app.window.timeline_sync.timeline.ClearAllCache()
9999

100100
# Hide audio channels
101101
self.lblChannels.setVisible(False)
@@ -106,12 +106,12 @@ def __init__(self):
106106
openshot.Settings.Instance().HIGH_QUALITY_SCALING = True
107107

108108
# 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
115115

116116
# No keyframe rescaling has happened yet (due to differences in FPS)
117117
self.keyframes_rescaled = False
@@ -120,16 +120,16 @@ def __init__(self):
120120
self.timeline = openshot.Timeline(width, height, openshot.Fraction(fps.num, fps.den),
121121
sample_rate, channels, channel_layout)
122122
# 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
130130

131131
# 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)
133133
self.timeline.SetJson(json_timeline)
134134

135135
# Open the "export" Timeline reader
@@ -140,7 +140,7 @@ def __init__(self):
140140
if app.project.current_filepath:
141141
recommended_path = os.path.dirname(app.project.current_filepath)
142142

143-
export_path = get_app().project.get("export_path")
143+
export_path = app.project.get("export_path")
144144
if export_path and os.path.exists(export_path):
145145
# Use last selected export path
146146
self.txtExportFolder.setText(export_path)
@@ -149,13 +149,13 @@ def __init__(self):
149149
self.txtExportFolder.setText(recommended_path)
150150

151151
# Is this a saved project?
152-
if not get_app().project.current_filepath:
152+
if not app.project.current_filepath:
153153
# Not saved yet
154154
self.txtFileName.setText(_("Untitled Project"))
155155
else:
156156
# Yes, project is saved
157157
# Get just the filename
158-
filename = os.path.basename(get_app().project.current_filepath)
158+
filename = os.path.basename(app.project.current_filepath)
159159
filename = os.path.splitext(filename)[0]
160160
self.txtFileName.setText(filename)
161161

@@ -191,7 +191,7 @@ def __init__(self):
191191
self.cboSimpleQuality.currentIndexChanged.connect(
192192
functools.partial(self.cboSimpleQuality_index_changed, self.cboSimpleQuality))
193193
self.cboChannelLayout.currentIndexChanged.connect(self.updateChannels)
194-
get_app().window.ExportFrame.connect(self.updateProgressBar)
194+
app.window.ExportFrame.connect(self.updateProgressBar)
195195

196196
# ********* Advanced Profile List **********
197197
# Loop through profiles
@@ -614,8 +614,6 @@ def btnBrowse_clicked(self):
614614

615615
if os.path.exists(file_path):
616616
self.txtExportFolder.setText(file_path)
617-
# update export folder path in project file
618-
app.updates.update_untracked(["export_path"], file_path)
619617

620618
def convert_to_bytes(self, BitRateString):
621619
bit_rate_bytes = 0
@@ -690,7 +688,6 @@ def accept(self):
690688
# Prompt error message
691689
if self.txtStartFrame.value() == self.txtEndFrame.value():
692690
msg = QMessageBox()
693-
_ = get_app()._tr
694691
msg.setWindowTitle(_("Export Error"))
695692
msg.setText(_("Sorry, please select a valid range of frames to export"))
696693
msg.exec_()
@@ -732,22 +729,23 @@ def accept(self):
732729
export_file_path = os.path.join(self.txtExportFolder.text().strip() or default_folder, file_name_with_ext)
733730
log.info("Invalid export path detected, changing to: %s" % export_file_path)
734731

735-
# Translate object
736-
_ = get_app()._tr
737-
738732
file = File.get(path=export_file_path)
739733
if file:
740-
ret = QMessageBox.question(self, _("Export Video"), _("%s is an input file.\nPlease 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.\nPlease choose a different name.") % file_name_with_ext,
737+
QMessageBox.Ok)
742738
self.enableControls()
743739
self.exporting = False
744740
return
745741

746742
# Handle exception
747743
if os.path.exists(export_file_path) and export_type in [_("Video & Audio"), _("Video Only"), _("Audio Only")]:
748744
# File already exists! Prompt user
749-
ret = QMessageBox.question(self, _("Export Video"), _("%s already exists.\nDo 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.\nDo you want to replace it?") % file_name_with_ext,
748+
QMessageBox.No | QMessageBox.Yes)
751749
if ret == QMessageBox.No:
752750
# Stop and don't do anything
753751
# Re-enable controls
@@ -783,6 +781,11 @@ def accept(self):
783781
else:
784782
video_settings["vcodec"] = image_ext
785783

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+
786789
# Set MaxSize (so we don't have any downsampling)
787790
self.timeline.SetMaxSize(video_settings.get("width"), video_settings.get("height"))
788791

@@ -793,10 +796,10 @@ def accept(self):
793796
# Rescale all keyframes and reload project
794797
if self.export_fps_factor != 1.0:
795798
self.keyframes_rescaled = True
796-
get_app().project.rescale_keyframes(self.export_fps_factor)
799+
app.project.rescale_keyframes(self.export_fps_factor)
797800

798801
# 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)
800803
self.timeline.SetJson(json_timeline)
801804

802805
# Re-update the timeline FPS again (since the timeline just got clobbered)
@@ -847,7 +850,7 @@ def accept(self):
847850

848851
# Notify window of export started
849852
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"))
851854

852855
progressstep = max(1 , round(( video_settings.get("end_frame") - video_settings.get("start_frame") ) / 1000))
853856
start_time_export = time.time()
@@ -868,7 +871,7 @@ def accept(self):
868871
'fps': fps_encode}
869872

870873
# 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)
872875

873876
# Process events (to show the progress bar moving)
874877
QCoreApplication.processEvents()
@@ -891,7 +894,7 @@ def accept(self):
891894
'seconds': seconds_run % 60,
892895
'fps': fps_encode}
893896

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"),
895898
video_settings.get("end_frame"), frame)
896899

897900
except Exception as e:
@@ -925,13 +928,12 @@ def accept(self):
925928

926929
# Prompt error message
927930
msg = QMessageBox()
928-
_ = get_app()._tr
929931
msg.setWindowTitle(_("Export Error"))
930932
msg.setText(_("Sorry, there was an error exporting your video: \n%s") % friendly_error)
931933
msg.exec_()
932934

933935
# Notify window of export started
934-
get_app().window.ExportEnded.emit(export_file_path)
936+
app.window.ExportEnded.emit(export_file_path)
935937

936938
# Close timeline object
937939
self.timeline.Close()
@@ -950,7 +952,7 @@ def accept(self):
950952

951953
# Return keyframes to preview scaling
952954
if self.keyframes_rescaled:
953-
get_app().project.rescale_keyframes(self.original_fps_factor)
955+
app.project.rescale_keyframes(self.original_fps_factor)
954956

955957
# Handle end of export (for non-canceled exports)
956958
if self.s.get("show_finished_window") and self.exporting:

0 commit comments

Comments
 (0)