Update keyboard and mouse enums
This commit is contained in:
@@ -27,7 +27,7 @@ from PyQt5.QtGui import QKeyEvent, QWheelEvent
|
|||||||
from PyQt5.QtWidgets import QWidget
|
from PyQt5.QtWidgets import QWidget
|
||||||
|
|
||||||
from novelwriter.extensions.eventfilters import WheelEventFilter
|
from novelwriter.extensions.eventfilters import WheelEventFilter
|
||||||
from novelwriter.types import QtModShift
|
from novelwriter.types import QtModNone, QtModShift
|
||||||
|
|
||||||
|
|
||||||
class MockWidget(QWidget):
|
class MockWidget(QWidget):
|
||||||
@@ -57,7 +57,11 @@ def testExtEventFilters_WheelEventFilter():
|
|||||||
|
|
||||||
# Sending a mouse wheel event forwards it
|
# Sending a mouse wheel event forwards it
|
||||||
pos = QPoint(0, 0)
|
pos = QPoint(0, 0)
|
||||||
event = QWheelEvent(pos, pos, pos, pos, Qt.NoButton, Qt.NoModifier, Qt.NoScrollPhase, False)
|
event = QWheelEvent(
|
||||||
|
pos, pos, pos, pos,
|
||||||
|
Qt.MouseButton.NoButton, QtModNone, Qt.ScrollMomentum.NoScrollPhase,
|
||||||
|
False,
|
||||||
|
)
|
||||||
eFilter.eventFilter(obj, event)
|
eFilter.eventFilter(obj, event)
|
||||||
assert widget.count == 1
|
assert widget.count == 1
|
||||||
|
|
||||||
|
|||||||
@@ -1153,16 +1153,16 @@ def testGuiEditor_TextManipulation(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
|||||||
assert docEditor.getText() == text
|
assert docEditor.getText() == text
|
||||||
|
|
||||||
# Select All
|
# Select All
|
||||||
qtbot.keyClick(docEditor, Qt.Key_A, modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_A, modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Delete, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Delete, delay=KEY_DELAY)
|
||||||
assert docEditor.getText() == ""
|
assert docEditor.getText() == ""
|
||||||
|
|
||||||
# Undo
|
# Undo
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Z, modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Z, modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
assert docEditor.getText() == text
|
assert docEditor.getText() == text
|
||||||
|
|
||||||
# Redo
|
# Redo
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Y, modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Y, modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
assert docEditor.getText() == ""
|
assert docEditor.getText() == ""
|
||||||
|
|
||||||
# qtbot.stop()
|
# qtbot.stop()
|
||||||
@@ -1679,8 +1679,8 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
nwGUI.docEditor.setFocus()
|
nwGUI.docEditor.setFocus()
|
||||||
for c in "### Scene One":
|
for c in "### Scene One":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Type Keyword @
|
# Type Keyword @
|
||||||
qtbot.keyClick(docEditor, "@", delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "@", delay=KEY_DELAY)
|
||||||
@@ -1695,7 +1695,7 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
assert len(completer.actions()) == 0
|
assert len(completer.actions()) == 0
|
||||||
|
|
||||||
# Delete character and go select @char
|
# Delete character and go select @char
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
assert len(completer.actions()) == 2
|
assert len(completer.actions()) == 2
|
||||||
completer.actions()[0].trigger()
|
completer.actions()[0].trigger()
|
||||||
assert docEditor.getText() == (
|
assert docEditor.getText() == (
|
||||||
@@ -1712,13 +1712,13 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
assert [a.text() for a in completer.actions()] == []
|
assert [a.text() for a in completer.actions()] == []
|
||||||
|
|
||||||
# Deleting it and typing "a", should leave "Jane"
|
# Deleting it and typing "a", should leave "Jane"
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, "a", delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", delay=KEY_DELAY)
|
||||||
assert [a.text() for a in completer.actions()] == ["Jane"]
|
assert [a.text() for a in completer.actions()] == ["Jane"]
|
||||||
|
|
||||||
# Selecting "Jane" should insert it
|
# Selecting "Jane" should insert it
|
||||||
completer.actions()[0].trigger()
|
completer.actions()[0].trigger()
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
assert docEditor.getText() == (
|
assert docEditor.getText() == (
|
||||||
"### Scene One\n\n"
|
"### Scene One\n\n"
|
||||||
"@char: Jane\n"
|
"@char: Jane\n"
|
||||||
@@ -1727,21 +1727,21 @@ def testGuiEditor_Completer(qtbot, nwGUI, projPath, mockRnd):
|
|||||||
# Start a new line with a nonsense keyword, which should be handled
|
# Start a new line with a nonsense keyword, which should be handled
|
||||||
for c in "@: ":
|
for c in "@: ":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Send keypresses to the completer object
|
# Send keypresses to the completer object
|
||||||
qtbot.keyClick(docEditor, "@", delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "@", delay=KEY_DELAY)
|
||||||
assert len(completer.actions()) == len(nwKeyWords.VALID_KEYS)
|
assert len(completer.actions()) == len(nwKeyWords.VALID_KEYS)
|
||||||
qtbot.keyClick(completer, "f", delay=KEY_DELAY)
|
qtbot.keyClick(completer, "f", delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, Qt.Key_Down, delay=KEY_DELAY)
|
qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, " ", delay=KEY_DELAY)
|
qtbot.keyClick(completer, " ", delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, "h", delay=KEY_DELAY)
|
qtbot.keyClick(completer, "h", delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, Qt.Key_Down, delay=KEY_DELAY)
|
qtbot.keyClick(completer, Qt.Key.Key_Down, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(completer, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(completer, Qt.Key_Escape, delay=KEY_DELAY)
|
qtbot.keyClick(completer, Qt.Key.Key_Escape, delay=KEY_DELAY)
|
||||||
assert docEditor.getText() == (
|
assert docEditor.getText() == (
|
||||||
"### Scene One\n\n"
|
"### Scene One\n\n"
|
||||||
"@char: Jane\n"
|
"@char: Jane\n"
|
||||||
@@ -1887,7 +1887,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
|||||||
|
|
||||||
# Find next by enter key
|
# Find next by enter key
|
||||||
monkeypatch.setattr(docSearch.searchBox, "hasFocus", lambda: True)
|
monkeypatch.setattr(docSearch.searchBox, "hasFocus", lambda: True)
|
||||||
qtbot.keyClick(docSearch.searchBox, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docSearch.searchBox, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
assert abs(docEditor.getCursorPosition() - 1299) < 3
|
assert abs(docEditor.getCursorPosition() - 1299) < 3
|
||||||
|
|
||||||
# Find next by button
|
# Find next by button
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ from novelwriter.gui.noveltree import GuiNovelView
|
|||||||
from novelwriter.gui.outline import GuiOutlineView
|
from novelwriter.gui.outline import GuiOutlineView
|
||||||
from novelwriter.gui.projtree import GuiProjectTree
|
from novelwriter.gui.projtree import GuiProjectTree
|
||||||
from novelwriter.tools.welcome import GuiWelcome
|
from novelwriter.tools.welcome import GuiWelcome
|
||||||
|
from novelwriter.types import QtModCtrl, QtModShift
|
||||||
|
|
||||||
from tests.mocked import causeOSError
|
from tests.mocked import causeOSError
|
||||||
from tests.tools import NWD_IGNORE, XML_IGNORE, C, buildTestProject, cmpFiles
|
from tests.tools import NWD_IGNORE, XML_IGNORE, C, buildTestProject, cmpFiles
|
||||||
@@ -266,18 +267,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.docEditor.setFocus()
|
nwGUI.docEditor.setFocus()
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
for c in "# Jane Doe":
|
for c in "# Jane Doe":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: Jane":
|
for c in "@tag: Jane":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file about Jane.":
|
for c in "This is a file about Jane.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a Plot File
|
# Add a Plot File
|
||||||
nwGUI._switchFocus(nwFocus.TREE)
|
nwGUI._switchFocus(nwFocus.TREE)
|
||||||
@@ -288,18 +289,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.docEditor.setFocus()
|
nwGUI.docEditor.setFocus()
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
for c in "# Main Plot":
|
for c in "# Main Plot":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: MainPlot":
|
for c in "@tag: MainPlot":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file [i]detailing[/i] the main plot.":
|
for c in "This is a file [i]detailing[/i] the main plot.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Add a World File
|
# Add a World File
|
||||||
nwGUI._switchFocus(nwFocus.TREE)
|
nwGUI._switchFocus(nwFocus.TREE)
|
||||||
@@ -315,18 +316,18 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.docEditor.setFocus()
|
nwGUI.docEditor.setFocus()
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
for c in "# Main Location":
|
for c in "# Main Location":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@tag: Home":
|
for c in "@tag: Home":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "This is a file describing Jane's home.":
|
for c in "This is a file describing Jane's home.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Trigger autosaves before making more changes
|
# Trigger autosaves before making more changes
|
||||||
nwGUI._autoSaveDocument()
|
nwGUI._autoSaveDocument()
|
||||||
@@ -342,67 +343,67 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
# Type something into the document
|
# Type something into the document
|
||||||
nwGUI.docEditor.setFocus()
|
nwGUI.docEditor.setFocus()
|
||||||
qtbot.keyClick(docEditor, "a", modifier=Qt.ControlModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, "a", modifier=QtModCtrl, delay=KEY_DELAY)
|
||||||
for c in "# Novel":
|
for c in "# Novel":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "## Chapter":
|
for c in "## Chapter":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "@pov: Jane":
|
for c in "@pov: Jane":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@plot: MainPlot":
|
for c in "@plot: MainPlot":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "### Scene":
|
for c in "### Scene":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "% How about a comment?":
|
for c in "% How about a comment?":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@pov: Jane":
|
for c in "@pov: Jane":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@plot: MainPlot":
|
for c in "@plot: MainPlot":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
for c in "@location: Home":
|
for c in "@location: Home":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "#### Some Section":
|
for c in "#### Some Section":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "@char: Jane":
|
for c in "@char: Jane":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "This is a paragraph of nonsense text.":
|
for c in "This is a paragraph of nonsense text.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Don't allow Shift+Enter to insert a line separator (issue #1150)
|
# Don't allow Shift+Enter to insert a line separator (issue #1150)
|
||||||
for c in "This is another paragraph":
|
for c in "This is another paragraph":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Enter, modifier=Qt.ShiftModifier, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Enter, modifier=QtModShift, delay=KEY_DELAY)
|
||||||
for c in "with a line separator in it.":
|
for c in "with a line separator in it.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Auto-Replace
|
# Auto-Replace
|
||||||
# ============
|
# ============
|
||||||
@@ -422,23 +423,23 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
for c in "How about three hyphens - -":
|
for c in "How about three hyphens - -":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Left, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Left, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Backspace, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Right, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Right, delay=KEY_DELAY)
|
||||||
for c in "- for long dash? It works too.":
|
for c in "- for long dash? It works too.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "\"Full line double quoted text.\"":
|
for c in "\"Full line double quoted text.\"":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "'Full line single quoted text.'":
|
for c in "'Full line single quoted text.'":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
# Insert spaces before and after quotes
|
# Insert spaces before and after quotes
|
||||||
docEditor._typPadBefore = "\u201d"
|
docEditor._typPadBefore = "\u201d"
|
||||||
@@ -446,8 +447,8 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
for c in "Some \"double quoted text with spaces padded\".":
|
for c in "Some \"double quoted text with spaces padded\".":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
docEditor._typPadBefore = ""
|
docEditor._typPadBefore = ""
|
||||||
docEditor._typPadAfter = ""
|
docEditor._typPadAfter = ""
|
||||||
@@ -457,23 +458,23 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
for c in "@object: NoSpaceAdded":
|
for c in "@object: NoSpaceAdded":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "% synopsis: No space before this colon.":
|
for c in "% synopsis: No space before this colon.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "Add space before this colon: See?":
|
for c in "Add space before this colon: See?":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "But don't add a double space : See?":
|
for c in "But don't add a double space : See?":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
docEditor._typPadBefore = ""
|
docEditor._typPadBefore = ""
|
||||||
|
|
||||||
@@ -482,33 +483,33 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
for c in "\t\"Tab-indented text\"":
|
for c in "\t\"Tab-indented text\"":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">\"Paragraph-indented text\"":
|
for c in ">\"Paragraph-indented text\"":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">>\"Right-aligned text\"":
|
for c in ">>\"Right-aligned text\"":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in "\t'Tab-indented text'":
|
for c in "\t'Tab-indented text'":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">'Paragraph-indented text'":
|
for c in ">'Paragraph-indented text'":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
for c in ">>'Right-aligned text'":
|
for c in ">>'Right-aligned text'":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
docEditor.wCounterDoc.run()
|
docEditor.wCounterDoc.run()
|
||||||
|
|
||||||
@@ -517,8 +518,8 @@ def testGuiMain_Editing(qtbot, monkeypatch, nwGUI, projPath, tstPaths, mockRnd):
|
|||||||
|
|
||||||
for c in "Some text with tesst in it.":
|
for c in "Some text with tesst in it.":
|
||||||
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, c, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
qtbot.keyClick(docEditor, Qt.Key_Return, delay=KEY_DELAY)
|
qtbot.keyClick(docEditor, Qt.Key.Key_Return, delay=KEY_DELAY)
|
||||||
|
|
||||||
currPos = docEditor.getCursorPosition()
|
currPos = docEditor.getCursorPosition()
|
||||||
assert docEditor._qDocument.spellErrorAtPos(currPos) == ("", -1, -1, [])
|
assert docEditor._qDocument.spellErrorAtPos(currPos) == ("", -1, -1, [])
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ from novelwriter import CONFIG, SHARED
|
|||||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||||
from novelwriter.enum import nwFocus, nwItemType
|
from novelwriter.enum import nwFocus, nwItemType
|
||||||
from novelwriter.gui.noveltree import GuiNovelTree, NovelTreeColumn
|
from novelwriter.gui.noveltree import GuiNovelTree, NovelTreeColumn
|
||||||
from novelwriter.types import QtMouseLeft
|
from novelwriter.types import QtMouseLeft, QtMouseMiddle
|
||||||
|
|
||||||
from tests.tools import C, buildTestProject
|
from tests.tools import C, buildTestProject
|
||||||
|
|
||||||
@@ -127,17 +127,17 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
|||||||
scItem.setSelected(True)
|
scItem.setSelected(True)
|
||||||
assert scItem.isSelected()
|
assert scItem.isSelected()
|
||||||
assert nwGUI.docViewer.docHandle is None
|
assert nwGUI.docViewer.docHandle is None
|
||||||
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=vPort.rect().center(), delay=10)
|
qtbot.mouseClick(vPort, QtMouseMiddle, pos=vPort.rect().center(), delay=10)
|
||||||
assert nwGUI.docViewer.docHandle is None
|
assert nwGUI.docViewer.docHandle is None
|
||||||
|
|
||||||
scRect = novelTree.visualItemRect(scItem)
|
scRect = novelTree.visualItemRect(scItem)
|
||||||
oldData = scItem.data(novelTree.C_TITLE, novelTree.D_HANDLE)
|
oldData = scItem.data(novelTree.C_TITLE, novelTree.D_HANDLE)
|
||||||
scItem.setData(novelTree.C_TITLE, novelTree.D_HANDLE, None)
|
scItem.setData(novelTree.C_TITLE, novelTree.D_HANDLE, None)
|
||||||
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10)
|
qtbot.mouseClick(vPort, QtMouseMiddle, pos=scRect.center(), delay=10)
|
||||||
assert nwGUI.docViewer.docHandle is None
|
assert nwGUI.docViewer.docHandle is None
|
||||||
|
|
||||||
scItem.setData(novelTree.C_TITLE, novelTree.D_HANDLE, oldData)
|
scItem.setData(novelTree.C_TITLE, novelTree.D_HANDLE, oldData)
|
||||||
qtbot.mouseClick(vPort, Qt.MiddleButton, pos=scRect.center(), delay=10)
|
qtbot.mouseClick(vPort, QtMouseMiddle, pos=scRect.center(), delay=10)
|
||||||
assert nwGUI.docViewer.docHandle == C.hSceneDoc
|
assert nwGUI.docViewer.docHandle == C.hSceneDoc
|
||||||
|
|
||||||
# Last Column
|
# Last Column
|
||||||
|
|||||||
Reference in New Issue
Block a user