From 18e33f24d3e4b8ef62217239928f55c62f4f0957 Mon Sep 17 00:00:00 2001 From: RumovZ Date: Mon, 29 Mar 2021 15:51:34 +0200 Subject: [PATCH] Make note state equate to False as on backend --- qt/aqt/browser.py | 8 ++++---- qt/aqt/switch.py | 14 +++++++------- qt/aqt/table.py | 28 ++++++++++++++-------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/qt/aqt/browser.py b/qt/aqt/browser.py index 56e313c2a..5084b9213 100644 --- a/qt/aqt/browser.py +++ b/qt/aqt/browser.py @@ -330,9 +330,9 @@ class Browser(QMainWindow): selected = self.table.len_selection() cur = self.table.len() tr_title = ( - tr.browsing_window_title - if self.table.is_card_state() - else tr.browsing_window_title_notes + tr.browsing_window_title_notes + if self.table.is_notes_mode() + else tr.browsing_window_title ) self.setWindowTitle( without_unicode_isolation(tr_title(total=cur, selected=selected)) @@ -377,7 +377,7 @@ class Browser(QMainWindow): self.table = Table(self) self.table.set_view(self.form.tableView) switch = Switch(11, tr.browsing_card_initial(), tr.browsing_note_initial()) - switch.setChecked(self.table.is_card_state()) + switch.setChecked(self.table.is_notes_mode()) qconnect(switch.toggled, self.on_table_state_changed) self.form.gridLayout.addWidget(switch, 0, 0) diff --git a/qt/aqt/switch.py b/qt/aqt/switch.py index d1a883b44..83afdcd99 100644 --- a/qt/aqt/switch.py +++ b/qt/aqt/switch.py @@ -9,7 +9,7 @@ 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=True. + The left state is the default and corresponds to isChecked=False. """ _margin: int = 2 @@ -23,7 +23,7 @@ class Switch(QAbstractButton): ) -> None: super().__init__(parent=parent) self.setCheckable(True) - super().setChecked(True) + super().setChecked(False) self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self._left_label = left_label self._right_label = right_label @@ -43,15 +43,15 @@ class Switch(QAbstractButton): @property def start_position(self) -> int: - return self._right_position if self.isChecked() else self._left_position - - @property - def end_position(self) -> int: return self._left_position if self.isChecked() else self._right_position + @property + def end_position(self) -> int: + return self._right_position if self.isChecked() else self._left_position + @property def label(self) -> str: - return self._left_label if self.isChecked() else self._right_label + return self._right_label if self.isChecked() else self._left_label def sizeHint(self) -> QSize: return QSize( diff --git a/qt/aqt/table.py b/qt/aqt/table.py index dac6bbb26..9fba51acd 100644 --- a/qt/aqt/table.py +++ b/qt/aqt/table.py @@ -93,8 +93,8 @@ class Table: def has_next(self) -> bool: return self.has_current() and self._current().row() < self.len() - 1 - def is_card_state(self) -> bool: - return self._state.is_card_state() + def is_notes_mode(self) -> bool: + return self._state.is_notes_mode() # Get objects @@ -193,15 +193,15 @@ class Table: self._model.search(SearchContext(search=txt, browser=self.browser)) self._restore_selection(self._intersected_selection) - def toggle_state(self, is_card_state: bool, last_search: str) -> None: - if is_card_state == self.is_card_state(): + def toggle_state(self, is_notes_mode: bool, last_search: str) -> None: + if is_notes_mode == self.is_notes_mode(): return self._save_selection() self._state = self._model.toggle_state( SearchContext(search=last_search, browser=self.browser) ) self.col.set_config_bool( - Config.Bool.BROWSER_TABLE_SHOW_NOTES_MODE, not self.is_card_state() + Config.Bool.BROWSER_TABLE_SHOW_NOTES_MODE, self.is_notes_mode() ) self._set_sort_indicator() self._set_column_sizes() @@ -327,14 +327,14 @@ class Table: def _on_context_menu(self, _point: QPoint) -> None: menu = QMenu() - if self.is_card_state(): - main = self.browser.form.menu_Cards - other = self.browser.form.menu_Notes - other_name = tr.qt_accel_notes() - else: + if self.is_notes_mode(): main = self.browser.form.menu_Notes other = self.browser.form.menu_Cards other_name = tr.qt_accel_cards() + else: + main = self.browser.form.menu_Cards + other = self.browser.form.menu_Notes + other_name = tr.qt_accel_notes() for action in main.actions(): menu.addAction(action) menu.addSeparator() @@ -529,9 +529,9 @@ class ItemState(ABC): def __init__(self, col: Collection) -> None: self.col = col - def is_card_state(self) -> bool: - """Return True if the state is a CardState.""" - return isinstance(self, CardState) + def is_notes_mode(self) -> bool: + """Return True if the state is a NoteState.""" + return isinstance(self, NoteState) # Stateless Helpers @@ -901,7 +901,7 @@ class DataModel(QAbstractTableModel): return CellRow.generic(self.len_columns(), str(e)) gui_hooks.browser_did_fetch_row( - item, not self._state.is_card_state(), row, self._state.active_columns + item, self._state.is_notes_mode(), row, self._state.active_columns ) return row