Add some more type constants
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -53,7 +53,8 @@ from novelwriter.formats.toqdoc import ToQTextDocument
|
||||
from novelwriter.gui.theme import STYLES_MIN_TOOLBUTTON
|
||||
from novelwriter.types import (
|
||||
QtAlignCenterTop, QtKeepAnchor, QtMouseLeft, QtMoveAnchor,
|
||||
QtScrollAlwaysOff, QtScrollAsNeeded
|
||||
QtScrollAlwaysOff, QtScrollAsNeeded, QtSelectBlock, QtSelectDocument,
|
||||
QtSelectWord
|
||||
)
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -287,9 +288,9 @@ class GuiDocViewer(QTextBrowser):
|
||||
elif action == nwDocAction.COPY:
|
||||
self.copy()
|
||||
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)
|
||||
else:
|
||||
logger.debug("Unknown or unsupported document action '%s'", action)
|
||||
return False
|
||||
@@ -400,14 +401,10 @@ class GuiDocViewer(QTextBrowser):
|
||||
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, point
|
||||
))
|
||||
action.triggered.connect(qtLambda(self._makePosSelection, QtSelectWord, point))
|
||||
|
||||
action = qtAddAction(ctxMenu, self.tr("Select Paragraph"))
|
||||
action.triggered.connect(qtLambda(
|
||||
self._makePosSelection, QTextCursor.SelectionType.BlockUnderCursor, point
|
||||
))
|
||||
action.triggered.connect(qtLambda(self._makePosSelection, QtSelectBlock, point))
|
||||
|
||||
# Open the context menu
|
||||
if viewport := self.viewport():
|
||||
@@ -466,7 +463,7 @@ class GuiDocViewer(QTextBrowser):
|
||||
cursor.clearSelection()
|
||||
cursor.select(selType)
|
||||
|
||||
if selType == QTextCursor.SelectionType.BlockUnderCursor:
|
||||
if selType == QtSelectBlock:
|
||||
# This selection mode also selects the preceding paragraph
|
||||
# separator, which we want to avoid.
|
||||
posS = cursor.selectionStart()
|
||||
|
||||
@@ -109,9 +109,14 @@ QtRoleReject = QDialogButtonBox.ButtonRole.RejectRole
|
||||
|
||||
QtKeepAnchor = QTextCursor.MoveMode.KeepAnchor
|
||||
QtMoveAnchor = QTextCursor.MoveMode.MoveAnchor
|
||||
|
||||
QtMoveLeft = QTextCursor.MoveOperation.Left
|
||||
QtMoveRight = QTextCursor.MoveOperation.Right
|
||||
|
||||
QtSelectWord = QTextCursor.SelectionType.WordUnderCursor
|
||||
QtSelectBlock = QTextCursor.SelectionType.BlockUnderCursor
|
||||
QtSelectDocument = QTextCursor.SelectionType.Document
|
||||
|
||||
QtImCursorRectangle = Qt.InputMethodQuery.ImCursorRectangle
|
||||
|
||||
# Size Policy
|
||||
|
||||
Reference in New Issue
Block a user