From 10ebac1eafcf7f0c7234c60fb4141393e68af3a9 Mon Sep 17 00:00:00 2001 From: Osmo Salomaa Date: Sun, 16 Aug 2020 22:51:30 +0300 Subject: [PATCH] Allow shifting positions of all open projects Closes #66 --- TODO.md | 1 + data/ui/position-shift-dialog.ui | 17 +++++++++++++++++ gaupol/dialogs/position_shift.py | 7 ++++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/TODO.md b/TODO.md index 49afe45c..87c88aef 100644 --- a/TODO.md +++ b/TODO.md @@ -2,4 +2,5 @@ Gaupol 1.9 ========== * [x] Add framerates 30, 50, 59.94 and 60 fps (#164) +* [x] Allow shifting positions of all open projects (#66) * [x] Fix the order of audio tracks in the menu (#129, qnga) diff --git a/data/ui/position-shift-dialog.ui b/data/ui/position-shift-dialog.ui index a6a8282d..24864f63 100644 --- a/data/ui/position-shift-dialog.ui +++ b/data/ui/position-shift-dialog.ui @@ -246,6 +246,23 @@ 2 + + + Shift all _open projects + True + True + False + start + True + True + selected_radio + + + False + False + 3 + + False diff --git a/gaupol/dialogs/position_shift.py b/gaupol/dialogs/position_shift.py index c21d283e..651de2f8 100644 --- a/gaupol/dialogs/position_shift.py +++ b/gaupol/dialogs/position_shift.py @@ -31,6 +31,7 @@ class PositionShiftDialog(gaupol.BuilderDialog): """Base class for dialogs for shifting positions.""" _widgets = [ + "all_radio", "amount_spin", "current_radio", "preview_button", @@ -61,6 +62,8 @@ def _get_target(self): return gaupol.targets.SELECTED_TO_END if self._current_radio.get_active(): return gaupol.targets.CURRENT + if self._all_radio.get_active(): + return gaupol.targets.ALL raise ValueError("Invalid target radio state") def _init_dialog(self, parent): @@ -77,6 +80,7 @@ def _init_values(self): self._selected_radio.set_active(target == gaupol.targets.SELECTED) self._to_end_radio.set_active(target == gaupol.targets.SELECTED_TO_END) self._current_radio.set_active(target == gaupol.targets.CURRENT) + self._all_radio.set_active(target == gaupol.targets.ALL) page = self.application.get_current_page() rows = page.view.get_selected_rows() if not rows and target in ( @@ -120,9 +124,10 @@ def _shift_positions(self): """Shift positions in subtitles.""" gaupol.util.set_cursor_busy(self) target = self._get_target() - rows = self.application.get_target_rows(target) amount = self._get_amount() for page in self.application.get_target_pages(target): + self.application.set_current_page(page) + rows = self.application.get_target_rows(target) page.project.shift_positions(rows, amount) gaupol.util.set_cursor_normal(self)