mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add in a default implementation of the event() override
This commit is contained in:
parent
84ae3b8595
commit
081836db66
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user