From 081836db66c4f33107086b9fb0911536b4e0a2ca Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 18 Jan 2014 11:15:17 +0530 Subject: [PATCH] Add in a default implementation of the event() override --- src/calibre/gui2/tweak_book/editor/text.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/tweak_book/editor/text.py b/src/calibre/gui2/tweak_book/editor/text.py index 6b34e82e52..a916fe68fc 100644 --- a/src/calibre/gui2/tweak_book/editor/text.py +++ b/src/calibre/gui2/tweak_book/editor/text.py @@ -55,9 +55,7 @@ class LineNumbers(QWidget): # {{{ class PlainTextEdit(QPlainTextEdit): ''' A class that overrides some methods from QPlainTextEdit to fix handling - of the nbsp unicode character. In addition to this you also have to - override the default copy/cut actions triggered by the keyboard shortcuts. - See the event() method of the TextEdit class for example. ''' + of the nbsp unicode character. ''' def __init__(self, parent=None): QPlainTextEdit.__init__(self, parent) @@ -97,6 +95,13 @@ class PlainTextEdit(QPlainTextEdit): md.setText(self.selected_text) clipboard.setMimeData(md, clipboard.Selection) + def event(self, ev): + if ev.type() == ev.ShortcutOverride and ev in (QKeySequence.Copy, QKeySequence.Cut): + ev.accept() + (self.copy if ev == QKeySequence.Copy else self.cut)() + return True + return QPlainTextEdit.event(self, ev) + class TextEdit(PlainTextEdit): def __init__(self, parent=None):