mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Add an option to prevent the up and down arrow keys from scrolling past page breaks
This commit is contained in:
parent
cf446a724f
commit
5abc74f570
@ -301,6 +301,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="11" column="0" colspan="2">
|
||||||
|
<widget class="QCheckBox" name="opt_line_scrolling_stops_on_pagebreaks">
|
||||||
|
<property name="text">
|
||||||
|
<string>Line &scrolling stops at page breaks</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -60,6 +60,9 @@ def config(defaults=None):
|
|||||||
help=_('Save the current position in the document, when quitting'))
|
help=_('Save the current position in the document, when quitting'))
|
||||||
c.add_opt('wheel_flips_pages', default=False,
|
c.add_opt('wheel_flips_pages', default=False,
|
||||||
help=_('Have the mouse wheel turn pages'))
|
help=_('Have the mouse wheel turn pages'))
|
||||||
|
c.add_opt('line_scrolling_stops_on_pagebreaks', default=False,
|
||||||
|
help=_('Prevent the up and down arrow keys from scrolling past '
|
||||||
|
'page breaks'))
|
||||||
c.add_opt('page_flip_duration', default=0.5,
|
c.add_opt('page_flip_duration', default=0.5,
|
||||||
help=_('The time, in seconds, for the page flip animation. Default'
|
help=_('The time, in seconds, for the page flip animation. Default'
|
||||||
' is half a second.'))
|
' is half a second.'))
|
||||||
@ -96,6 +99,8 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
if fms < 0.01 or fms > 1:
|
if fms < 0.01 or fms > 1:
|
||||||
fms = 0.2
|
fms = 0.2
|
||||||
self.opt_font_mag_step.setValue(int(fms*100))
|
self.opt_font_mag_step.setValue(int(fms*100))
|
||||||
|
self.opt_line_scrolling_stops_on_pagebreaks.setChecked(
|
||||||
|
opts.line_scrolling_stops_on_pagebreaks)
|
||||||
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))
|
||||||
@ -157,6 +162,8 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
|||||||
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()))
|
||||||
|
c.set('line_scrolling_stops_on_pagebreaks',
|
||||||
|
self.opt_line_scrolling_stops_on_pagebreaks.isChecked())
|
||||||
return QDialog.accept(self, *args)
|
return QDialog.accept(self, *args)
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
@ -242,6 +249,7 @@ class Document(QWebPage): # {{{
|
|||||||
self.enable_page_flip = self.page_flip_duration > 0.1
|
self.enable_page_flip = self.page_flip_duration > 0.1
|
||||||
self.font_magnification_step = opts.font_magnification_step
|
self.font_magnification_step = opts.font_magnification_step
|
||||||
self.wheel_flips_pages = opts.wheel_flips_pages
|
self.wheel_flips_pages = opts.wheel_flips_pages
|
||||||
|
self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks
|
||||||
screen_width = QApplication.desktop().screenGeometry().width()
|
screen_width = QApplication.desktop().screenGeometry().width()
|
||||||
# Leave some space for the scrollbar and some border
|
# Leave some space for the scrollbar and some border
|
||||||
self.max_fs_width = min(opts.max_fs_width, screen_width-50)
|
self.max_fs_width = min(opts.max_fs_width, screen_width-50)
|
||||||
@ -955,12 +963,16 @@ class DocumentView(QWebView): # {{{
|
|||||||
finally:
|
finally:
|
||||||
self.is_auto_repeat_event = False
|
self.is_auto_repeat_event = False
|
||||||
elif key == 'Down':
|
elif key == 'Down':
|
||||||
if self.document.at_bottom:
|
if (not self.document.line_scrolling_stops_on_pagebreaks and
|
||||||
|
self.document.at_bottom):
|
||||||
self.manager.next_document()
|
self.manager.next_document()
|
||||||
|
else:
|
||||||
self.scroll_by(y=15)
|
self.scroll_by(y=15)
|
||||||
elif key == 'Up':
|
elif key == 'Up':
|
||||||
if self.document.at_top:
|
if (not self.document.line_scrolling_stops_on_pagebreaks and
|
||||||
|
self.document.at_top):
|
||||||
self.manager.previous_document()
|
self.manager.previous_document()
|
||||||
|
else:
|
||||||
self.scroll_by(y=-15)
|
self.scroll_by(y=-15)
|
||||||
elif key == 'Left':
|
elif key == 'Left':
|
||||||
self.scroll_by(x=-15)
|
self.scroll_by(x=-15)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user