mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
save stats image to desktop instead of temp folder
This commit is contained in:
parent
5e18d8856b
commit
b7ccf406c3
1 changed files with 10 additions and 4 deletions
14
aqt/stats.py
14
aqt/stats.py
|
@ -3,9 +3,10 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from aqt.qt import *
|
from aqt.qt import *
|
||||||
import os
|
import os, time
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
from aqt.utils import saveGeom, restoreGeom, maybeHideClose, openFolder
|
from aqt.utils import saveGeom, restoreGeom, maybeHideClose, openFolder, \
|
||||||
|
showInfo
|
||||||
from anki.utils import namedtmp
|
from anki.utils import namedtmp
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
import aqt
|
import aqt
|
||||||
|
@ -50,7 +51,12 @@ class DeckStats(QDialog):
|
||||||
|
|
||||||
def browser(self):
|
def browser(self):
|
||||||
# dump to a temporary file
|
# dump to a temporary file
|
||||||
path = namedtmp("report.png")
|
name = time.strftime("-%Y-%m-%d@%H-%M-%S.png",
|
||||||
|
time.localtime(time.time()))
|
||||||
|
name = "anki-"+_("stats")+name
|
||||||
|
path = os.path.join(
|
||||||
|
QDesktopServices.storageLocation(QDesktopServices.DesktopLocation),
|
||||||
|
name)
|
||||||
p = self.form.web.page()
|
p = self.form.web.page()
|
||||||
oldsize = p.viewportSize()
|
oldsize = p.viewportSize()
|
||||||
p.setViewportSize(p.mainFrame().contentsSize())
|
p.setViewportSize(p.mainFrame().contentsSize())
|
||||||
|
@ -60,7 +66,7 @@ class DeckStats(QDialog):
|
||||||
painter.end()
|
painter.end()
|
||||||
image.save(path, "png")
|
image.save(path, "png")
|
||||||
p.setViewportSize(oldsize)
|
p.setViewportSize(oldsize)
|
||||||
openFolder(path)
|
showInfo(_("An image was saved to your desktop."))
|
||||||
|
|
||||||
def changePeriod(self, n):
|
def changePeriod(self, n):
|
||||||
self.period = n
|
self.period = n
|
||||||
|
|
Loading…
Reference in a new issue