Skip to content

Commit 4a63a95

Browse files
committed
Compose the export windows title with a local function to make
the code easier to read
1 parent 4a516f9 commit 4a63a95

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/windows/export.py

+14-15
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,17 @@ def enableControls(self):
721721
def accept(self):
722722
""" Start exporting video """
723723

724+
# Build the export window title
725+
def titlestring(sec, fps, mess):
726+
formatstr = "%(hours)d:%(minutes)02d:%(seconds)02d " + mess + " (%(fps)5.2f FPS)"
727+
title_mes = _(formatstr) % {
728+
'hours': sec / 3600,
729+
'minutes': (sec / 60) % 60,
730+
'seconds': sec % 60,
731+
'fps': fps}
732+
return title_mes
733+
734+
724735
# get translations
725736
_ = get_app()._tr
726737

@@ -936,11 +947,7 @@ def accept(self):
936947
if frame == end_frame_export:
937948
title_message = _("Finalizing video export, please wait...")
938949
else:
939-
title_message = _("%(hours)d:%(minutes)02d:%(seconds)02d Remaining (%(fps)5.2f FPS)") % {
940-
'hours': seconds_left / 3600,
941-
'minutes': (seconds_left / 60) % 60,
942-
'seconds': seconds_left % 60,
943-
'fps': fps_encode}
950+
title_message = titlestring(seconds_left, fps_encode, "Remaining")
944951

945952
# Emit frame exported
946953
get_app().window.ExportFrame.emit(title_message, video_settings.get("start_frame"), video_settings.get("end_frame"), frame, progress_format)
@@ -960,11 +967,7 @@ def accept(self):
960967

961968
# Emit final exported frame (with elapsed time)
962969
seconds_run = round((end_time_export - start_time_export))
963-
title_message = _("%(hours)d:%(minutes)02d:%(seconds)02d Elapsed (%(fps)5.2f FPS)") % {
964-
'hours': seconds_run / 3600,
965-
'minutes': (seconds_run / 60) % 60,
966-
'seconds': seconds_run % 60,
967-
'fps': fps_encode}
970+
title_message = titlestring(seconds_left, fps_encode, "Elapsed")
968971

969972
get_app().window.ExportFrame.emit(title_message, video_settings.get("start_frame"),
970973
video_settings.get("end_frame"), frame, progress_format)
@@ -1032,11 +1035,7 @@ def accept(self):
10321035
self.close_button.setVisible(True)
10331036

10341037
# Restore windows title to show elapsed time
1035-
title_message = _("%(hours)d:%(minutes)02d:%(seconds)02d Elapsed (%(fps)5.2f FPS)") % {
1036-
'hours': seconds_run / 3600,
1037-
'minutes': (seconds_run / 60) % 60,
1038-
'seconds': seconds_run % 60,
1039-
'fps': fps_encode}
1038+
title_message = titlestring(seconds_left, fps_encode, "Elapsed")
10401039

10411040
get_app().window.ExportFrame.emit(title_message, video_settings.get("start_frame"),
10421041
video_settings.get("end_frame"), frame, progress_format)

0 commit comments

Comments
 (0)