mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement a 'remember current page' option in the viewer.
This commit is contained in:
parent
e655d8b77f
commit
eaea0d2aa6
@ -171,6 +171,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_remember_current_page">
|
||||
<property name="text">
|
||||
<string>Remember the &current page when quitting</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="max_view_width">
|
||||
<property name="suffix">
|
||||
|
@ -50,6 +50,8 @@ def config(defaults=None):
|
||||
c.add_opt('hyphenate', default=False, help=_('Hyphenate text'))
|
||||
c.add_opt('hyphenate_default_lang', default='en',
|
||||
help=_('Default language for hyphenation rules'))
|
||||
c.add_opt('remember_current_page', default=True,
|
||||
help=_('Save the current position in the documentwhen quitting'))
|
||||
|
||||
fonts = c.add_group('FONTS', _('Font options'))
|
||||
fonts('serif_family', default='Times New Roman' if iswindows else 'Liberation Serif',
|
||||
@ -72,6 +74,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
|
||||
opts = config().parse()
|
||||
self.opt_remember_window_size.setChecked(opts.remember_window_size)
|
||||
self.opt_remember_current_page.setChecked(opts.remember_current_page)
|
||||
self.serif_family.setCurrentFont(QFont(opts.serif_family))
|
||||
self.sans_family.setCurrentFont(QFont(opts.sans_family))
|
||||
self.mono_family.setCurrentFont(QFont(opts.mono_family))
|
||||
@ -118,6 +121,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
c.set('fit_images', self.opt_fit_images.isChecked())
|
||||
c.set('max_view_width', int(self.max_view_width.value()))
|
||||
c.set('hyphenate', self.hyphenate.isChecked())
|
||||
c.set('remember_current_page', self.opt_remember_current_page.isChecked())
|
||||
idx = self.hyphenate_default_lang.currentIndex()
|
||||
c.set('hyphenate_default_lang',
|
||||
str(self.hyphenate_default_lang.itemData(idx).toString()))
|
||||
|
@ -328,6 +328,11 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
c = config().parse()
|
||||
self.frame.setMaximumWidth(c.max_view_width)
|
||||
|
||||
def get_remember_current_page_opt(self):
|
||||
from calibre.gui2.viewer.documentview import config
|
||||
c = config().parse()
|
||||
return c.remember_current_page
|
||||
|
||||
def print_book(self, preview):
|
||||
Printing(self.iterator.spine, preview)
|
||||
|
||||
@ -578,7 +583,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
current_page = None
|
||||
self.existing_bookmarks = []
|
||||
for bm in bookmarks:
|
||||
if bm[0] == 'calibre_current_page_bookmark':
|
||||
if bm[0] == 'calibre_current_page_bookmark' and \
|
||||
self.get_remember_current_page_opt():
|
||||
current_page = bm
|
||||
else:
|
||||
self.existing_bookmarks.append(bm[0])
|
||||
@ -598,6 +604,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
||||
self.set_bookmarks(bookmarks)
|
||||
|
||||
def save_current_position(self):
|
||||
if not self.get_remember_current_page_opt():
|
||||
return
|
||||
try:
|
||||
pos = self.view.bookmark()
|
||||
bookmark = '%d#%s'%(self.current_index, pos)
|
||||
|
Loading…
x
Reference in New Issue
Block a user