default to deckname.apkg on single deck export (#618)
This commit is contained in:
parent
85cb7ef47e
commit
9707786eea
@ -66,10 +66,15 @@ class ExportDialog(QDialog):
|
|||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
verbatim = False
|
verbatim = False
|
||||||
|
deck_name = self.decks[self.frm.deck.currentIndex()]
|
||||||
|
filename = os.path.join(aqt.mw.pm.base,
|
||||||
|
'{}.apkg'.format(deck_name))
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
file = getSaveFile(
|
file = getSaveFile(
|
||||||
self, _("Export"), "export",
|
self, _("Export"), "export",
|
||||||
self.exporter.key, self.exporter.ext)
|
self.exporter.key, self.exporter.ext,
|
||||||
|
initial_path=filename)
|
||||||
if not file:
|
if not file:
|
||||||
return
|
return
|
||||||
if checkInvalidFilename(os.path.basename(file), dirsep=False):
|
if checkInvalidFilename(os.path.basename(file), dirsep=False):
|
||||||
|
19
aqt/utils.py
19
aqt/utils.py
@ -252,19 +252,28 @@ def getFile(parent, title, cb, filter="*.*", dir=None, key=None):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
return ret and ret[0]
|
return ret and ret[0]
|
||||||
|
|
||||||
def getSaveFile(parent, title, dir, key, ext):
|
def getSaveFile(parent, title, dir_description, key, ext,
|
||||||
"Ask the user for a file to save. Use DIR as config variable."
|
initial_path=None):
|
||||||
dirkey = dir+"Directory"
|
"""Ask the user for a file to save. Use DIR_DESCRIPTION as config
|
||||||
|
variable. The file dialog will open with an initial path of
|
||||||
|
INITIAL_PATH (this may be the path of a file or directory)."""
|
||||||
|
|
||||||
|
if initial_path is None:
|
||||||
|
initial_path = aqt.mw.pm.base
|
||||||
|
|
||||||
file = unicode(QFileDialog.getSaveFileName(
|
file = unicode(QFileDialog.getSaveFileName(
|
||||||
parent, title, aqt.mw.pm.base, "{0} (*{1})".format(key, ext),
|
parent, title, initial_path, "{0} (*{1})".format(key, ext),
|
||||||
options=QFileDialog.DontConfirmOverwrite))
|
options=QFileDialog.DontConfirmOverwrite))
|
||||||
if file:
|
if file:
|
||||||
# add extension
|
# add extension
|
||||||
if not file.lower().endswith(ext):
|
if not file.lower().endswith(ext):
|
||||||
file += ext
|
file += ext
|
||||||
|
|
||||||
# save new default
|
# save new default
|
||||||
|
config_key = dir_description + 'Directory'
|
||||||
dir = os.path.dirname(file)
|
dir = os.path.dirname(file)
|
||||||
aqt.mw.pm.profile[dirkey] = dir
|
aqt.mw.pm.profile[config_key] = dir
|
||||||
|
|
||||||
# check if it exists
|
# check if it exists
|
||||||
if os.path.exists(file):
|
if os.path.exists(file):
|
||||||
if not askUser(
|
if not askUser(
|
||||||
|
Loading…
Reference in New Issue
Block a user