fix description in export screen (thanks to ANH)

https://forums.ankiweb.net/t/anki-2-1-31-exporting-display-bug/2669/3
This commit is contained in:
Damien Elmes 2020-08-26 08:33:35 +10:00
parent 068eca5319
commit 5355c3c25e
2 changed files with 11 additions and 7 deletions

View File

@ -92,7 +92,7 @@ class Exporter:
class TextCardExporter(Exporter): class TextCardExporter(Exporter):
key = lambda: _("Cards in Plain Text") key = lambda self: _("Cards in Plain Text")
ext = ".txt" ext = ".txt"
includeHTML = True includeHTML = True
@ -122,7 +122,7 @@ class TextCardExporter(Exporter):
class TextNoteExporter(Exporter): class TextNoteExporter(Exporter):
key = lambda: _("Notes in Plain Text") key = lambda self: _("Notes in Plain Text")
ext = ".txt" ext = ".txt"
includeTags = True includeTags = True
includeHTML = True includeHTML = True
@ -164,7 +164,7 @@ where cards.id in %s)"""
class AnkiExporter(Exporter): class AnkiExporter(Exporter):
key = lambda: _("Anki 2.0 Deck") key = lambda self: _("Anki 2.0 Deck")
ext = ".anki2" ext = ".anki2"
includeSched: Union[bool, None] = False includeSched: Union[bool, None] = False
includeMedia = True includeMedia = True
@ -313,7 +313,7 @@ class AnkiExporter(Exporter):
class AnkiPackageExporter(AnkiExporter): class AnkiPackageExporter(AnkiExporter):
key = lambda: _("Anki Deck Package") key = lambda self: _("Anki Deck Package")
ext = ".apkg" ext = ".apkg"
def __init__(self, col: Collection) -> None: def __init__(self, col: Collection) -> None:
@ -394,7 +394,7 @@ class AnkiPackageExporter(AnkiExporter):
class AnkiCollectionPackageExporter(AnkiPackageExporter): class AnkiCollectionPackageExporter(AnkiPackageExporter):
key = lambda: _("Anki Collection Package") key = lambda self: _("Anki Collection Package")
ext = ".colpkg" ext = ".colpkg"
verbatim = True verbatim = True
includeSched = None includeSched = None
@ -427,7 +427,7 @@ class AnkiCollectionPackageExporter(AnkiPackageExporter):
def exporters() -> List[Tuple[str, Any]]: def exporters() -> List[Tuple[str, Any]]:
def id(obj): def id(obj):
if callable(obj.key): if callable(obj.key):
key_str = obj.key() key_str = obj.key(obj)
else: else:
key_str = obj.key key_str = obj.key
return ("%s (*%s)" % (key_str, obj.ext), obj) return ("%s (*%s)" % (key_str, obj.ext), obj)

View File

@ -114,12 +114,16 @@ class ExportDialog(QDialog):
deck_name = re.sub('[\\\\/?<>:*|"^]', "_", deck_name) deck_name = re.sub('[\\\\/?<>:*|"^]', "_", deck_name)
filename = "{0}{1}".format(deck_name, self.exporter.ext) filename = "{0}{1}".format(deck_name, self.exporter.ext)
if callable(self.exporter.key):
key_str = self.exporter.key()
else:
key_str = self.exporter.key
while 1: while 1:
file = getSaveFile( file = getSaveFile(
self, self,
_("Export"), _("Export"),
"export", "export",
self.exporter.key, key_str,
self.exporter.ext, self.exporter.ext,
fname=filename, fname=filename,
) )