mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
E-book viewer: Add options to control the amount the mouse wheel and arrow keys scroll by in flow mode
This commit is contained in:
parent
a4c2a4b2f4
commit
98eacb55cf
@ -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',
|
||||
|
@ -600,73 +600,167 @@ QToolBox::tab:hover {
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
<string>Page Fl&ip options</string>
|
||||
<string>Page Fl&ip/Scrolling options</string>
|
||||
</attribute>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="text">
|
||||
<string>Page flip &duration:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_page_flip_duration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QDoubleSpinBox" name="opt_page_flip_duration">
|
||||
<property name="specialValueText">
|
||||
<string>disabled</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> secs</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_wheel_flips_pages">
|
||||
<property name="text">
|
||||
<string>Mouse &wheel flips pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" 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>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_fit_images">
|
||||
<property name="text">
|
||||
<string>&Resize images larger than the viewer window (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="opt_tap_flips_pages">
|
||||
<property name="text">
|
||||
<string>&Tapping on the page flips pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="label_11">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Page flip &duration:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_page_flip_duration</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="opt_page_flip_duration">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>251</x>
|
||||
<y>9</y>
|
||||
<width>76</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="specialValueText">
|
||||
<string>disabled</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> secs</string>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>3.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.100000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.500000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>115</y>
|
||||
<width>374</width>
|
||||
<height>91</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Scrolling in flow mode</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_29">
|
||||
<property name="text">
|
||||
<string>Control the amount the mouse &wheel scrolls:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_wheel_scroll_fraction</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="opt_wheel_scroll_fraction">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_30">
|
||||
<property name="text">
|
||||
<string>Control the amount the arrow &keys scroll:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>opt_line_scroll_fraction</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="opt_line_scroll_fraction">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> %</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="opt_tap_flips_pages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>37</y>
|
||||
<width>219</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Tapping on the page flips pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="opt_wheel_flips_pages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>63</y>
|
||||
<width>174</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mouse &wheel flips pages</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="opt_line_scrolling_stops_on_pagebreaks">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>89</y>
|
||||
<width>236</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Line &scrolling stops at page breaks</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4">
|
||||
<property name="geometry">
|
||||
@ -681,53 +775,6 @@ QToolBox::tab:hover {
|
||||
<string>&Miscellaneous options</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_remember_window_size">
|
||||
<property name="text">
|
||||
<string>Remember last used &window size and layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_copy_bookmarks_to_file">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keep a copy of &bookmarks/current page inside the ebook file, for easy sharing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="search_online_url">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="hyphenate_default_lang">
|
||||
<property name="toolTip">
|
||||
<string>The default language to use for hyphenation rules. If the book does not specify a language, this will be used.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" 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="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_show_controls">
|
||||
<property name="text">
|
||||
<string>Show &controls in the viewer window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="hyphenate">
|
||||
<property name="text">
|
||||
@ -735,13 +782,6 @@ You must enter the search URL for the search engine, with the placeholder
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<widget class="QPushButton" name="clear_search_history_button">
|
||||
<property name="text">
|
||||
<string>Clear search history</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="hyphenate_label">
|
||||
<property name="text">
|
||||
@ -752,6 +792,20 @@ You must enter the search URL for the search engine, with the placeholder
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="hyphenate_default_lang">
|
||||
<property name="toolTip">
|
||||
<string>The default language to use for hyphenation rules. If the book does not specify a language, this will be used.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_show_controls">
|
||||
<property name="text">
|
||||
<string>Show &controls in the viewer window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_26">
|
||||
<property name="text">
|
||||
@ -762,7 +816,64 @@ You must enter the search URL for the search engine, with the placeholder
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="search_online_url">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_remember_window_size">
|
||||
<property name="text">
|
||||
<string>Remember last used &window size and layout</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" 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="6" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_copy_bookmarks_to_file">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Keep a copy of &bookmarks/current page inside the ebook file, for easy sharing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_singleinstance">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow only a &single book to be viewed at a time (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_fit_images">
|
||||
<property name="text">
|
||||
<string>&Resize images larger than the viewer window (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QPushButton" name="clear_search_history_button">
|
||||
<property name="text">
|
||||
<string>Clear search history</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -775,16 +886,6 @@ You must enter the search URL for the search engine, with the placeholder
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="opt_singleinstance">
|
||||
<property name="toolTip">
|
||||
<string>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.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Allow only a &single book to be viewed at a time (needs restart)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user