Clean up types

This commit is contained in:
Veronica Berglyd Olsen
2025-09-12 22:01:17 +02:00
parent 8a01ffa832
commit 42f0d71ecf
2 changed files with 9 additions and 8 deletions
+7 -8
View File
@@ -39,8 +39,8 @@ from enum import Enum, IntFlag
from time import time from time import time
from PyQt6.QtCore import ( from PyQt6.QtCore import (
QObject, QPoint, QRegularExpression, QRunnable, Qt, QTimer, pyqtSignal, QObject, QPoint, QRect, QRegularExpression, QRunnable, Qt, QTimer,
pyqtSlot QVariant, pyqtSignal, pyqtSlot
) )
from PyQt6.QtGui import ( from PyQt6.QtGui import (
QAction, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent, QAction, QCursor, QDragEnterEvent, QDragMoveEvent, QDropEvent,
@@ -75,8 +75,9 @@ from novelwriter.text.counting import standardCounter
from novelwriter.tools.lipsum import GuiLipsum from novelwriter.tools.lipsum import GuiLipsum
from novelwriter.types import ( from novelwriter.types import (
QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop, QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop,
QtAlignRight, QtKeepAnchor, QtModCtrl, QtModNone, QtModShift, QtMouseLeft, QtAlignRight, QtImCursorRectangle, QtKeepAnchor, QtModCtrl, QtModNone,
QtMoveAnchor, QtMoveLeft, QtMoveRight, QtScrollAlwaysOff, QtScrollAsNeeded QtModShift, QtMouseLeft, QtMoveAnchor, QtMoveLeft, QtMoveRight,
QtScrollAlwaysOff, QtScrollAsNeeded
) )
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -1028,17 +1029,15 @@ class GuiDocEditor(QPlainTextEdit):
pos = self.mapToGlobal(rect.bottomLeft()) pos = self.mapToGlobal(rect.bottomLeft())
self._completer.move(pos) self._completer.move(pos)
def inputMethodQuery(self, query: Qt.InputMethodQuery) -> object: def inputMethodQuery(self, query: Qt.InputMethodQuery) -> QRect | QVariant:
"""Adjust completion windows for CJK input methods to consider """Adjust completion windows for CJK input methods to consider
the viewport margins. the viewport margins.
""" """
if query == Qt.InputMethodQuery.ImCursorRectangle: if query == QtImCursorRectangle:
rect = self.cursorRect() rect = self.cursorRect()
vM = self.viewportMargins() vM = self.viewportMargins()
rect.translate(vM.left(), vM.top()) rect.translate(vM.left(), vM.top())
return rect return rect
return super().inputMethodQuery(query) return super().inputMethodQuery(query)
## ##
+2
View File
@@ -110,6 +110,8 @@ QtMoveAnchor = QTextCursor.MoveMode.MoveAnchor
QtMoveLeft = QTextCursor.MoveOperation.Left QtMoveLeft = QTextCursor.MoveOperation.Left
QtMoveRight = QTextCursor.MoveOperation.Right QtMoveRight = QTextCursor.MoveOperation.Right
QtImCursorRectangle = Qt.InputMethodQuery.ImCursorRectangle
# Size Policy # Size Policy
QtSizeExpanding = QSizePolicy.Policy.Expanding QtSizeExpanding = QSizePolicy.Policy.Expanding