mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02:00
Metadata edit dialog: Fix keyboard shortcuts for bold/italic/underline not workining when more than one comments editor widget is present on a single tab. Fixes #1905479 [Edit Metadata: Non-default layout and custom longtext column breaks formatting shortcuts](https://bugs.launchpad.net/calibre/+bug/1905479)
This commit is contained in:
parent
56e0fc69fb
commit
635337068e
1 changed files with 15 additions and 9 deletions
|
|
@ -255,12 +255,6 @@ def __init__(self, parent=None):
|
|||
self._parent = weakref.ref(parent)
|
||||
self.comments_pat = re.compile(r'<!--.*?-->', re.DOTALL)
|
||||
|
||||
extra_shortcuts = {
|
||||
'bold': 'Bold',
|
||||
'italic': 'Italic',
|
||||
'underline': 'Underline',
|
||||
}
|
||||
|
||||
for rec in (
|
||||
('bold', 'format-text-bold', _('Bold'), True),
|
||||
('italic', 'format-text-italic', _('Italic'), True),
|
||||
|
|
@ -298,9 +292,6 @@ def __init__(self, parent=None):
|
|||
if checkable:
|
||||
ac.setCheckable(checkable)
|
||||
setattr(self, 'action_'+name, ac)
|
||||
ss = extra_shortcuts.get(name)
|
||||
if ss is not None:
|
||||
ac.setShortcut(QKeySequence(getattr(QKeySequence, ss)))
|
||||
ac.triggered.connect(getattr(self, 'do_' + name))
|
||||
|
||||
self.action_block_style = QAction(QIcon(I('format-text-heading.png')),
|
||||
|
|
@ -341,6 +332,21 @@ def __init__(self, parent=None):
|
|||
self.textChanged.connect(self.data_changed)
|
||||
self.update_cursor_position_actions()
|
||||
|
||||
def keyPressEvent(self, ev):
|
||||
if ev.matches(QKeySequence.Bold):
|
||||
ev.accept()
|
||||
self.action_bold.toggle(), self.action_bold.trigger()
|
||||
return
|
||||
if ev.matches(QKeySequence.Italic):
|
||||
ev.accept()
|
||||
self.action_italic.toggle(), self.action_italic.trigger()
|
||||
return
|
||||
if ev.matches(QKeySequence.Underline):
|
||||
ev.accept()
|
||||
self.action_underline.toggle(), self.action_underline.trigger()
|
||||
return
|
||||
return QTextEdit.keyPressEvent(self, ev)
|
||||
|
||||
def update_clipboard_actions(self, copy_available):
|
||||
self.action_copy.setEnabled(copy_available)
|
||||
self.action_cut.setEnabled(copy_available)
|
||||
|
|
|
|||
Loading…
Reference in a new issue