mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
Make DialogManager accept kwargs
When opening a dialogue accepting multiple optional arguments, relying on position is error-prone and requires passing Nones to fill unused parameter slots.
This commit is contained in:
parent
011b562038
commit
5aac81d15f
3 changed files with 7 additions and 7 deletions
|
@ -88,7 +88,7 @@ class DialogManager:
|
|||
"sync_log": [mediasync.MediaSyncDialog, None],
|
||||
}
|
||||
|
||||
def open(self, name: str, *args: Any) -> Any:
|
||||
def open(self, name: str, *args: Any, **kwargs: Any) -> Any:
|
||||
(creator, instance) = self._dialogs[name]
|
||||
if instance:
|
||||
if instance.windowState() & Qt.WindowMinimized:
|
||||
|
@ -96,12 +96,11 @@ class DialogManager:
|
|||
instance.activateWindow()
|
||||
instance.raise_()
|
||||
if hasattr(instance, "reopen"):
|
||||
instance.reopen(*args)
|
||||
return instance
|
||||
instance.reopen(*args, **kwargs)
|
||||
else:
|
||||
instance = creator(*args)
|
||||
instance = creator(*args, **kwargs)
|
||||
self._dialogs[name][1] = instance
|
||||
return instance
|
||||
return instance
|
||||
|
||||
def markClosed(self, name: str):
|
||||
self._dialogs[name] = [self._dialogs[name][0], None]
|
||||
|
|
|
@ -1160,7 +1160,8 @@ where id in %s"""
|
|||
ChangeModel(self, nids)
|
||||
|
||||
def filterToDeck(self):
|
||||
aqt.dialogs.open("DynDeckConfDialog", self.mw, self.form.searchEdit.lineEdit().text())
|
||||
search = self.form.searchEdit.lineEdit().text()
|
||||
aqt.dialogs.open("DynDeckConfDialog", self.mw, search=search)
|
||||
|
||||
# Preview
|
||||
######################################################################
|
||||
|
|
|
@ -1056,7 +1056,7 @@ title="%s" %s>%s</button>""" % (
|
|||
if deck["dyn"]:
|
||||
import aqt
|
||||
|
||||
aqt.dialogs.open("DynDeckConfDialog", self, None, deck)
|
||||
aqt.dialogs.open("DynDeckConfDialog", self, deck=deck)
|
||||
else:
|
||||
import aqt.deckconf
|
||||
|
||||
|
|
Loading…
Reference in a new issue