|
39 | 39 | from enum import Enum, IntFlag |
40 | 40 | from time import time |
41 | 41 |
|
| 42 | +from PyQt6 import sip |
42 | 43 | from PyQt6.QtCore import ( |
43 | 44 | QMimeData, QObject, QPoint, QRect, QRegularExpression, QRunnable, Qt, |
44 | 45 | QTimer, QVariant, pyqtSignal, pyqtSlot |
|
76 | 77 | from novelwriter.tools.lipsum import GuiLipsum |
77 | 78 | from novelwriter.types import ( |
78 | 79 | QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop, |
79 | | - QtAlignRight, QtBlack, QtImCursorRectangle, QtKeepAnchor, QtModCtrl, |
80 | | - QtModNone, QtModShift, QtMouseLeft, QtMoveAnchor, QtMoveDown, QtMoveEnd, |
81 | | - QtMoveEndOfLine, QtMoveEndOfWord, QtMoveLeft, QtMoveNextChar, |
82 | | - QtMoveNextWord, QtMovePreviousWord, QtMoveRight, QtMoveStart, |
83 | | - QtMoveStartOfLine, QtMoveUp, QtScrollAlwaysOff, QtScrollAsNeeded, |
84 | | - QtSelectBlock, QtSelectDocument, QtSelectLine, QtSelectWord, QtTransparent |
| 80 | + QtAlignRight, QtBlack, QtImCurrentSelection, QtImCursorRectangle, |
| 81 | + QtKeepAnchor, QtModCtrl, QtModNone, QtModShift, QtMouseLeft, QtMoveAnchor, |
| 82 | + QtMoveDown, QtMoveEnd, QtMoveEndOfLine, QtMoveEndOfWord, QtMoveLeft, |
| 83 | + QtMoveNextChar, QtMoveNextWord, QtMovePreviousWord, QtMoveRight, |
| 84 | + QtMoveStart, QtMoveStartOfLine, QtMoveUp, QtScrollAlwaysOff, |
| 85 | + QtScrollAsNeeded, QtSelectBlock, QtSelectDocument, QtSelectLine, |
| 86 | + QtSelectWord, QtTransparent |
85 | 87 | ) |
86 | 88 |
|
87 | 89 | logger = logging.getLogger(__name__) |
@@ -1070,6 +1072,12 @@ def inputMethodQuery(self, query: Qt.InputMethodQuery) -> QRect | QVariant: |
1070 | 1072 | rect = self.cursorRect() |
1071 | 1073 | rect.translate(vM.left(), vM.top()) |
1072 | 1074 | return rect |
| 1075 | + elif query == QtImCurrentSelection: |
| 1076 | + # See issue #2622 |
| 1077 | + ac = sip.enableautoconversion(QVariant, False) # type: ignore |
| 1078 | + variant = super().inputMethodQuery(query) |
| 1079 | + sip.enableautoconversion(QVariant, ac) # type: ignore |
| 1080 | + return variant |
1073 | 1081 | return super().inputMethodQuery(query) |
1074 | 1082 |
|
1075 | 1083 | def insertFromMimeData(self, source: QMimeData | None) -> None: |
|
0 commit comments