Normalize dyndeck search and handle exception
This commit is contained in:
parent
060fdc824b
commit
52c27e7b99
@ -5,6 +5,7 @@ from typing import List, Optional
|
|||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
from anki.lang import without_unicode_isolation
|
from anki.lang import without_unicode_isolation
|
||||||
|
from anki.rsbackend import InvalidInput
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
from aqt.utils import (
|
from aqt.utils import (
|
||||||
TR,
|
TR,
|
||||||
@ -13,6 +14,7 @@ from aqt.utils import (
|
|||||||
openHelp,
|
openHelp,
|
||||||
restoreGeom,
|
restoreGeom,
|
||||||
saveGeom,
|
saveGeom,
|
||||||
|
show_invalid_search_error,
|
||||||
showWarning,
|
showWarning,
|
||||||
tr,
|
tr,
|
||||||
)
|
)
|
||||||
@ -114,25 +116,27 @@ class DeckConf(QDialog):
|
|||||||
else:
|
else:
|
||||||
d["delays"] = None
|
d["delays"] = None
|
||||||
|
|
||||||
terms = [[f.search.text(), f.limit.value(), f.order.currentIndex()]]
|
search = self.mw.col.backend.normalize_search(f.search.text())
|
||||||
|
terms = [[search, f.limit.value(), f.order.currentIndex()]]
|
||||||
|
|
||||||
if f.secondFilter.isChecked():
|
if f.secondFilter.isChecked():
|
||||||
terms.append(
|
search_2 = self.mw.col.backend.normalize_search(f.search_2.text())
|
||||||
[f.search_2.text(), f.limit_2.value(), f.order_2.currentIndex()]
|
terms.append([search_2, f.limit_2.value(), f.order_2.currentIndex()])
|
||||||
)
|
|
||||||
|
|
||||||
d["terms"] = terms
|
d["terms"] = terms
|
||||||
d["previewDelay"] = f.previewDelay.value()
|
d["previewDelay"] = f.previewDelay.value()
|
||||||
|
|
||||||
self.mw.col.decks.save(d)
|
self.mw.col.decks.save(d)
|
||||||
return True
|
|
||||||
|
|
||||||
def reject(self):
|
def reject(self):
|
||||||
self.ok = False
|
self.ok = False
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
if not self.saveConf():
|
try:
|
||||||
|
self.saveConf()
|
||||||
|
except InvalidInput as err:
|
||||||
|
show_invalid_search_error(err)
|
||||||
return
|
return
|
||||||
if not self.mw.col.sched.rebuild_filtered_deck(self.deck["id"]):
|
if not self.mw.col.sched.rebuild_filtered_deck(self.deck["id"]):
|
||||||
if askUser(tr(TR.DECKS_THE_PROVIDED_SEARCH_DID_NOT_MATCH)):
|
if askUser(tr(TR.DECKS_THE_PROVIDED_SEARCH_DID_NOT_MATCH)):
|
||||||
|
Loading…
Reference in New Issue
Block a user