mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Use QInputMethodEvent to make charmap work with all widgets
This commit is contained in:
parent
ab7b6e1e99
commit
e0bf82e6e0
@ -15,7 +15,7 @@ from PyQt4.Qt import (
|
|||||||
QAbstractItemModel, QModelIndex, Qt, QVariant, pyqtSignal, QApplication,
|
QAbstractItemModel, QModelIndex, Qt, QVariant, pyqtSignal, QApplication,
|
||||||
QTreeView, QSize, QGridLayout, QAbstractListModel, QListView, QPen, QMenu,
|
QTreeView, QSize, QGridLayout, QAbstractListModel, QListView, QPen, QMenu,
|
||||||
QStyledItemDelegate, QSplitter, QLabel, QSizePolicy, QIcon, QMimeData,
|
QStyledItemDelegate, QSplitter, QLabel, QSizePolicy, QIcon, QMimeData,
|
||||||
QPushButton, QToolButton)
|
QPushButton, QToolButton, QInputMethodEvent)
|
||||||
|
|
||||||
from calibre.constants import ispy3, plugins, cache_dir
|
from calibre.constants import ispy3, plugins, cache_dir
|
||||||
from calibre.gui2 import NONE
|
from calibre.gui2 import NONE
|
||||||
@ -817,15 +817,12 @@ class CharSelect(Dialog):
|
|||||||
return
|
return
|
||||||
self.parent().activateWindow()
|
self.parent().activateWindow()
|
||||||
w = self.parent().focusWidget()
|
w = self.parent().focusWidget()
|
||||||
if hasattr(w, 'textCursor'):
|
e = QInputMethodEvent('', [])
|
||||||
cr = w.textCursor()
|
e.setCommitString(c)
|
||||||
cr.insertText(c)
|
|
||||||
w.setTextCursor(cr)
|
|
||||||
elif hasattr(w, 'insert'):
|
|
||||||
if hasattr(w, 'no_popup'):
|
if hasattr(w, 'no_popup'):
|
||||||
oval = w.no_popup
|
oval = w.no_popup
|
||||||
w.no_popup = True
|
w.no_popup = True
|
||||||
w.insert(c)
|
QApplication.sendEvent(w, e)
|
||||||
if hasattr(w, 'no_popup'):
|
if hasattr(w, 'no_popup'):
|
||||||
w.no_popup = oval
|
w.no_popup = oval
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user