mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -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],
|
"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]
|
(creator, instance) = self._dialogs[name]
|
||||||
if instance:
|
if instance:
|
||||||
if instance.windowState() & Qt.WindowMinimized:
|
if instance.windowState() & Qt.WindowMinimized:
|
||||||
|
@ -96,12 +96,11 @@ class DialogManager:
|
||||||
instance.activateWindow()
|
instance.activateWindow()
|
||||||
instance.raise_()
|
instance.raise_()
|
||||||
if hasattr(instance, "reopen"):
|
if hasattr(instance, "reopen"):
|
||||||
instance.reopen(*args)
|
instance.reopen(*args, **kwargs)
|
||||||
return instance
|
|
||||||
else:
|
else:
|
||||||
instance = creator(*args)
|
instance = creator(*args, **kwargs)
|
||||||
self._dialogs[name][1] = instance
|
self._dialogs[name][1] = instance
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def markClosed(self, name: str):
|
def markClosed(self, name: str):
|
||||||
self._dialogs[name] = [self._dialogs[name][0], None]
|
self._dialogs[name] = [self._dialogs[name][0], None]
|
||||||
|
|
|
@ -1160,7 +1160,8 @@ where id in %s"""
|
||||||
ChangeModel(self, nids)
|
ChangeModel(self, nids)
|
||||||
|
|
||||||
def filterToDeck(self):
|
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
|
# Preview
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ title="%s" %s>%s</button>""" % (
|
||||||
if deck["dyn"]:
|
if deck["dyn"]:
|
||||||
import aqt
|
import aqt
|
||||||
|
|
||||||
aqt.dialogs.open("DynDeckConfDialog", self, None, deck)
|
aqt.dialogs.open("DynDeckConfDialog", self, deck=deck)
|
||||||
else:
|
else:
|
||||||
import aqt.deckconf
|
import aqt.deckconf
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue