Add some more type constants

This commit is contained in:
Veronica Berglyd Olsen
2025-10-04 18:42:20 +02:00
parent 100aad1256
commit 42352e9500
6 changed files with 39 additions and 41 deletions
+11 -14
View File
@@ -77,7 +77,8 @@ from novelwriter.types import (
QtAlignCenterTop, QtAlignJustify, QtAlignLeft, QtAlignLeftTop,
QtAlignRight, QtImCursorRectangle, QtKeepAnchor, QtModCtrl, QtModNone,
QtModShift, QtMouseLeft, QtMoveAnchor, QtMoveLeft, QtMoveRight,
QtScrollAlwaysOff, QtScrollAsNeeded, QtTransparent
QtScrollAlwaysOff, QtScrollAsNeeded, QtSelectBlock, QtSelectDocument,
QtSelectWord, QtTransparent
)
logger = logging.getLogger(__name__)
@@ -731,9 +732,9 @@ class GuiDocEditor(QPlainTextEdit):
elif action == nwDocAction.D_QUOTE:
self._wrapSelection(CONFIG.fmtDQuoteOpen, CONFIG.fmtDQuoteClose)
elif action == nwDocAction.SEL_ALL:
self._makeSelection(QTextCursor.SelectionType.Document)
self._makeSelection(QtSelectDocument)
elif action == nwDocAction.SEL_PARA:
self._makeSelection(QTextCursor.SelectionType.BlockUnderCursor)
self._makeSelection(QtSelectBlock)
elif action == nwDocAction.BLOCK_H1:
self._formatBlock(nwDocAction.BLOCK_H1)
elif action == nwDocAction.BLOCK_H2:
@@ -1174,13 +1175,9 @@ class GuiDocEditor(QPlainTextEdit):
action = qtAddAction(ctxMenu, self.tr("Select All"))
action.triggered.connect(qtLambda(self.docAction, nwDocAction.SEL_ALL))
action = qtAddAction(ctxMenu, self.tr("Select Word"))
action.triggered.connect(qtLambda(
self._makePosSelection, QTextCursor.SelectionType.WordUnderCursor, pos,
))
action.triggered.connect(qtLambda(self._makePosSelection, QtSelectWord, pos))
action = qtAddAction(ctxMenu, self.tr("Select Paragraph"))
action.triggered.connect(qtLambda(
self._makePosSelection, QTextCursor.SelectionType.BlockUnderCursor, pos
))
action.triggered.connect(qtLambda(self._makePosSelection, QtSelectBlock, pos))
# Spell Checking
if SHARED.project.data.spellCheck:
@@ -1770,7 +1767,7 @@ class GuiDocEditor(QPlainTextEdit):
pos = cursor.position()
cursor.beginEditBlock()
self._makeSelection(QTextCursor.SelectionType.BlockUnderCursor, cursor)
self._makeSelection(QtSelectBlock, cursor)
cursor.insertText(text)
cursor.endEditBlock()
@@ -1798,7 +1795,7 @@ class GuiDocEditor(QPlainTextEdit):
if pAction != nwDocAction.NO_ACTION and blockText.strip():
action = pAction # First block decides further actions
cursor.setPosition(block.position())
self._makeSelection(QTextCursor.SelectionType.BlockUnderCursor, cursor)
self._makeSelection(QtSelectBlock, cursor)
cursor.insertText(text)
toggle = False
@@ -1818,7 +1815,7 @@ class GuiDocEditor(QPlainTextEdit):
"""Strip line breaks within paragraphs in the selected text."""
cursor = self.textCursor()
if not cursor.hasSelection():
cursor.select(QTextCursor.SelectionType.Document)
cursor.select(QtSelectDocument)
rS = 0
rE = self._qDocument.characterCount()
@@ -2035,10 +2032,10 @@ class GuiDocEditor(QPlainTextEdit):
cursor.clearSelection()
cursor.select(mode)
if mode == QTextCursor.SelectionType.WordUnderCursor:
if mode == QtSelectWord:
cursor = self._autoSelect()
elif mode == QTextCursor.SelectionType.BlockUnderCursor:
elif mode == QtSelectBlock:
# This selection mode also selects the preceding paragraph
# separator, which we want to avoid.
posS = cursor.selectionStart()