mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
allow user to pick graph save location
This commit is contained in:
parent
d3d96222bc
commit
1e2f934480
1 changed files with 13 additions and 8 deletions
21
aqt/stats.py
21
aqt/stats.py
|
@ -5,7 +5,7 @@
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import os, time
|
import os, time
|
||||||
from aqt.utils import saveGeom, restoreGeom, maybeHideClose, addCloseShortcut, \
|
from aqt.utils import saveGeom, restoreGeom, maybeHideClose, addCloseShortcut, \
|
||||||
tooltip
|
tooltip, getSaveFile
|
||||||
import aqt
|
import aqt
|
||||||
|
|
||||||
# Deck Stats
|
# Deck Stats
|
||||||
|
@ -52,20 +52,25 @@ class DeckStats(QDialog):
|
||||||
callback()
|
callback()
|
||||||
|
|
||||||
def _imagePath(self):
|
def _imagePath(self):
|
||||||
|
desktopPath = QStandardPaths.writableLocation(
|
||||||
|
QStandardPaths.DesktopLocation)
|
||||||
name = time.strftime("-%Y-%m-%d@%H-%M-%S.pdf",
|
name = time.strftime("-%Y-%m-%d@%H-%M-%S.pdf",
|
||||||
time.localtime(time.time()))
|
time.localtime(time.time()))
|
||||||
name = "anki-"+_("stats")+name
|
name = "anki-"+_("stats")+name
|
||||||
desktopPath = QStandardPaths.writableLocation(
|
file = os.path.join(desktopPath, name)
|
||||||
QStandardPaths.DesktopLocation)
|
file = getSaveFile(self, title=_("Save PDF"),
|
||||||
if not os.path.exists(desktopPath):
|
dir_description="stats",
|
||||||
os.mkdir(desktopPath)
|
key="stats",
|
||||||
path = os.path.join(desktopPath, name)
|
ext=".pdf",
|
||||||
return path
|
fname=file)
|
||||||
|
return file
|
||||||
|
|
||||||
def saveImage(self):
|
def saveImage(self):
|
||||||
path = self._imagePath()
|
path = self._imagePath()
|
||||||
|
if not path:
|
||||||
|
return
|
||||||
self.form.web.page().printToPdf(path)
|
self.form.web.page().printToPdf(path)
|
||||||
tooltip(_("A PDF file was saved to your desktop."))
|
tooltip(_("Saved."))
|
||||||
|
|
||||||
def changePeriod(self, n):
|
def changePeriod(self, n):
|
||||||
self.period = n
|
self.period = n
|
||||||
|
|
Loading…
Reference in a new issue