diff --git a/imgsrc/auto-scroll.svg b/imgsrc/auto-scroll.svg new file mode 100644 index 0000000000..122f305418 --- /dev/null +++ b/imgsrc/auto-scroll.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/resources/images/auto-scroll.png b/resources/images/auto-scroll.png new file mode 100644 index 0000000000..11671ff158 Binary files /dev/null and b/resources/images/auto-scroll.png differ diff --git a/src/calibre/gui2/viewer/toolbars.py b/src/calibre/gui2/viewer/toolbars.py index af345ff2ac..aae4f10409 100644 --- a/src/calibre/gui2/viewer/toolbars.py +++ b/src/calibre/gui2/viewer/toolbars.py @@ -55,6 +55,7 @@ def all_actions(): 'bookmarks': Action('bookmarks.png', _('Bookmarks'), 'toggle_bookmarks'), 'inspector': Action('debug.png', _('Inspector'), 'toggle_inspector'), 'reference': Action('reference.png', _('Toggle Reference mode'), 'toggle_reference_mode'), + 'autoscroll': Action('auto-scroll.png', _('Toggle auto-scrolling'), 'toggle_autoscroll'), 'lookup': Action('generic-library.png', _('Lookup words'), 'toggle_lookup'), 'chrome': Action('tweaks.png', _('Show viewer controls'), 'show_chrome'), 'mode': Action('scroll.png', _('Toggle paged mode'), 'toggle_paged_mode'), @@ -128,6 +129,7 @@ class ActionsToolBar(ToolBar): web_view.paged_mode_changed.connect(self.update_mode_action) web_view.reference_mode_changed.connect(self.update_reference_mode_action) web_view.standalone_misc_settings_changed.connect(self.update_visibility) + web_view.autoscroll_state_changed.connect(self.update_autoscroll_action) web_view.customize_toolbar.connect(self.customize, type=Qt.QueuedConnection) self.back_action = page.action(QWebEnginePage.Back) @@ -163,6 +165,9 @@ class ActionsToolBar(ToolBar): a.setCheckable(True) self.inspector_action = a = shortcut_action('inspector') a.setCheckable(True) + self.autoscroll_action = a = shortcut_action('autoscroll') + a.setCheckable(True) + self.update_autoscroll_action(False) self.chrome_action = shortcut_action('chrome') self.mode_action = a = shortcut_action('mode') @@ -195,6 +200,11 @@ class ActionsToolBar(ToolBar): a.setChecked(True) a.setToolTip(_('Switch to paged mode -- where the text is broken into pages')) + def update_autoscroll_action(self, active): + self.autoscroll_action.setChecked(active) + self.autoscroll_action.setToolTip( + _('Turn off auto-scrolling') if active else _('Turn on auto-scrolling')) + def update_reference_mode_action(self, enabled): self.reference_action.setChecked(enabled) diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py index acf0a137c8..1d351ef6ec 100644 --- a/src/calibre/gui2/viewer/web_view.py +++ b/src/calibre/gui2/viewer/web_view.py @@ -247,6 +247,7 @@ class ViewerBridge(Bridge): report_cfi = from_js(object, object) ask_for_open = from_js(object) selection_changed = from_js(object) + autoscroll_state_changed = from_js(object) copy_selection = from_js(object) view_image = from_js(object) copy_image = from_js(object) @@ -416,6 +417,7 @@ class WebView(RestartingWebEngineView): toggle_full_screen = pyqtSignal() ask_for_open = pyqtSignal(object) selection_changed = pyqtSignal(object) + autoscroll_state_changed = pyqtSignal(object) view_image = pyqtSignal(object) copy_image = pyqtSignal(object) overlay_visibility_changed = pyqtSignal(object) @@ -455,6 +457,7 @@ class WebView(RestartingWebEngineView): self.bridge.toggle_full_screen.connect(self.toggle_full_screen) self.bridge.ask_for_open.connect(self.ask_for_open) self.bridge.selection_changed.connect(self.selection_changed) + self.bridge.autoscroll_state_changed.connect(self.autoscroll_state_changed) self.bridge.view_image.connect(self.view_image) self.bridge.copy_image.connect(self.copy_image) self.bridge.overlay_visibility_changed.connect(self.overlay_visibility_changed) diff --git a/src/pyj/read_book/view.pyj b/src/pyj/read_book/view.pyj index e976d58667..dc05a9b350 100644 --- a/src/pyj/read_book/view.pyj +++ b/src/pyj/read_book/view.pyj @@ -203,6 +203,8 @@ class View: handlers = { 'autoscroll_state_changed': def(data): self.autoscroll_active = v'!!data.running' + if ui_operations.autoscroll_state_changed: + ui_operations.autoscroll_state_changed(self.autoscroll_active) , 'bump_font_size': self.bump_font_size, 'content_loaded': self.on_content_loaded, @@ -417,6 +419,8 @@ class View: self.update_scroll_speed(SCROLL_SPEED_STEP) elif data.name is 'scrollspeed_decrease': self.update_scroll_speed(-SCROLL_SPEED_STEP) + elif data.name is 'toggle_autoscroll': + self.toggle_autoscroll() def on_selection_change(self, data): self.currently_showing.selected_text = data.text diff --git a/src/pyj/viewer-main.pyj b/src/pyj/viewer-main.pyj index 26d9167a35..fb87a39bf9 100644 --- a/src/pyj/viewer-main.pyj +++ b/src/pyj/viewer-main.pyj @@ -384,6 +384,8 @@ if window is window.top: to_python.clear_history() ui_operations.customize_toolbar = def(): to_python.customize_toolbar() + ui_operations.autoscroll_state_changed = def(active): + to_python.autoscroll_state_changed(active) document.body.appendChild(E.div(id='view')) window.onerror = onerror