Add switch for browser states

This commit is contained in:
RumovZ 2021-03-29 12:24:24 +02:00
parent a3e3e56f2b
commit ad7ac06398
3 changed files with 13 additions and 31 deletions

View File

@ -12,6 +12,8 @@ browsing-browser-appearance = Browser Appearance
browsing-browser-options = Browser Options
browsing-buried = Buried
browsing-card = Card
# Exactly one character representing 'Cards'; should differ from browsing-note-initial.
browsing-card-initial = C
browsing-card-list = Card List
browsing-card-state = Card State
browsing-cards-cant-be-manually-moved-into = Cards can't be manually moved into a filtered deck.
@ -63,6 +65,8 @@ browsing-new = (new)
browsing-new-note-type = New note type:
browsing-no-flag = No Flag
browsing-note = Note
# Exactly one character representing 'Notes'; should differ from browsing-card-initial.
browsing-note-initial = N
browsing-notes-tagged = Notes tagged.
browsing-nothing = Nothing
browsing-only-new-cards-can-be-repositioned = Only new cards can be repositioned.

View File

@ -37,6 +37,7 @@ from aqt.scheduling_ops import (
unsuspend_cards,
)
from aqt.sidebar import SidebarTreeView
from aqt.switch import Switch
from aqt.table import Table
from aqt.tag_ops import add_tags, clear_unused_tags, remove_tags_for_notes
from aqt.utils import (
@ -374,10 +375,11 @@ class Browser(QMainWindow):
def setup_table(self) -> None:
self.table = Table(self)
self.form.radio_cards.setChecked(self.table.is_card_state())
self.form.radio_notes.setChecked(not self.table.is_card_state())
self.table.set_view(self.form.tableView)
qconnect(self.form.radio_cards.toggled, self.on_table_state_changed)
switch = Switch(11, tr.browsing_card_initial(), tr.browsing_note_initial())
switch.setChecked(self.table.is_card_state())
qconnect(switch.toggled, self.on_table_state_changed)
self.form.gridLayout.addWidget(switch, 0, 0)
def setupEditor(self) -> None:
def add_preview_button(leftbuttons: List[str], editor: Editor) -> None:
@ -430,10 +432,10 @@ class Browser(QMainWindow):
self._update_flags_menu()
gui_hooks.browser_did_change_row(self)
@ensure_editor_saved_on_trigger
def on_table_state_changed(self) -> None:
@ensure_editor_saved
def on_table_state_changed(self, checked: bool) -> None:
self.mw.progress.start()
self.table.toggle_state(self.form.radio_cards.isChecked(), self._lastSearchTxt)
self.table.toggle_state(checked, self._lastSearchTxt)
self.mw.progress.finish()
# Sidebar

View File

@ -91,7 +91,7 @@
<property name="verticalSpacing">
<number>0</number>
</property>
<item row="0" column="0">
<item row="0" column="1">
<widget class="QComboBox" name="searchEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -109,30 +109,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="view_state" stretch="0,1">
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QRadioButton" name="radio_cards">
<property name="text">
<string>qt_accel_cards</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radio_notes">
<property name="text">
<string>qt_accel_notes</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableView" name="tableView">
<property name="sizePolicy">