diff --git a/src/calibre/gui2/viewer/config.py b/src/calibre/gui2/viewer/config.py index 44446a878c..7a7ace4a60 100644 --- a/src/calibre/gui2/viewer/config.py +++ b/src/calibre/gui2/viewer/config.py @@ -55,6 +55,10 @@ def config(defaults=None): help=_('Copy bookmarks to the ebook file for easy sharing, if possible')) c.add_opt('wheel_flips_pages', default=False, help=_('Have the mouse wheel turn pages')) + c.add_opt('wheel_scroll_fraction', default=100, + help=_('Control how much the mouse wheel scrolls by in flow mode')) + c.add_opt('line_scroll_fraction', default=100, + help=_('Control how much the arrow keys scroll by in flow mode')) c.add_opt('tap_flips_pages', default=True, help=_('Tapping on the screen turns pages')) c.add_opt('line_scrolling_stops_on_pagebreaks', default=False, @@ -300,6 +304,8 @@ class ConfigDialog(QDialog, Ui_Dialog): self.opt_remember_current_page.setChecked(opts.remember_current_page) self.opt_copy_bookmarks_to_file.setChecked(opts.copy_bookmarks_to_file) self.opt_wheel_flips_pages.setChecked(opts.wheel_flips_pages) + self.opt_wheel_scroll_fraction.setValue(opts.wheel_scroll_fraction) + self.opt_line_scroll_fraction.setValue(opts.line_scroll_fraction) self.opt_tap_flips_pages.setChecked(opts.tap_flips_pages) self.opt_page_flip_duration.setValue(opts.page_flip_duration) fms = opts.font_magnification_step @@ -407,6 +413,8 @@ class ConfigDialog(QDialog, Ui_Dialog): c.set('remember_current_page', self.opt_remember_current_page.isChecked()) c.set('copy_bookmarks_to_file', self.opt_copy_bookmarks_to_file.isChecked()) c.set('wheel_flips_pages', self.opt_wheel_flips_pages.isChecked()) + c.set('wheel_scroll_fraction', self.opt_wheel_scroll_fraction.value()) + c.set('line_scroll_fraction', self.opt_line_scroll_fraction.value()) c.set('tap_flips_pages', self.opt_tap_flips_pages.isChecked()) c.set('page_flip_duration', self.opt_page_flip_duration.value()) c.set('font_magnification_step', diff --git a/src/calibre/gui2/viewer/config.ui b/src/calibre/gui2/viewer/config.ui index 8973643be4..b01a48b1e9 100644 --- a/src/calibre/gui2/viewer/config.ui +++ b/src/calibre/gui2/viewer/config.ui @@ -600,73 +600,167 @@ QToolBox::tab:hover { - Page Fl&ip options + Page Fl&ip/Scrolling options - - - - - Page flip &duration: - - - opt_page_flip_duration - - - - - - - disabled - - - secs - - - 1 - - - 0.100000000000000 - - - 3.000000000000000 - - - 0.100000000000000 - - - 0.500000000000000 - - - - - - - Mouse &wheel flips pages - - - - - - - Line &scrolling stops at page breaks - - - - - - - &Resize images larger than the viewer window (needs restart) - - - - - - - &Tapping on the page flips pages - - - - + + + + 9 + 9 + 111 + 16 + + + + Page flip &duration: + + + opt_page_flip_duration + + + + + + 251 + 9 + 76 + 22 + + + + disabled + + + secs + + + 1 + + + 0.100000000000000 + + + 3.000000000000000 + + + 0.100000000000000 + + + 0.500000000000000 + + + + + + 9 + 115 + 374 + 91 + + + + Scrolling in flow mode + + + + + + Control the amount the mouse &wheel scrolls: + + + opt_wheel_scroll_fraction + + + + + + + This is a percentage, by making itless than 100 you can decrease the amount the wheel scrolls by, by making it more than 100 you can increase the scroll amount. + + + % + + + 1 + + + 2000 + + + 5 + + + + + + + Control the amount the arrow &keys scroll: + + + opt_line_scroll_fraction + + + + + + + This is a percentage, by making itless than 100 you can decrease the amount thearrow keys scroll by, by making it more than 100 you can increase the scroll amount. + + + % + + + 1 + + + 2000 + + + 5 + + + + + + + + + 9 + 37 + 219 + 20 + + + + &Tapping on the page flips pages + + + + + + 9 + 63 + 174 + 20 + + + + Mouse &wheel flips pages + + + + + + 9 + 89 + 236 + 20 + + + + Line &scrolling stops at page breaks + + @@ -681,53 +775,6 @@ QToolBox::tab:hover { &Miscellaneous options - - - - Remember last used &window size and layout - - - - - - - Keep a copy of all bookmarks/current page information inside the ebook file, so that you can share them by simply sending the ebook file itself. Currently only works with ebooks in the EPUB format. - - - Keep a copy of &bookmarks/current page inside the ebook file, for easy sharing - - - - - - - Change the search engine used to perform online searches for selected text. -You must enter the search URL for the search engine, with the placeholder -{text}, which will be replaced by the selected text. - - - - - - - The default language to use for hyphenation rules. If the book does not specify a language, this will be used. - - - - - - - Remember the &current page when quitting - - - - - - - Show &controls in the viewer window - - - @@ -735,13 +782,6 @@ You must enter the search URL for the search engine, with the placeholder - - - - Clear search history - - - @@ -752,6 +792,20 @@ You must enter the search URL for the search engine, with the placeholder + + + + The default language to use for hyphenation rules. If the book does not specify a language, this will be used. + + + + + + + Show &controls in the viewer window + + + @@ -762,7 +816,64 @@ You must enter the search URL for the search engine, with the placeholder + + + + Change the search engine used to perform online searches for selected text. +You must enter the search URL for the search engine, with the placeholder +{text}, which will be replaced by the selected text. + + + + + + + Remember last used &window size and layout + + + + + + + Remember the &current page when quitting + + + + + + + Keep a copy of all bookmarks/current page information inside the ebook file, so that you can share them by simply sending the ebook file itself. Currently only works with ebooks in the EPUB format. + + + Keep a copy of &bookmarks/current page inside the ebook file, for easy sharing + + + + + + + Normally, you can view multiple books in calibre, each in its own viewer window. With this option, if you attempt to view a second book, it will replace the previously opened book instead of using a new window. + + + Allow only a &single book to be viewed at a time (needs restart) + + + + + + + &Resize images larger than the viewer window (needs restart) + + + + + + Clear search history + + + + Qt::Vertical @@ -775,16 +886,6 @@ You must enter the search URL for the search engine, with the placeholder - - - - Normally, you can view multiple books in calibre, each in its own viewer window. With this option, if you attempt to view a second book, it will replace the previously opened book instead of using a new window. - - - Allow only a &single book to be viewed at a time (needs restart) - - - diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 4bc7c66fad..0b587eeb18 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -172,6 +172,8 @@ class Document(QWebPage): # {{{ self.enable_page_flip = self.page_flip_duration > 0.1 self.font_magnification_step = opts.font_magnification_step self.wheel_flips_pages = opts.wheel_flips_pages + self.wheel_scroll_fraction = opts.wheel_scroll_fraction + self.line_scroll_fraction = opts.line_scroll_fraction self.tap_flips_pages = opts.tap_flips_pages self.line_scrolling_stops_on_pagebreaks = opts.line_scrolling_stops_on_pagebreaks screen_width = QApplication.desktop().screenGeometry().width() @@ -1298,10 +1300,12 @@ class DocumentView(QWebView): # {{{ num_degrees_h = event.angleDelta().x() // 8 vertical = abs(num_degrees) > abs(num_degrees_h) scroll_amount = ((num_degrees if vertical else num_degrees_h)/ 120.0) * .2 * -1 * 8 - if vertical: - self.scroll_by(0, self.document.viewportSize().height() * scroll_amount) - else: - self.scroll_by(self.document.viewportSize().width() * scroll_amount, 0) + dim = self.document.viewportSize().height() if vertical else self.document.viewportSize().width() + amt = dim * scroll_amount + mult = -1 if amt < 0 else 1 + if self.document.wheel_scroll_fraction != 100: + amt = mult * max(1, abs(int(amt * self.document.wheel_scroll_fraction / 100.))) + self.scroll_by(0, amt) if vertical else self.scroll_by(amt, 0) if self.manager is not None: self.manager.scrolled(self.scroll_fraction) @@ -1341,7 +1345,8 @@ class DocumentView(QWebView): # {{{ self.document.at_bottom): self.manager.next_document() else: - self.scroll_by(y=15) + amt = int((self.document.line_scroll_fraction / 100.) * 15) + self.scroll_by(y=amt) elif key == 'Up': if self.document.in_paged_mode: self.paged_col_scroll(forward=False, scroll_past_end=not @@ -1351,17 +1356,20 @@ class DocumentView(QWebView): # {{{ self.document.at_top): self.manager.previous_document() else: - self.scroll_by(y=-15) + amt = int((self.document.line_scroll_fraction / 100.) * 15) + self.scroll_by(y=-amt) elif key == 'Left': if self.document.in_paged_mode: self.paged_col_scroll(forward=False) else: - self.scroll_by(x=-15) + amt = int((self.document.line_scroll_fraction / 100.) * 15) + self.scroll_by(x=-amt) elif key == 'Right': if self.document.in_paged_mode: self.paged_col_scroll() else: - self.scroll_by(x=15) + amt = int((self.document.line_scroll_fraction / 100.) * 15) + self.scroll_by(x=amt) elif key == 'Back': if self.manager is not None: self.manager.back(None)