From 2c05c874d7c301cf86fcc2a44c08b7f4fbb92d91 Mon Sep 17 00:00:00 2001 From: "Soren I. Bjornstad" Date: Tue, 5 Aug 2014 11:25:24 -0500 Subject: [PATCH] fall back to homedir on collection package export if no desktop --- aqt/exporting.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/aqt/exporting.py b/aqt/exporting.py index bc373b077..3d80266b4 100644 --- a/aqt/exporting.py +++ b/aqt/exporting.py @@ -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