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>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="3" column="1">
|
||||||
<widget class="QSpinBox" name="max_view_width">
|
<widget class="QSpinBox" name="max_view_width">
|
||||||
<property name="suffix">
|
<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=False, help=_('Hyphenate text'))
|
||||||
c.add_opt('hyphenate_default_lang', default='en',
|
c.add_opt('hyphenate_default_lang', default='en',
|
||||||
help=_('Default language for hyphenation rules'))
|
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 = c.add_group('FONTS', _('Font options'))
|
||||||
fonts('serif_family', default='Times New Roman' if iswindows else 'Liberation Serif',
|
fonts('serif_family', default='Times New Roman' if iswindows else 'Liberation Serif',
|
||||||
@ -72,6 +74,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
|
|
||||||
opts = config().parse()
|
opts = config().parse()
|
||||||
self.opt_remember_window_size.setChecked(opts.remember_window_size)
|
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.serif_family.setCurrentFont(QFont(opts.serif_family))
|
||||||
self.sans_family.setCurrentFont(QFont(opts.sans_family))
|
self.sans_family.setCurrentFont(QFont(opts.sans_family))
|
||||||
self.mono_family.setCurrentFont(QFont(opts.mono_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('fit_images', self.opt_fit_images.isChecked())
|
||||||
c.set('max_view_width', int(self.max_view_width.value()))
|
c.set('max_view_width', int(self.max_view_width.value()))
|
||||||
c.set('hyphenate', self.hyphenate.isChecked())
|
c.set('hyphenate', self.hyphenate.isChecked())
|
||||||
|
c.set('remember_current_page', self.opt_remember_current_page.isChecked())
|
||||||
idx = self.hyphenate_default_lang.currentIndex()
|
idx = self.hyphenate_default_lang.currentIndex()
|
||||||
c.set('hyphenate_default_lang',
|
c.set('hyphenate_default_lang',
|
||||||
str(self.hyphenate_default_lang.itemData(idx).toString()))
|
str(self.hyphenate_default_lang.itemData(idx).toString()))
|
||||||
|
@ -328,6 +328,11 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
c = config().parse()
|
c = config().parse()
|
||||||
self.frame.setMaximumWidth(c.max_view_width)
|
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):
|
def print_book(self, preview):
|
||||||
Printing(self.iterator.spine, preview)
|
Printing(self.iterator.spine, preview)
|
||||||
|
|
||||||
@ -578,7 +583,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
current_page = None
|
current_page = None
|
||||||
self.existing_bookmarks = []
|
self.existing_bookmarks = []
|
||||||
for bm in 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
|
current_page = bm
|
||||||
else:
|
else:
|
||||||
self.existing_bookmarks.append(bm[0])
|
self.existing_bookmarks.append(bm[0])
|
||||||
@ -598,6 +604,8 @@ class EbookViewer(MainWindow, Ui_EbookViewer):
|
|||||||
self.set_bookmarks(bookmarks)
|
self.set_bookmarks(bookmarks)
|
||||||
|
|
||||||
def save_current_position(self):
|
def save_current_position(self):
|
||||||
|
if not self.get_remember_current_page_opt():
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
pos = self.view.bookmark()
|
pos = self.view.bookmark()
|
||||||
bookmark = '%d#%s'%(self.current_index, pos)
|
bookmark = '%d#%s'%(self.current_index, pos)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user