Add button in dynDeckConf to search in browser

This commit is contained in:
RumovZ 2021-02-01 13:55:03 +01:00
parent 0949cdc73e
commit 4d097b995d
4 changed files with 51 additions and 18 deletions

View File

@ -35,3 +35,5 @@ search-card-modified = Card Modified
##
# Tooltip for search lines outside browser
search-view-in-browser = View in browser

View File

@ -71,6 +71,7 @@ class DeckConf(QDialog):
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
)
self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
self.form.search.setFocus()
self.form.search.selectAll()
if self.mw.col.schedVer() == 1:
self.form.secondFilter.setVisible(False)
@ -83,7 +84,8 @@ class DeckConf(QDialog):
):
if search is not None:
self.form.search.setText(search)
self.form.search.selectAll()
self.form.search.setFocus()
self.form.search.selectAll()
def new_dyn_deck(self):
suffix: int = 1
@ -110,6 +112,8 @@ class DeckConf(QDialog):
)
def initialSetup(self):
qconnect(self.form.search_button.clicked, self.on_search_button)
import anki.consts as cs
self.form.order.addItems(list(cs.dynOrderLabels(self.mw.col).values()))
@ -117,6 +121,16 @@ class DeckConf(QDialog):
qconnect(self.form.resched.stateChanged, self._onReschedToggled)
def on_search_button(self):
try:
search = self.mw.col.build_search_string(self.form.search.text())
except InvalidInput as err:
self.form.search.setFocus()
self.form.search.selectAll()
show_invalid_search_error(err)
else:
aqt.dialogs.open("Browser", self.mw, search=(search,))
def _onReschedToggled(self, _state: int):
self.form.previewDelayWidget.setVisible(
not self.form.resched.isChecked() and self.mw.col.schedVer() > 1

View File

@ -548,7 +548,7 @@ class Editor:
first_field=self.note.fields[0],
)
),
)
),
)
def fieldsAreBlank(self, previousNote=None):

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>392</width>
<width>416</width>
<height>472</height>
</rect>
</property>
@ -21,20 +21,44 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="search_button">
<property name="font">
<font>
<underline>true</underline>
</font>
</property>
<property name="toolTip">
<string>SEARCH_VIEW_IN_BROWSER</string>
</property>
<property name="styleSheet">
<string notr="true">QPushButton { text-align: left; color: blue; padding: 0; border: 0 }</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">
<widget class="QLabel" name="label_5">
<property name="text">
<string>DECKS_LIMIT_TO</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<item row="2" column="3">
<widget class="QLabel" name="label">
<property name="text">
<string>ACTIONS_SEARCH</string>
<string>DECKS_CARDS_SELECTED_BY</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="2">
<widget class="QSpinBox" name="limit">
<property name="maximumSize">
<size>
@ -50,19 +74,12 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label">
<property name="text">
<string>DECKS_CARDS_SELECTED_BY</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="4">
<widget class="QLineEdit" name="search"/>
</item>
<item row="1" column="3" colspan="2">
<item row="2" column="4" colspan="2">
<widget class="QComboBox" name="order"/>
</item>
<item row="1" column="2" colspan="4">
<widget class="QLineEdit" name="search"/>
</item>
</layout>
</widget>
</item>