mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Viewer: Allow customizing what actions appear on the toolbar (Preferences->Miscellaneous->Customize toolbar). Fixes #1852017 [Rearrange the optional toolbar icons](https://bugs.launchpad.net/calibre/+bug/1852017)
This commit is contained in:
parent
0f94cb092f
commit
f41348a5e1
@ -108,6 +108,7 @@ class ActionsToolBar(ToolBar):
|
|||||||
page = web_view.page()
|
page = web_view.page()
|
||||||
web_view.paged_mode_changed.connect(self.update_mode_action)
|
web_view.paged_mode_changed.connect(self.update_mode_action)
|
||||||
web_view.standalone_misc_settings_changed.connect(self.update_visibility)
|
web_view.standalone_misc_settings_changed.connect(self.update_visibility)
|
||||||
|
web_view.customize_toolbar.connect(self.customize, type=Qt.QueuedConnection)
|
||||||
|
|
||||||
self.back_action = page.action(QWebEnginePage.Back)
|
self.back_action = page.action(QWebEnginePage.Back)
|
||||||
self.back_action.setIcon(aa.back.icon)
|
self.back_action.setIcon(aa.back.icon)
|
||||||
@ -199,6 +200,11 @@ class ActionsToolBar(ToolBar):
|
|||||||
def update_visibility(self):
|
def update_visibility(self):
|
||||||
self.setVisible(bool(get_session_pref('show_actions_toolbar', default=False)))
|
self.setVisible(bool(get_session_pref('show_actions_toolbar', default=False)))
|
||||||
|
|
||||||
|
def customize(self):
|
||||||
|
d = ConfigureToolBar(parent=self.parent())
|
||||||
|
if d.exec_() == d.Accepted:
|
||||||
|
self.add_actions()
|
||||||
|
|
||||||
|
|
||||||
class ActionsList(QListWidget):
|
class ActionsList(QListWidget):
|
||||||
|
|
||||||
@ -323,6 +329,7 @@ class ConfigureToolBar(Dialog):
|
|||||||
vprefs.__delitem__('actions-toolbar-actions')
|
vprefs.__delitem__('actions-toolbar-actions')
|
||||||
else:
|
else:
|
||||||
vprefs.set('actions-toolbar-actions', ans)
|
vprefs.set('actions-toolbar-actions', ans)
|
||||||
|
return Dialog.accept(self)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -258,6 +258,7 @@ class ViewerBridge(Bridge):
|
|||||||
print_book = from_js()
|
print_book = from_js()
|
||||||
clear_history = from_js()
|
clear_history = from_js()
|
||||||
reset_interface = from_js()
|
reset_interface = from_js()
|
||||||
|
customize_toolbar = from_js()
|
||||||
|
|
||||||
create_view = to_js()
|
create_view = to_js()
|
||||||
start_book_load = to_js()
|
start_book_load = to_js()
|
||||||
@ -414,6 +415,7 @@ class WebView(RestartingWebEngineView):
|
|||||||
show_error = pyqtSignal(object, object, object)
|
show_error = pyqtSignal(object, object, object)
|
||||||
print_book = pyqtSignal()
|
print_book = pyqtSignal()
|
||||||
reset_interface = pyqtSignal()
|
reset_interface = pyqtSignal()
|
||||||
|
customize_toolbar = pyqtSignal()
|
||||||
shortcuts_changed = pyqtSignal(object)
|
shortcuts_changed = pyqtSignal(object)
|
||||||
paged_mode_changed = pyqtSignal()
|
paged_mode_changed = pyqtSignal()
|
||||||
standalone_misc_settings_changed = pyqtSignal(object)
|
standalone_misc_settings_changed = pyqtSignal(object)
|
||||||
@ -452,6 +454,7 @@ class WebView(RestartingWebEngineView):
|
|||||||
self.bridge.print_book.connect(self.print_book)
|
self.bridge.print_book.connect(self.print_book)
|
||||||
self.bridge.clear_history.connect(self.clear_history)
|
self.bridge.clear_history.connect(self.clear_history)
|
||||||
self.bridge.reset_interface.connect(self.reset_interface)
|
self.bridge.reset_interface.connect(self.reset_interface)
|
||||||
|
self.bridge.customize_toolbar.connect(self.customize_toolbar)
|
||||||
self.bridge.export_shortcut_map.connect(self.set_shortcut_map)
|
self.bridge.export_shortcut_map.connect(self.set_shortcut_map)
|
||||||
self.shortcut_map = {}
|
self.shortcut_map = {}
|
||||||
self.bridge.report_cfi.connect(self.call_callback)
|
self.bridge.report_cfi.connect(self.call_callback)
|
||||||
|
@ -7,9 +7,10 @@ from gettext import gettext as _
|
|||||||
|
|
||||||
from book_list.globals import get_session_data
|
from book_list.globals import get_session_data
|
||||||
from dom import unique_id
|
from dom import unique_id
|
||||||
from session import defaults
|
from read_book.globals import ui_operations
|
||||||
from read_book.prefs.utils import create_button_box
|
from read_book.prefs.utils import create_button_box
|
||||||
|
from session import defaults
|
||||||
|
from widgets import create_button
|
||||||
|
|
||||||
CONTAINER = unique_id('standalone-misc-settings')
|
CONTAINER = unique_id('standalone-misc-settings')
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
@ -46,6 +47,9 @@ def create_misc_panel(container, apply_func, cancel_func):
|
|||||||
|
|
||||||
container.append(cb('remember_window_geometry', _('Remember last used window size and position')))
|
container.append(cb('remember_window_geometry', _('Remember last used window size and position')))
|
||||||
container.append(cb('show_actions_toolbar', _('Show a toolbar with the most useful actions')))
|
container.append(cb('show_actions_toolbar', _('Show a toolbar with the most useful actions')))
|
||||||
|
container.lastChild.append(E.span('\xa0'))
|
||||||
|
container.lastChild.append(
|
||||||
|
create_button(_('Customize toolbar'), action=ui_operations.customize_toolbar))
|
||||||
container.append(cb('remember_last_read', _('Remember current page when quitting')))
|
container.append(cb('remember_last_read', _('Remember current page when quitting')))
|
||||||
container.append(cb('save_annotations_in_ebook', _('Keep a copy of annotations/bookmarks in the e-book file, for easy sharing')))
|
container.append(cb('save_annotations_in_ebook', _('Keep a copy of annotations/bookmarks in the e-book file, for easy sharing')))
|
||||||
container.append(cb('singleinstance', _('Allow only a single instance of the viewer (needs restart)')))
|
container.append(cb('singleinstance', _('Allow only a single instance of the viewer (needs restart)')))
|
||||||
|
@ -377,6 +377,8 @@ if window is window.top:
|
|||||||
to_python.print_book()
|
to_python.print_book()
|
||||||
ui_operations.clear_history = def():
|
ui_operations.clear_history = def():
|
||||||
to_python.clear_history()
|
to_python.clear_history()
|
||||||
|
ui_operations.customize_toolbar = def():
|
||||||
|
to_python.customize_toolbar()
|
||||||
|
|
||||||
document.body.appendChild(E.div(id='view'))
|
document.body.appendChild(E.div(id='view'))
|
||||||
window.onerror = onerror
|
window.onerror = onerror
|
||||||
|
Loading…
x
Reference in New Issue
Block a user