Add cross links for second dyndeck filter

This commit is contained in:
RumovZ 2021-02-01 19:10:05 +01:00
parent 0d37254238
commit 8065e73ef8
5 changed files with 94 additions and 45 deletions

View File

@ -25,6 +25,7 @@ browsing-clear-unused = Clear Unused
browsing-clear-unused-tags = Clear Unused Tags browsing-clear-unused-tags = Clear Unused Tags
browsing-created = Created browsing-created = Created
browsing-create-filtered-deck = Create Filtered Deck... browsing-create-filtered-deck = Create Filtered Deck...
browsing-create-filtered-deck_2 = Create Filtered Deck (2nd Filter)...
browsing-ctrlandshiftande = Ctrl+Shift+E browsing-ctrlandshiftande = Ctrl+Shift+E
browsing-current-deck = Current Deck browsing-current-deck = Current Deck
browsing-current-note-type = Current note type: browsing-current-note-type = Current note type:

View File

@ -482,6 +482,9 @@ class Browser(QMainWindow):
if not isMac: if not isMac:
f.actionClose.setVisible(False) f.actionClose.setVisible(False)
qconnect(f.actionCreateFilteredDeck.triggered, self.createFilteredDeck) qconnect(f.actionCreateFilteredDeck.triggered, self.createFilteredDeck)
qconnect(f.actionCreateFilteredDeck2.triggered, self.createFilteredDeck2)
if self.mw.col.schedVer() == 1:
f.menuEdit.removeAction(f.actionCreateFilteredDeck2)
# notes # notes
qconnect(f.actionAdd.triggered, self.mw.onAddCard) qconnect(f.actionAdd.triggered, self.mw.onAddCard)
qconnect(f.actionAdd_Tags.triggered, lambda: self.addTags()) qconnect(f.actionAdd_Tags.triggered, lambda: self.addTags())
@ -1194,6 +1197,10 @@ where id in %s"""
search = self.form.searchEdit.lineEdit().text() search = self.form.searchEdit.lineEdit().text()
aqt.dialogs.open("DynDeckConfDialog", self.mw, search=search) aqt.dialogs.open("DynDeckConfDialog", self.mw, search=search)
def createFilteredDeck2(self):
search = self.form.searchEdit.lineEdit().text()
aqt.dialogs.open("DynDeckConfDialog", self.mw, search_2=search)
# Preview # Preview
###################################################################### ######################################################################

View File

@ -29,7 +29,11 @@ class DeckConf(QDialog):
"""Dialogue to modify and build a filtered deck.""" """Dialogue to modify and build a filtered deck."""
def __init__( def __init__(
self, mw: AnkiQt, search: Optional[str] = None, deck: Optional[Deck] = None self,
mw: AnkiQt,
search: Optional[str] = None,
search_2: Optional[str] = None,
deck: Optional[Deck] = None,
): ):
"""If 'deck' is an existing filtered deck, load and modify its settings. """If 'deck' is an existing filtered deck, load and modify its settings.
Otherwise, build a new one and derive settings from the current deck. Otherwise, build a new one and derive settings from the current deck.
@ -60,10 +64,10 @@ class DeckConf(QDialog):
self.new_dyn_deck() self.new_dyn_deck()
self.loadConf() self.loadConf()
self.set_default_searches(self.old_deck["name"]) self.set_default_searches(self.old_deck["name"])
if search is not None:
self.form.search.setText(search)
self.set_custom_searches(search, search_2)
qconnect(self.form.search_button.clicked, self.on_search_button) qconnect(self.form.search_button.clicked, self.on_search_button)
qconnect(self.form.search_button_2.clicked, self.on_search_button_2)
color = theme_manager.str_color("link") color = theme_manager.str_color("link")
self.setStyleSheet( self.setStyleSheet(
f"""QPushButton[flat=true] {{ text-align: left; color: {color}; padding: 0; border: 0 }} f"""QPushButton[flat=true] {{ text-align: left; color: {color}; padding: 0; border: 0 }}
@ -78,8 +82,6 @@ class DeckConf(QDialog):
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"])) without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
) )
self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole) self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
self.form.search.setFocus()
self.form.search.selectAll()
if self.mw.col.schedVer() == 1: if self.mw.col.schedVer() == 1:
self.form.secondFilter.setVisible(False) self.form.secondFilter.setVisible(False)
restoreGeom(self, "dyndeckconf") restoreGeom(self, "dyndeckconf")
@ -87,12 +89,13 @@ class DeckConf(QDialog):
self.show() self.show()
def reopen( def reopen(
self, _mw: AnkiQt, search: Optional[str] = None, _deck: Optional[Deck] = None self,
_mw: AnkiQt,
search: Optional[str] = None,
search_2: Optional[str] = None,
_deck: Optional[Deck] = None,
): ):
if search is not None: self.set_custom_searches(search, search_2)
self.form.search.setText(search)
self.form.search.setFocus()
self.form.search.selectAll()
def new_dyn_deck(self): def new_dyn_deck(self):
suffix: int = 1 suffix: int = 1
@ -118,6 +121,20 @@ class DeckConf(QDialog):
) )
) )
def set_custom_searches(
self, search: Optional[str], search_2: Optional[str]
) -> None:
if search is not None:
self.form.search.setText(search)
self.form.search.setFocus()
self.form.search.selectAll()
if search_2 is not None:
self.form.secondFilter.setChecked(True)
self.form.filter2group.setVisible(True)
self.form.search_2.setText(search_2)
self.form.search_2.setFocus()
self.form.search_2.selectAll()
def initialSetup(self): def initialSetup(self):
import anki.consts as cs import anki.consts as cs
@ -126,12 +143,18 @@ class DeckConf(QDialog):
qconnect(self.form.resched.stateChanged, self._onReschedToggled) qconnect(self.form.resched.stateChanged, self._onReschedToggled)
def on_search_button(self): def on_search_button(self) -> None:
self._on_search_button(self.form.search)
def on_search_button_2(self) -> None:
self._on_search_button(self.form.search_2)
def _on_search_button(self, line: QLineEdit) -> None:
try: try:
search = self.mw.col.build_search_string(self.form.search.text()) search = self.mw.col.build_search_string(line.text())
except InvalidInput as err: except InvalidInput as err:
self.form.search.setFocus() line.setFocus()
self.form.search.selectAll() line.selectAll()
show_invalid_search_error(err) show_invalid_search_error(err)
else: else:
aqt.dialogs.open("Browser", self.mw, search=(search,)) aqt.dialogs.open("Browser", self.mw, search=(search,))

View File

@ -232,6 +232,7 @@
<addaction name="actionClose"/> <addaction name="actionClose"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionCreateFilteredDeck"/> <addaction name="actionCreateFilteredDeck"/>
<addaction name="actionCreateFilteredDeck2"/>
</widget> </widget>
<widget class="QMenu" name="menuJump"> <widget class="QMenu" name="menuJump">
<property name="title"> <property name="title">
@ -593,6 +594,14 @@
<string notr="true">Ctrl+G</string> <string notr="true">Ctrl+G</string>
</property> </property>
</action> </action>
<action name="actionCreateFilteredDeck2">
<property name="text">
<string>BROWSING_CREATE_FILTERED_DECK_2</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+G</string>
</property>
</action>
</widget> </widget>
<resources> <resources>
<include location="icons.qrc"/> <include location="icons.qrc"/>

View File

@ -20,22 +20,6 @@
<string>ACTIONS_FILTER</string> <string>ACTIONS_FILTER</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="search_button">
<property name="toolTip">
<string>SEARCH_VIEW_IN_BROWSER</string>
</property>
<property name="text">
<string>ACTIONS_SEARCH</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0"> <item row="2" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="label_5">
<property name="text"> <property name="text">
@ -43,12 +27,8 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="3"> <item row="1" column="2" colspan="4">
<widget class="QLabel" name="label"> <widget class="QLineEdit" name="search"/>
<property name="text">
<string>DECKS_CARDS_SELECTED_BY</string>
</property>
</widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QSpinBox" name="limit"> <widget class="QSpinBox" name="limit">
@ -69,8 +49,28 @@
<item row="2" column="4" colspan="2"> <item row="2" column="4" colspan="2">
<widget class="QComboBox" name="order"/> <widget class="QComboBox" name="order"/>
</item> </item>
<item row="1" column="2" colspan="4"> <item row="2" column="3">
<widget class="QLineEdit" name="search"/> <widget class="QLabel" name="label">
<property name="text">
<string>DECKS_CARDS_SELECTED_BY</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="search_button">
<property name="toolTip">
<string>SEARCH_VIEW_IN_BROWSER</string>
</property>
<property name="text">
<string>ACTIONS_SEARCH</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
@ -94,13 +94,6 @@
<item row="0" column="1" colspan="4"> <item row="0" column="1" colspan="4">
<widget class="QLineEdit" name="search_2"/> <widget class="QLineEdit" name="search_2"/>
</item> </item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>ACTIONS_SEARCH</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSpinBox" name="limit_2"> <widget class="QSpinBox" name="limit_2">
<property name="maximumSize"> <property name="maximumSize">
@ -124,6 +117,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0">
<widget class="QPushButton" name="search_button_2">
<property name="toolTip">
<string>SEARCH_VIEW_IN_BROWSER</string>
</property>
<property name="text">
<string>ACTIONS_SEARCH</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>