diff --git a/ftl/core/browsing.ftl b/ftl/core/browsing.ftl
index 24091e4f8..89755266c 100644
--- a/ftl/core/browsing.ftl
+++ b/ftl/core/browsing.ftl
@@ -101,6 +101,7 @@ browsing-suspended = Suspended
browsing-tag-duplicates = Tag Duplicates
browsing-tag-rename-warning-empty = You can't rename a tag that has no notes.
browsing-target-field = Target field:
+browsing-toggle-cards-notes-mode = Toggle Cards/Notes Mode
browsing-toggle-mark = Toggle Mark
browsing-toggle-suspend = Toggle Suspend
browsing-treat-input-as-regular-expression = Treat input as regular expression
diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py
index 0055f75b7..62562c77a 100644
--- a/qt/aqt/browser.py
+++ b/qt/aqt/browser.py
@@ -376,6 +376,8 @@ class Browser(QMainWindow):
self.table.set_view(self.form.tableView)
switch = Switch(11, tr.browsing_card_initial(), tr.browsing_note_initial())
switch.setChecked(self.table.is_notes_mode())
+ switch.setToolTip(tr.browsing_toggle_cards_notes_mode())
+ qconnect(self.form.action_toggle_mode.triggered, switch.toggle)
qconnect(switch.toggled, self.on_table_state_changed)
self.form.gridLayout.addWidget(switch, 0, 0)
diff --git a/qt/aqt/forms/browser.ui b/qt/aqt/forms/browser.ui
index f7cfde752..810724b33 100644
--- a/qt/aqt/forms/browser.ui
+++ b/qt/aqt/forms/browser.ui
@@ -218,6 +218,8 @@
+
+
@@ -603,6 +605,14 @@
qt_accel_forget
+
+
+ browsing_toggle_cards_notes_mode
+
+
+ Ctrl+M
+
+
diff --git a/qt/aqt/switch.py b/qt/aqt/switch.py
index 2f8816ee8..cd6590dac 100644
--- a/qt/aqt/switch.py
+++ b/qt/aqt/switch.py
@@ -9,7 +9,9 @@ from aqt.theme import theme_manager
class Switch(QAbstractButton):
"""A horizontal slider to toggle between two states which can be denoted by short strings.
- The left state is the default and corresponds to isChecked=False.
+
+ The left state is the default and corresponds to isChecked()=False.
+ The suppoorted slots are toggle(), for an animated transition, and setChecked().
"""
_margin: int = 2
@@ -104,13 +106,20 @@ class Switch(QAbstractButton):
def mouseReleaseEvent(self, event: QMouseEvent) -> None:
super().mouseReleaseEvent(event)
if event.button() == Qt.LeftButton:
- animation = QPropertyAnimation(self, b"position", self)
- animation.setDuration(100)
- animation.setStartValue(self.start_position)
- animation.setEndValue(self.end_position)
- # make triggered events execute first so the animation runs smoothly afterwards
- QTimer.singleShot(50, animation.start)
+ self._animate_toggle()
def enterEvent(self, event: QEvent) -> None:
self.setCursor(Qt.PointingHandCursor)
super().enterEvent(event)
+
+ def toggle(self) -> None:
+ super().toggle()
+ self._animate_toggle()
+
+ def _animate_toggle(self) -> None:
+ animation = QPropertyAnimation(self, b"position", self)
+ animation.setDuration(100)
+ animation.setStartValue(self.start_position)
+ animation.setEndValue(self.end_position)
+ # make triggered events execute first so the animation runs smoothly afterwards
+ QTimer.singleShot(50, animation.start)