mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit Book: Make the undo/redo/cut/copy/paste buttons on the editor toolbar also configurable, so they can be removed via Preferences->Toolbars, if needed.
See #1346913 (Edit Books - Toolbars)
This commit is contained in:
parent
fa47a695ea
commit
d05e88293f
@ -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']
|
'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_tools_toolbar'] = ['check-book', 'spell-check-book', 'edit-toc', 'insert-character', 'manage-fonts', 'smarten-punctuation', 'remove-unused-css']
|
||||||
d['global_plugins_toolbar'] = []
|
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_css_toolbar'] = ['pretty-current', 'insert-image']
|
||||||
d['editor_xml_toolbar'] = ['pretty-current', 'insert-tag']
|
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']
|
d['editor_html_toolbar'] = ['fix-html-current', 'pretty-current', 'insert-image', 'insert-hyperlink', 'insert-tag', 'change-paragraph']
|
||||||
|
@ -255,13 +255,8 @@ class Editor(QMainWindow):
|
|||||||
return property(fget=fget, fset=fset)
|
return property(fget=fget, fset=fset)
|
||||||
|
|
||||||
def create_toolbars(self):
|
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
|
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'))
|
self.tools_bar = b = self.addToolBar(_('Editor tools'))
|
||||||
b.setObjectName('tools_bar')
|
b.setObjectName('tools_bar')
|
||||||
if self.syntax == 'html':
|
if self.syntax == 'html':
|
||||||
@ -271,7 +266,7 @@ class Editor(QMainWindow):
|
|||||||
self.populate_toolbars()
|
self.populate_toolbars()
|
||||||
|
|
||||||
def populate_toolbars(self):
|
def populate_toolbars(self):
|
||||||
self.tools_bar.clear()
|
self.action_bar.clear(), self.tools_bar.clear()
|
||||||
def add_action(name, bar):
|
def add_action(name, bar):
|
||||||
if name is None:
|
if name is None:
|
||||||
bar.addSeparator()
|
bar.addSeparator()
|
||||||
@ -297,6 +292,9 @@ class Editor(QMainWindow):
|
|||||||
for name in tuple('h%d' % d for d in range(1, 7)) + ('p',):
|
for name in tuple('h%d' % d for d in range(1, 7)) + ('p',):
|
||||||
m.addAction(actions['rename-block-tag-%s' % name])
|
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, ()):
|
for name in tprefs.get('editor_%s_toolbar' % self.syntax, ()):
|
||||||
add_action(name, self.tools_bar)
|
add_action(name, self.tools_bar)
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from PyQt4.Qt import (
|
|||||||
QToolButton, QVBoxLayout, QSpacerItem)
|
QToolButton, QVBoxLayout, QSpacerItem)
|
||||||
|
|
||||||
from calibre.gui2.keyboard import ShortcutConfig
|
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.editor.themes import default_theme, all_theme_names, ThemeEditor
|
||||||
from calibre.gui2.tweak_book.spell import ManageDictionaries
|
from calibre.gui2.tweak_book.spell import ManageDictionaries
|
||||||
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
from calibre.gui2.font_family_chooser import FontFamilyChooser
|
||||||
@ -340,6 +340,7 @@ class ToolbarSettings(QWidget):
|
|||||||
('global_book_toolbar', _('Book wide actions'),),
|
('global_book_toolbar', _('Book wide actions'),),
|
||||||
('global_tools_toolbar', _('Book wide tools'),),
|
('global_tools_toolbar', _('Book wide tools'),),
|
||||||
('global_plugins_toolbar', _('Book wide tools from third party plugins'),),
|
('global_plugins_toolbar', _('Book wide tools from third party plugins'),),
|
||||||
|
('editor_common_toolbar', ft % _('all')),
|
||||||
('editor_html_toolbar', ft % 'HTML',),
|
('editor_html_toolbar', ft % 'HTML',),
|
||||||
('editor_css_toolbar', ft % 'CSS',),
|
('editor_css_toolbar', ft % 'CSS',),
|
||||||
('editor_xml_toolbar', ft % 'XML',),
|
('editor_xml_toolbar', ft % 'XML',),
|
||||||
@ -405,7 +406,12 @@ class ToolbarSettings(QWidget):
|
|||||||
return
|
return
|
||||||
items = self.current_settings[name]
|
items = self.current_settings[name]
|
||||||
applied = set(items)
|
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'))
|
blank = QIcon(I('blank.png'))
|
||||||
|
|
||||||
def to_item(key, ac, parent):
|
def to_item(key, ac, parent):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user