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): self.exporter.did):
verbatim = True verbatim = True
# it's a verbatim apkg export, so place on desktop instead of # 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( file = os.path.join(QDesktopServices.storageLocation(
QDesktopServices.DesktopLocation), "collection.apkg") 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 os.path.exists(file):
if not askUser( if usingHomedir:
_("%s already exists on your desktop. Overwrite it?")% question = _("%s already exists in your home directory. Overwrite it?")
"collection.apkg"): else:
question = _("%s already exists on your desktop. Overwrite it?")
if not askUser(question % "collection.apkg"):
return return
else: else:
verbatim = False verbatim = False
@ -100,7 +107,11 @@ class ExportDialog(QDialog):
os.unlink(file) os.unlink(file)
self.exporter.exportInto(file) self.exporter.exportInto(file)
if verbatim: 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 period = 5000
else: else:
period = 3000 period = 3000