Viewer: Add a keyboard shortcut (Ctrl+w) to toggle the scrollbar. Fixes #1864356 [[Enhancement] Hide scrollbar by right clicking on it](https://bugs.launchpad.net/calibre/+bug/1864356)

This commit is contained in:
Kovid Goyal 2020-02-23 19:38:16 +05:30
parent d6184e16a1
commit a9c8b0c807
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 19 additions and 0 deletions

View File

@ -210,6 +210,8 @@ class EbookViewer(MainWindow):
m.addSeparator() m.addSeparator()
a(_('Start of current file'), 'start_of_file') a(_('Start of current file'), 'start_of_file')
a(_('End of current file'), 'end_of_file') a(_('End of current file'), 'end_of_file')
m.addSeparator()
a(_('Hide this scrollbar'), 'toggle_scrollbar')
q = m.exec_(QCursor.pos()) q = m.exec_(QCursor.pos())
if not q: if not q:

View File

@ -228,6 +228,12 @@ def shortcuts_definition():
_('Toggle between Paged mode and Flow mode for text layout') _('Toggle between Paged mode and Flow mode for text layout')
), ),
'toggle_scrollbar': desc(
'Ctrl+w',
'ui',
_('Toggle the scrollbar')
),
'toggle_reference_mode': desc( 'toggle_reference_mode': desc(
'Ctrl+x', 'Ctrl+x',
'ui', 'ui',

View File

@ -269,6 +269,15 @@ class View:
def reference_mode_overlay(self): def reference_mode_overlay(self):
return document.getElementById('reference-mode-overlay') return document.getElementById('reference-mode-overlay')
def set_scrollbar_visibility(self, visible):
sd = get_session_data()
sd.set('book_scrollbar', bool(visible))
self.book_scrollbar.apply_visibility()
def toggle_scrollbar(self):
sd = get_session_data()
self.set_scrollbar_visibility(not sd.get('book_scrollbar'))
def on_lookup_word(self, data): def on_lookup_word(self, data):
if runtime.is_standalone_viewer: if runtime.is_standalone_viewer:
ui_operations.selection_changed(data.word) ui_operations.selection_changed(data.word)
@ -388,6 +397,8 @@ class View:
self.toggle_paged_mode() self.toggle_paged_mode()
elif data.name is 'toggle_toolbar': elif data.name is 'toggle_toolbar':
self.toggle_toolbar() self.toggle_toolbar()
elif data.name is 'toggle_scrollbar':
self.toggle_scrollbar()
elif data.name is 'quit': elif data.name is 'quit':
ui_operations.quit() ui_operations.quit()
elif data.name is 'start_search': elif data.name is 'start_search':