diff --git a/src/calibre/gui2/tweak_book/__init__.py b/src/calibre/gui2/tweak_book/__init__.py index 9c59abac68..dc2a7d2c81 100644 --- a/src/calibre/gui2/tweak_book/__init__.py +++ b/src/calibre/gui2/tweak_book/__init__.py @@ -53,6 +53,7 @@ d['global_book_toolbar'] = [ 'new-file', 'open-book', 'save-book', None, 'global-undo', 'global-redo', 'create-checkpoint', None, 'donate', 'user-manual'] d['global_tools_toolbar'] = ['check-book', 'spell-check-book', 'edit-toc', 'insert-character', 'manage-fonts', 'smarten-punctuation', 'remove-unused-css'] d['global_plugins_toolbar'] = [] +d['editor_common_toolbar'] = [('editor-' + x) if x else None for x in ('undo', 'redo', None, 'cut', 'copy', 'paste')] d['editor_css_toolbar'] = ['pretty-current', 'insert-image'] d['editor_xml_toolbar'] = ['pretty-current', 'insert-tag'] d['editor_html_toolbar'] = ['fix-html-current', 'pretty-current', 'insert-image', 'insert-hyperlink', 'insert-tag', 'change-paragraph'] diff --git a/src/calibre/gui2/tweak_book/editor/widget.py b/src/calibre/gui2/tweak_book/editor/widget.py index f93c912b3d..b8e7365997 100644 --- a/src/calibre/gui2/tweak_book/editor/widget.py +++ b/src/calibre/gui2/tweak_book/editor/widget.py @@ -255,13 +255,8 @@ class Editor(QMainWindow): return property(fget=fget, fset=fset) def create_toolbars(self): - self.action_bar = b = self.addToolBar(_('File actions tool bar')) + self.action_bar = b = self.addToolBar(_('Edit actions tool bar')) b.setObjectName('action_bar') # Needed for saveState - for x in ('undo', 'redo'): - b.addAction(actions['editor-%s' % x]) - self.edit_bar = b = self.addToolBar(_('Edit actions tool bar')) - for x in ('cut', 'copy', 'paste'): - b.addAction(actions['editor-%s' % x]) self.tools_bar = b = self.addToolBar(_('Editor tools')) b.setObjectName('tools_bar') if self.syntax == 'html': @@ -271,7 +266,7 @@ class Editor(QMainWindow): self.populate_toolbars() def populate_toolbars(self): - self.tools_bar.clear() + self.action_bar.clear(), self.tools_bar.clear() def add_action(name, bar): if name is None: bar.addSeparator() @@ -297,6 +292,9 @@ class Editor(QMainWindow): for name in tuple('h%d' % d for d in range(1, 7)) + ('p',): m.addAction(actions['rename-block-tag-%s' % name]) + for name in tprefs.get('editor_common_toolbar', ()): + add_action(name, self.action_bar) + for name in tprefs.get('editor_%s_toolbar' % self.syntax, ()): add_action(name, self.tools_bar) diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py index bd16429a0f..af3c5b25ed 100644 --- a/src/calibre/gui2/tweak_book/preferences.py +++ b/src/calibre/gui2/tweak_book/preferences.py @@ -21,7 +21,7 @@ from PyQt4.Qt import ( QToolButton, QVBoxLayout, QSpacerItem) from calibre.gui2.keyboard import ShortcutConfig -from calibre.gui2.tweak_book import tprefs, toolbar_actions, editor_toolbar_actions +from calibre.gui2.tweak_book import tprefs, toolbar_actions, editor_toolbar_actions, actions from calibre.gui2.tweak_book.editor.themes import default_theme, all_theme_names, ThemeEditor from calibre.gui2.tweak_book.spell import ManageDictionaries from calibre.gui2.font_family_chooser import FontFamilyChooser @@ -340,6 +340,7 @@ class ToolbarSettings(QWidget): ('global_book_toolbar', _('Book wide actions'),), ('global_tools_toolbar', _('Book wide tools'),), ('global_plugins_toolbar', _('Book wide tools from third party plugins'),), + ('editor_common_toolbar', ft % _('all')), ('editor_html_toolbar', ft % 'HTML',), ('editor_css_toolbar', ft % 'CSS',), ('editor_xml_toolbar', ft % 'XML',), @@ -405,7 +406,12 @@ class ToolbarSettings(QWidget): return items = self.current_settings[name] applied = set(items) - all_items = toolbar_actions if name.startswith('global_') else editor_toolbar_actions[name.split('_')[1]] + if name.startswith('global_'): + all_items = toolbar_actions + elif name == 'editor_common_toolbar': + all_items = {x:actions[x] for x in tprefs.defaults[name] if x} + else: + all_items = editor_toolbar_actions[name.split('_')[1]] blank = QIcon(I('blank.png')) def to_item(key, ac, parent):