mirror of
https://github.com/ankitects/anki.git
synced 2025-12-12 22:36:55 -05: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
|
# - 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
|
from aqt import stats, about, preferences, mediasync # isort:skip
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -80,6 +80,7 @@ class DialogManager:
|
||||||
"AddonsDialog": [addons.AddonsDialog, None],
|
"AddonsDialog": [addons.AddonsDialog, None],
|
||||||
"Browser": [browser.Browser, None],
|
"Browser": [browser.Browser, None],
|
||||||
"EditCurrent": [editcurrent.EditCurrent, None],
|
"EditCurrent": [editcurrent.EditCurrent, None],
|
||||||
|
"DynDeckConfDialog": [dyndeckconf.DeckConf, None],
|
||||||
"DeckStats": [stats.DeckStats, None],
|
"DeckStats": [stats.DeckStats, None],
|
||||||
"NewDeckStats": [stats.NewDeckStats, None],
|
"NewDeckStats": [stats.NewDeckStats, None],
|
||||||
"About": [about.show, None],
|
"About": [about.show, None],
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
# Copyright: Ankitects Pty Ltd and contributors
|
# Copyright: Ankitects Pty Ltd and contributors
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# 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
|
import aqt
|
||||||
from anki.collection import SearchTerm
|
from anki.collection import SearchTerm
|
||||||
|
|
@ -67,14 +67,19 @@ class DeckConf(QDialog):
|
||||||
self.setWindowTitle(
|
self.setWindowTitle(
|
||||||
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
|
without_unicode_isolation(tr(TR.ACTIONS_OPTIONS_FOR, val=self.deck["name"]))
|
||||||
)
|
)
|
||||||
restoreGeom(self, "dyndeckconf")
|
self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
|
||||||
self.ok = self.form.buttonBox.addButton(label, QDialogButtonBox.AcceptRole)
|
|
||||||
self.form.search.selectAll()
|
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")
|
||||||
|
|
||||||
self.show()
|
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):
|
def new_dyn_deck(self):
|
||||||
suffix: int = 1
|
suffix: int = 1
|
||||||
while self.mw.col.decks.id_for_name(
|
while self.mw.col.decks.id_for_name(
|
||||||
|
|
@ -178,6 +183,7 @@ class DeckConf(QDialog):
|
||||||
self.mw.col.decks.select(self.old_deck["id"])
|
self.mw.col.decks.select(self.old_deck["id"])
|
||||||
saveGeom(self, "dyndeckconf")
|
saveGeom(self, "dyndeckconf")
|
||||||
QDialog.reject(self)
|
QDialog.reject(self)
|
||||||
|
aqt.dialogs.markClosed("DynDeckConfDialog")
|
||||||
|
|
||||||
def accept(self):
|
def accept(self):
|
||||||
try:
|
try:
|
||||||
|
|
@ -191,6 +197,11 @@ class DeckConf(QDialog):
|
||||||
saveGeom(self, "dyndeckconf")
|
saveGeom(self, "dyndeckconf")
|
||||||
self.mw.reset()
|
self.mw.reset()
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
aqt.dialogs.markClosed("DynDeckConfDialog")
|
||||||
|
|
||||||
|
def closeWithCallback(self, callback: Callable):
|
||||||
|
self.reject()
|
||||||
|
callback()
|
||||||
|
|
||||||
# Step load/save - fixme: share with std options screen
|
# Step load/save - fixme: share with std options screen
|
||||||
########################################################
|
########################################################
|
||||||
|
|
|
||||||
|
|
@ -1054,9 +1054,9 @@ title="%s" %s>%s</button>""" % (
|
||||||
if not deck:
|
if not deck:
|
||||||
deck = self.col.decks.current()
|
deck = self.col.decks.current()
|
||||||
if deck["dyn"]:
|
if deck["dyn"]:
|
||||||
import aqt.dyndeckconf
|
import aqt
|
||||||
|
|
||||||
aqt.dyndeckconf.DeckConf(self, deck=deck)
|
aqt.dialogs.open("DynDeckConfDialog", self, None, deck)
|
||||||
else:
|
else:
|
||||||
import aqt.deckconf
|
import aqt.deckconf
|
||||||
|
|
||||||
|
|
@ -1134,10 +1134,8 @@ title="%s" %s>%s</button>""" % (
|
||||||
# Cramming
|
# Cramming
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def onCram(self, search=""):
|
def onCram(self):
|
||||||
import aqt.dyndeckconf
|
aqt.dialogs.open("DynDeckConfDialog", self)
|
||||||
|
|
||||||
aqt.dyndeckconf.DeckConf(self)
|
|
||||||
|
|
||||||
# Menu, title bar & status
|
# Menu, title bar & status
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ class Overview:
|
||||||
elif url == "opts":
|
elif url == "opts":
|
||||||
self.mw.onDeckConf()
|
self.mw.onDeckConf()
|
||||||
elif url == "cram":
|
elif url == "cram":
|
||||||
self.mw.onCram()
|
aqt.dialogs.open("DynDeckConfDialog", self.mw)
|
||||||
elif url == "refresh":
|
elif url == "refresh":
|
||||||
self.mw.col.sched.rebuild_filtered_deck(self.mw.col.decks.selected())
|
self.mw.col.sched.rebuild_filtered_deck(self.mw.col.decks.selected())
|
||||||
self.mw.reset()
|
self.mw.reset()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue