Edit Book: Allow keyboard shortcuts to be assigned to the change case actions

This commit is contained in:
Kovid Goyal 2014-08-14 21:13:51 +05:30
parent c5b9cae0b7
commit 2f5b725806

View File

@ -86,6 +86,13 @@ def register_text_editor_actions(_reg, palette):
ac = reg(create_icon(name), text, ('rename_block_tag', name), 'rename-block-tag-' + name, 'Ctrl+%d' % (i + 1), desc, syntaxes=()) ac = reg(create_icon(name), text, ('rename_block_tag', name), 'rename-block-tag-' + name, 'Ctrl+%d' % (i + 1), desc, syntaxes=())
ac.setToolTip(desc) ac.setToolTip(desc)
for transform, text in [
('upper', _('&Upper case')), ('lower', _('&Lower case')), ('swap', _('&Swap case')),
('title', _('&Title case')), ('capitalize', _('&Capitalize'))]:
desc = _('Change the case of the selected text: %s') % text
ac = reg(None, text, ('change_case', transform), 'transform-case-' + transform, (), desc, syntaxes=())
ac.setToolTip(desc)
ac = reg('code', _('Insert &tag'), ('insert_tag',), 'insert-tag', ('Ctrl+<'), _('Insert tag'), syntaxes=('html', 'xml')) ac = reg('code', _('Insert &tag'), ('insert_tag',), 'insert-tag', ('Ctrl+<'), _('Insert tag'), syntaxes=('html', 'xml'))
ac.setToolTip(_('<h3>Insert tag</h3>Insert a tag, if some text is selected the tag will be inserted around the selected text')) ac.setToolTip(_('<h3>Insert tag</h3>Insert a tag, if some text is selected the tag will be inserted around the selected text'))
@ -499,11 +506,8 @@ class Editor(QMainWindow):
m.addAction(actions['mark-selected-text']) m.addAction(actions['mark-selected-text'])
if self.syntax != 'css' and actions['editor-cut'].isEnabled(): if self.syntax != 'css' and actions['editor-cut'].isEnabled():
cm = QMenu(_('Change &case'), m) cm = QMenu(_('Change &case'), m)
for ac, text in ( for ac in 'upper lower swap title capitalize'.split():
('upper', _('&Upper case')), ('lower', _('&Lower case')), ('swap', _('&Swap case')), cm.addAction(actions['transform-case-' + ac])
('title', _('&Title case')), ('capitalize', _('&Capitalize'))
):
cm.addAction(text, partial(self.editor.change_case, ac))
m.addMenu(cm) m.addMenu(cm)
if self.syntax == 'html': if self.syntax == 'html':
m.addAction(actions['multisplit']) m.addAction(actions['multisplit'])