Adjust arrows direction for RTL layouts in previewer (#1513)

This commit is contained in:
Abdo 2021-11-29 05:41:08 +03:00 committed by GitHub
parent 8edca4e6c1
commit 5a3999d0c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,6 +80,7 @@ class Previewer(QDialog):
self._web = AnkiWebView(title="previewer")
self.vbox.addWidget(self._web)
self.bbox = QDialogButtonBox()
self.bbox.setLayoutDirection(Qt.LayoutDirection.LeftToRight)
self._replay = self.bbox.addButton(
tr.actions_replay_audio(), QDialogButtonBox.ButtonRole.ActionRole
@ -263,12 +264,18 @@ class MultiCardPreviewer(Previewer):
def _create_gui(self) -> None:
super()._create_gui()
self._prev = self.bbox.addButton("<", QDialogButtonBox.ButtonRole.ActionRole)
self._prev = self.bbox.addButton(
">" if self.layoutDirection() == Qt.LayoutDirection.RightToLeft else "<",
QDialogButtonBox.ButtonRole.ActionRole,
)
self._prev.setAutoDefault(False)
self._prev.setShortcut(QKeySequence("Left"))
self._prev.setToolTip(tr.qt_misc_shortcut_key_left_arrow())
self._next = self.bbox.addButton(">", QDialogButtonBox.ButtonRole.ActionRole)
self._next = self.bbox.addButton(
"<" if self.layoutDirection() == Qt.LayoutDirection.RightToLeft else ">",
QDialogButtonBox.ButtonRole.ActionRole,
)
self._next.setAutoDefault(True)
self._next.setShortcut(QKeySequence("Right"))
self._next.setToolTip(tr.qt_misc_shortcut_key_right_arrow_or_enter())