mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
fall back to homedir on collection package export if no desktop
This commit is contained in:
parent
96818a07c7
commit
2c05c874d7
1 changed files with 16 additions and 5 deletions
|
@ -64,13 +64,20 @@ class ExportDialog(QDialog):
|
|||
self.exporter.did):
|
||||
verbatim = True
|
||||
# it's a verbatim apkg export, so place on desktop instead of
|
||||
# choosing file
|
||||
# choosing file; use homedir if no desktop
|
||||
usingHomedir = False
|
||||
file = os.path.join(QDesktopServices.storageLocation(
|
||||
QDesktopServices.DesktopLocation), "collection.apkg")
|
||||
if not os.path.exists(os.path.dirname(file)):
|
||||
usingHomedir = True
|
||||
file = os.path.join(QDesktopServices.storageLocation(
|
||||
QDesktopServices.HomeLocation), "collection.apkg")
|
||||
if os.path.exists(file):
|
||||
if not askUser(
|
||||
_("%s already exists on your desktop. Overwrite it?")%
|
||||
"collection.apkg"):
|
||||
if usingHomedir:
|
||||
question = _("%s already exists in your home directory. Overwrite it?")
|
||||
else:
|
||||
question = _("%s already exists on your desktop. Overwrite it?")
|
||||
if not askUser(question % "collection.apkg"):
|
||||
return
|
||||
else:
|
||||
verbatim = False
|
||||
|
@ -100,7 +107,11 @@ class ExportDialog(QDialog):
|
|||
os.unlink(file)
|
||||
self.exporter.exportInto(file)
|
||||
if verbatim:
|
||||
msg = _("A file called collection.apkg was saved on your desktop.")
|
||||
if usingHomedir:
|
||||
msg = _("A file called %s was saved in your home directory.")
|
||||
else:
|
||||
msg = _("A file called %s was saved on your desktop.")
|
||||
msg = msg % "collection.apkg"
|
||||
period = 5000
|
||||
else:
|
||||
period = 3000
|
||||
|
|
Loading…
Reference in a new issue