mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 08:46:37 -04:00
strip html option on import, and option to customize deck import location
This commit is contained in:
parent
b0c28d33b2
commit
8ec9572265
2 changed files with 18 additions and 1 deletions
|
@ -139,6 +139,7 @@ you can enter it here. Use \\t to represent tab."""),
|
|||
_("The first field of the note type must be mapped."))
|
||||
return
|
||||
self.importer.importMode = self.frm.importMode.currentIndex()
|
||||
self.importer.allowHTML = self.frm.allowHTML.isChecked()
|
||||
did = self.deck.selectedId()
|
||||
if did != self.importer.model['did']:
|
||||
self.importer.model['did'] = did
|
||||
|
@ -291,6 +292,13 @@ backup, please see the 'Backups' section of the user manual."""))
|
|||
if importer.__class__.__name__ == "AnkiPackageImporter":
|
||||
if not setupApkgImport(mw, importer):
|
||||
return
|
||||
def prepareImportPrefix(name):
|
||||
mw.progress.finish()
|
||||
new = getOnlyText(_("""\
|
||||
Deck to import into (if blank, will import into current deck):"""), default=name)
|
||||
mw.progress.start()
|
||||
return new or mw.col.decks.current()['name']
|
||||
addHook("prepareImportPrefix", prepareImportPrefix)
|
||||
mw.progress.start(immediate=True)
|
||||
try:
|
||||
importer.run()
|
||||
|
@ -316,12 +324,14 @@ Unable to import from a read-only file."""))
|
|||
showText(log)
|
||||
finally:
|
||||
mw.progress.finish()
|
||||
remHook("prepareImportPrefix", prepareImportPrefix)
|
||||
mw.reset()
|
||||
|
||||
def setupApkgImport(mw, importer):
|
||||
base = os.path.basename(importer.file).lower()
|
||||
full = (base == "collection.apkg") or re.match("backup-\d+.apkg", base)
|
||||
if not full:
|
||||
# adding
|
||||
return True
|
||||
if not askUser(_("""\
|
||||
This will delete your existing collection and replace it with the data in \
|
||||
|
|
|
@ -70,6 +70,13 @@
|
|||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="allowHTML">
|
||||
<property name="text">
|
||||
<string>Allow HTML in fields</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -127,7 +134,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>402</width>
|
||||
<height>229</height>
|
||||
<height>206</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
|
Loading…
Reference in a new issue