mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A toolbar button for auto-scrolling
This commit is contained in:
parent
38736d9412
commit
4c1032ba5c
58
imgsrc/auto-scroll.svg
Normal file
58
imgsrc/auto-scroll.svg
Normal file
@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="1792"
|
||||
height="1792"
|
||||
viewBox="0 0 1792 1792"
|
||||
version="1.1"
|
||||
id="svg4"
|
||||
sodipodi:docname="auto-scroll.svg"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14">
|
||||
<metadata
|
||||
id="metadata10">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs8" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="2560"
|
||||
inkscape:window-height="1400"
|
||||
id="namedview6"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.13169643"
|
||||
inkscape:cx="-1025.0847"
|
||||
inkscape:cy="896"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="40"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg4" />
|
||||
<path
|
||||
d="m 1395,864 q 0,13 -10,23 l -466,466 q -10,10 -23,10 -13,0 -23,-10 L 407,887 q -10,-10 -10,-23 0,-13 10,-23 l 50,-50 q 10,-10 23,-10 13,0 23,10 l 393,393 393,-393 q 10,-10 23,-10 13,0 23,10 l 50,50 q 10,10 10,23 z"
|
||||
id="path823"
|
||||
style="fill:#2caf45;fill-opacity:1" />
|
||||
<path
|
||||
d="m 1395,480 q 0,13 -10,23 L 919,969 q -10,10 -23,10 -13,0 -23,-10 L 407,503 q -10,-10 -10,-23 0,-13 10,-23 l 50,-50 q 10,-10 23,-10 13,0 23,10 l 393,393 393,-393 q 10,-10 23,-10 13,0 23,10 l 50,50 q 10,10 10,23 z"
|
||||
id="path2"
|
||||
style="fill:#2271d5;fill-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 2.0 KiB |
BIN
resources/images/auto-scroll.png
Normal file
BIN
resources/images/auto-scroll.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 822 B |
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user