Windows: Make recently opened books show up in the jump lists for the viewer and the editor

This commit is contained in:
Kovid Goyal 2017-02-01 16:53:58 +05:30
parent 2353d5926e
commit ff3cc55f21
2 changed files with 15 additions and 1 deletions

View File

@ -15,7 +15,7 @@ from PyQt5.Qt import (
QDialogButtonBox, QIcon, QInputDialog, QUrl, pyqtSignal) QDialogButtonBox, QIcon, QInputDialog, QUrl, pyqtSignal)
from calibre import prints, isbytestring from calibre import prints, isbytestring
from calibre.constants import cache_dir from calibre.constants import cache_dir, iswindows
from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory from calibre.ptempfile import PersistentTemporaryDirectory, TemporaryDirectory
from calibre.ebooks.oeb.base import urlnormalize from calibre.ebooks.oeb.base import urlnormalize
from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish from calibre.ebooks.oeb.polish.main import SUPPORTED, tweak_polish
@ -342,6 +342,13 @@ class Boss(QObject):
recent_books.insert(0, path) recent_books.insert(0, path)
tprefs['recent-books'] = recent_books[:10] tprefs['recent-books'] = recent_books[:10]
self.gui.update_recent_books() self.gui.update_recent_books()
if iswindows:
try:
from win32com.shell import shell, shellcon
shell.SHAddToRecentDocs(shellcon.SHARD_PATHW, path)
except Exception:
import traceback
traceback.print_exc()
if ef: if ef:
if isinstance(ef, type('')): if isinstance(ef, type('')):
ef = [ef] ef = [ef]

View File

@ -1000,6 +1000,13 @@ class EbookViewer(MainWindow):
pass pass
vh.insert(0, pathtoebook) vh.insert(0, pathtoebook)
vprefs.set('viewer_open_history', vh[:50]) vprefs.set('viewer_open_history', vh[:50])
if iswindows:
try:
from win32com.shell import shell, shellcon
shell.SHAddToRecentDocs(shellcon.SHARD_PATHW, pathtoebook)
except Exception:
import traceback
traceback.print_exc()
self.build_recent_menu() self.build_recent_menu()
self.view.set_book_data(self.iterator) self.view.set_book_data(self.iterator)