fall back to homedir on collection package export if no desktop

This commit is contained in:
Soren I. Bjornstad 2014-08-05 11:25:24 -05:00
parent 96818a07c7
commit 2c05c874d7

View file

@ -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