mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Make dyndeckconf a registered dialogue
This commit is contained in:
parent
0960ea6ece
commit
52867dfa6c
4 changed files with 21 additions and 11 deletions
|
@ -69,7 +69,7 @@ except ImportError as e:
|
|||
# - make preferences modal? cmd+q does wrong thing
|
||||
|
||||
|
||||
from aqt import addcards, addons, browser, editcurrent # isort:skip
|
||||
from aqt import addcards, addons, browser, editcurrent, dyndeckconf # isort:skip
|
||||
from aqt import stats, about, preferences, mediasync # isort:skip
|
||||
|
||||
|
||||
|
@ -80,6 +80,7 @@ class DialogManager:
|
|||
"AddonsDialog": [addons.AddonsDialog, None],
|
||||
"Browser": [browser.Browser, None],
|
||||
"EditCurrent": [editcurrent.EditCurrent, None],
|
||||
"DynDeckConfDialog": [dyndeckconf.DeckConf, None],
|
||||
"DeckStats": [stats.DeckStats, None],
|
||||
"NewDeckStats": [stats.NewDeckStats, None],
|
||||
"About": [about.show, None],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Copyright: Ankitects Pty Ltd and contributors
|
||||
# -*- coding: utf-8 -*-
|
||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||
from typing import List, Optional
|
||||
from typing import Callable, List, Optional
|
||||
|
||||
import aqt
|
||||
from anki.collection import SearchTerm
|
||||
|
@ -67,14 +67,19 @@ class DeckConf(QDialog):
|
|||
self.setWindowTitle(
|
||||
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
|
||||
)
|
||||
restoreGeom(self, "dyndeckconf")
|
||||
self.ok = self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
|
||||
self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
|
||||
self.form.search.selectAll()
|
||||
if self.mw.col.schedVer() == 1:
|
||||
self.form.secondFilter.setVisible(False)
|
||||
restoreGeom(self, "dyndeckconf")
|
||||
|
||||
self.show()
|
||||
|
||||
def reopen(self, _mw, search: Optional[str] = None, _deck: Optional[Deck] = None):
|
||||
if search is not None:
|
||||
self.form.search.setText(search)
|
||||
self.form.search.selectAll()
|
||||
|
||||
def new_dyn_deck(self):
|
||||
suffix: int = 1
|
||||
while self.mw.col.decks.id_for_name(
|
||||
|
@ -178,6 +183,7 @@ class DeckConf(QDialog):
|
|||
self.mw.col.decks.select(self.old_deck["id"])
|
||||
saveGeom(self, "dyndeckconf")
|
||||
QDialog.reject(self)
|
||||
aqt.dialogs.markClosed("DynDeckConfDialog")
|
||||
|
||||
def accept(self):
|
||||
try:
|
||||
|
@ -191,6 +197,11 @@ class DeckConf(QDialog):
|
|||
saveGeom(self, "dyndeckconf")
|
||||
self.mw.reset()
|
||||
QDialog.accept(self)
|
||||
aqt.dialogs.markClosed("DynDeckConfDialog")
|
||||
|
||||
def closeWithCallback(self, callback: Callable):
|
||||
self.reject()
|
||||
callback()
|
||||
|
||||
# Step load/save - fixme: share with std options screen
|
||||
########################################################
|
||||
|
|
|
@ -1054,9 +1054,9 @@ title="%s" %s>%s</button>""" % (
|
|||
if not deck:
|
||||
deck = self.col.decks.current()
|
||||
if deck["dyn"]:
|
||||
import aqt.dyndeckconf
|
||||
import aqt
|
||||
|
||||
aqt.dyndeckconf.DeckConf(self, deck=deck)
|
||||
aqt.dialogs.open("DynDeckConfDialog", self, None, deck)
|
||||
else:
|
||||
import aqt.deckconf
|
||||
|
||||
|
@ -1134,10 +1134,8 @@ title="%s" %s>%s</button>""" % (
|
|||
# Cramming
|
||||
##########################################################################
|
||||
|
||||
def onCram(self, search=""):
|
||||
import aqt.dyndeckconf
|
||||
|
||||
aqt.dyndeckconf.DeckConf(self)
|
||||
def onCram(self):
|
||||
aqt.dialogs.open("DynDeckConfDialog", self)
|
||||
|
||||
# Menu, title bar & status
|
||||
##########################################################################
|
||||
|
|
|
@ -71,7 +71,7 @@ class Overview:
|
|||
elif url == "opts":
|
||||
self.mw.onDeckConf()
|
||||
elif url == "cram":
|
||||
self.mw.onCram()
|
||||
aqt.dialogs.open("DynDeckConfDialog", self.mw)
|
||||
elif url == "refresh":
|
||||
self.mw.col.sched.rebuild_filtered_deck(self.mw.col.decks.selected())
|
||||
self.mw.reset()
|
||||
|
|
Loading…
Reference in a new issue