Update Qt namespace flags
This commit is contained in:
@@ -27,6 +27,7 @@ from tools import buildTestProject, C
|
||||
from PyQt5.QtCore import Qt
|
||||
|
||||
from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||
from novelwriter.types import QtUserRole
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -53,11 +54,11 @@ def testDlgMerge_Main(qtbot, nwGUI, projPath, mockRnd):
|
||||
itemOne = nwMerge.listBox.item(0)
|
||||
itemTwo = nwMerge.listBox.item(1)
|
||||
|
||||
assert itemOne.data(Qt.ItemDataRole.UserRole) == C.hChapterDoc
|
||||
assert itemTwo.data(Qt.ItemDataRole.UserRole) == C.hSceneDoc
|
||||
assert itemOne.data(QtUserRole) == C.hChapterDoc
|
||||
assert itemTwo.data(QtUserRole) == C.hSceneDoc
|
||||
|
||||
assert itemOne.checkState() == Qt.Checked
|
||||
assert itemTwo.checkState() == Qt.Checked
|
||||
assert itemOne.checkState() == Qt.CheckState.Checked
|
||||
assert itemTwo.checkState() == Qt.CheckState.Checked
|
||||
|
||||
data = nwMerge.getData()
|
||||
assert data["sHandle"] == C.hChapterDir
|
||||
@@ -66,7 +67,7 @@ def testDlgMerge_Main(qtbot, nwGUI, projPath, mockRnd):
|
||||
assert data["finalItems"] == [C.hChapterDoc, C.hSceneDoc]
|
||||
|
||||
# Uncheck second item and toggle trash switch
|
||||
itemTwo.setCheckState(Qt.Unchecked)
|
||||
itemTwo.setCheckState(Qt.CheckState.Unchecked)
|
||||
nwMerge.trashSwitch.setChecked(True)
|
||||
|
||||
data = nwMerge.getData()
|
||||
|
||||
@@ -30,6 +30,7 @@ from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.constants import nwConst, nwUnicode
|
||||
from novelwriter.dialogs.preferences import GuiPreferences
|
||||
from novelwriter.dialogs.quotes import GuiQuoteSelect
|
||||
from novelwriter.types import QtModeNone
|
||||
|
||||
KEY_DELAY = 1
|
||||
|
||||
@@ -141,7 +142,7 @@ def testDlgPreferences_Actions(qtbot, monkeypatch, nwGUI):
|
||||
# Close Using Escape Key
|
||||
prefs.show()
|
||||
with qtbot.waitSignal(prefs.finished) as status:
|
||||
event = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Escape, Qt.KeyboardModifier.NoModifier)
|
||||
event = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_Escape, QtModeNone)
|
||||
prefs.keyPressEvent(event)
|
||||
assert status.args == [nwConst.DLG_FINISHED]
|
||||
|
||||
|
||||
@@ -24,14 +24,15 @@ import pytest
|
||||
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtWidgets import QDialog, QAction, QColorDialog
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwItemType
|
||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
from novelwriter.dialogs.projectsettings import GuiProjectSettings
|
||||
from novelwriter.enum import nwItemType
|
||||
from novelwriter.types import QtMouseLeft
|
||||
|
||||
KEY_DELAY = 1
|
||||
|
||||
@@ -188,13 +189,13 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn
|
||||
# Can't delete the first item (it's in use)
|
||||
status.listBox.clearSelection()
|
||||
status.listBox.setCurrentItem(status.listBox.topLevelItem(0))
|
||||
qtbot.mouseClick(status.delButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(status.delButton, QtMouseLeft)
|
||||
assert status.listBox.topLevelItemCount() == 4
|
||||
|
||||
# Can delete the second item
|
||||
status.listBox.clearSelection()
|
||||
status.listBox.setCurrentItem(status.listBox.topLevelItem(1))
|
||||
qtbot.mouseClick(status.delButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(status.delButton, QtMouseLeft)
|
||||
assert status.listBox.topLevelItemCount() == 3
|
||||
|
||||
# Add a new item
|
||||
@@ -270,21 +271,21 @@ def testDlgProjSettings_StatusImport(qtbot, monkeypatch, nwGUI, projPath, mockRn
|
||||
# Delete unused entry
|
||||
importance.listBox.clearSelection()
|
||||
importance.listBox.setCurrentItem(importance.listBox.topLevelItem(1))
|
||||
qtbot.mouseClick(importance.delButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(importance.delButton, QtMouseLeft)
|
||||
assert importance.listBox.topLevelItemCount() == 3
|
||||
|
||||
# Add a new entry
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(QColorDialog, "getColor", lambda *a: QColor(20, 30, 40))
|
||||
qtbot.mouseClick(importance.addButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(importance.addButton, QtMouseLeft)
|
||||
importance.listBox.clearSelection()
|
||||
importance.listBox.setCurrentItem(importance.listBox.topLevelItem(3))
|
||||
for _ in range(8):
|
||||
qtbot.keyClick(importance.editName, Qt.Key_Backspace, delay=KEY_DELAY)
|
||||
qtbot.keyClick(importance.editName, Qt.Key.Key_Backspace, delay=KEY_DELAY)
|
||||
for c in "Final":
|
||||
qtbot.keyClick(importance.editName, c, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(importance.colButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(importance.saveButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(importance.colButton, QtMouseLeft)
|
||||
qtbot.mouseClick(importance.saveButton, QtMouseLeft)
|
||||
assert importance.listBox.topLevelItemCount() == 4
|
||||
|
||||
assert importance.wasChanged is True
|
||||
@@ -367,7 +368,7 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
assert replace.listBox.topLevelItemCount() == 2
|
||||
|
||||
# Create a new entry
|
||||
qtbot.mouseClick(replace.addButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(replace.addButton, QtMouseLeft)
|
||||
assert replace.listBox.topLevelItemCount() == 3
|
||||
assert replace.listBox.topLevelItem(2).text(0) == "<keyword3>" # type: ignore
|
||||
assert replace.listBox.topLevelItem(2).text(1) == "" # type: ignore
|
||||
@@ -380,13 +381,13 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
replace.editValue.setText("")
|
||||
for c in "With This Stuff ":
|
||||
qtbot.keyClick(replace.editValue, c, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(replace.saveButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(replace.saveButton, QtMouseLeft)
|
||||
assert replace.listBox.topLevelItem(2).text(0) == "<This>" # type: ignore
|
||||
assert replace.listBox.topLevelItem(2).text(1) == "With This Stuff " # type: ignore
|
||||
|
||||
# Create a new entry again
|
||||
replace.listBox.clearSelection()
|
||||
qtbot.mouseClick(replace.addButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(replace.addButton, QtMouseLeft)
|
||||
assert replace.listBox.topLevelItemCount() == 4
|
||||
|
||||
# The list is sorted, so we must find it
|
||||
@@ -399,7 +400,7 @@ def testDlgProjSettings_Replace(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
|
||||
# Then delete the new item
|
||||
replace.listBox.setCurrentItem(replace.listBox.topLevelItem(newIdx))
|
||||
qtbot.mouseClick(replace.delButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(replace.delButton, QtMouseLeft)
|
||||
assert replace.listBox.topLevelItemCount() == 3
|
||||
|
||||
# Check Project
|
||||
|
||||
@@ -37,7 +37,7 @@ from novelwriter.enum import (
|
||||
)
|
||||
from novelwriter.gui.doceditor import GuiDocEditor, GuiDocToolBar
|
||||
from novelwriter.text.counting import standardCounter
|
||||
from novelwriter.types import QtAlignJustify, QtAlignLeft
|
||||
from novelwriter.types import QtAlignJustify, QtAlignLeft, QtMouseLeft
|
||||
|
||||
KEY_DELAY = 1
|
||||
|
||||
@@ -95,7 +95,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
# Select item from header
|
||||
with qtbot.waitSignal(nwGUI.docEditor.requestProjectItemSelected, timeout=1000) as signal:
|
||||
qtbot.mouseClick(nwGUI.docEditor.docHeader, Qt.MouseButton.LeftButton)
|
||||
qtbot.mouseClick(nwGUI.docEditor.docHeader, QtMouseLeft)
|
||||
assert signal.args == [nwGUI.docEditor.docHeader._docHandle, True]
|
||||
|
||||
# Close from header
|
||||
@@ -109,7 +109,7 @@ def testGuiEditor_Init(qtbot, nwGUI, projPath, ipsumText, mockRnd):
|
||||
|
||||
# Select item from header
|
||||
with qtbot.waitSignal(nwGUI.docEditor.requestProjectItemSelected, timeout=1000) as signal:
|
||||
qtbot.mouseClick(nwGUI.docEditor.docHeader, Qt.MouseButton.LeftButton)
|
||||
qtbot.mouseClick(nwGUI.docEditor.docHeader, QtMouseLeft)
|
||||
assert signal.args == ["", True]
|
||||
|
||||
# qtbot.stop()
|
||||
@@ -1788,7 +1788,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert abs(docEditor.getCursorPosition() - 1299) < 3
|
||||
|
||||
# Find next by button
|
||||
qtbot.mouseClick(docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert abs(docEditor.getCursorPosition() - 1513) < 3
|
||||
|
||||
# Activate loop search
|
||||
@@ -1806,14 +1806,14 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
docEditor.setCursorPosition(15)
|
||||
|
||||
# Toggle search again with header button
|
||||
qtbot.mouseClick(docEditor.docHeader.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docEditor.docHeader.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
docSearch.setSearchText("")
|
||||
assert docSearch.isVisible() is True
|
||||
|
||||
# Search for non-existing
|
||||
docEditor.setCursorPosition(0)
|
||||
docSearch.setSearchText("abcdef")
|
||||
qtbot.mouseClick(docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert docEditor.getCursorPosition() < 3 # No result
|
||||
|
||||
# Enable RegEx search
|
||||
@@ -1824,19 +1824,19 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
# Set invalid RegEx
|
||||
docEditor.setCursorPosition(0)
|
||||
docSearch.setSearchText(r"\bSus[")
|
||||
qtbot.mouseClick(docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert docEditor.getCursorPosition() < 3 # No result
|
||||
|
||||
# Set dangerous RegEx (issue #1015)
|
||||
# If this doesn't get caught, the app will hang
|
||||
docEditor.setCursorPosition(0)
|
||||
docSearch.setSearchText(r".*")
|
||||
qtbot.mouseClick(docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert abs(docEditor.getCursorPosition() - 14) < 3
|
||||
|
||||
# Set valid RegEx
|
||||
docSearch.setSearchText(r"\bSus")
|
||||
qtbot.mouseClick(docSearch.searchButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.searchButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert abs(docEditor.getCursorPosition() - 223) < 3
|
||||
|
||||
# Find next and then prev
|
||||
@@ -1887,7 +1887,7 @@ def testGuiEditor_Search(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert abs(docEditor.getCursorPosition() - 223) < 3
|
||||
|
||||
# Replace "sus" with "foo" via replace button
|
||||
qtbot.mouseClick(docSearch.replaceButton, Qt.LeftButton, delay=KEY_DELAY)
|
||||
qtbot.mouseClick(docSearch.replaceButton, QtMouseLeft, delay=KEY_DELAY)
|
||||
assert docEditor.getText()[220:228] == "foocipit"
|
||||
|
||||
# Revert last two replaces
|
||||
|
||||
@@ -24,14 +24,15 @@ import pytest
|
||||
|
||||
from mocked import causeException
|
||||
|
||||
from PyQt5.QtGui import QMouseEvent, QTextCursor
|
||||
from PyQt5.QtCore import QEvent, QPoint, Qt, QUrl
|
||||
from PyQt5.QtGui import QMouseEvent, QTextCursor
|
||||
from PyQt5.QtWidgets import QAction, QApplication, QMenu
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwDocAction
|
||||
from novelwriter.core.tohtml import ToHtml
|
||||
from novelwriter.gui.docviewer import GuiDocViewer
|
||||
from novelwriter.types import QtMouseLeft, QtModeNone
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -59,8 +60,8 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert nwGUI.projView.projTree.getSelectedHandle() is None
|
||||
|
||||
# Re-select via header click
|
||||
button = Qt.MouseButton.LeftButton
|
||||
modifier = Qt.KeyboardModifier.NoModifier
|
||||
button = QtMouseLeft
|
||||
modifier = QtModeNone
|
||||
event = QMouseEvent(QEvent.MouseButtonPress, QPoint(), button, button, modifier)
|
||||
docViewer.docHeader.mousePressEvent(event)
|
||||
assert nwGUI.projView.projTree.getSelectedHandle() == "88243afbe5ed8"
|
||||
@@ -164,7 +165,7 @@ def testGuiViewer_Main(qtbot, monkeypatch, nwGUI, prjLipsum):
|
||||
assert docViewer.docHandle == "88243afbe5ed8"
|
||||
qtbot.mouseClick(docViewer.viewport(), Qt.ForwardButton, pos=rect.center(), delay=100)
|
||||
assert docViewer.docHandle == "4c4f28287af27"
|
||||
qtbot.mouseClick(docViewer.viewport(), Qt.LeftButton, pos=rect.center(), delay=100)
|
||||
qtbot.mouseClick(docViewer.viewport(), QtMouseLeft, pos=rect.center(), delay=100)
|
||||
assert docViewer.docHandle == "4c4f28287af27"
|
||||
|
||||
# Scroll bar default on empty document
|
||||
|
||||
@@ -25,13 +25,13 @@ import pytest
|
||||
from tools import C, writeFile, buildTestProject
|
||||
|
||||
from PyQt5.QtGui import QTextCursor, QTextBlock
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert
|
||||
from novelwriter.constants import nwKeyWords, nwUnicode
|
||||
from novelwriter.enum import nwDocAction, nwDocInsert
|
||||
from novelwriter.gui.doceditor import GuiDocEditor
|
||||
from novelwriter.types import QtMouseLeft
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -359,7 +359,7 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
|
||||
rect = nwGUI.docEditor.cursorRect()
|
||||
|
||||
nwGUI.docEditor._openContextMenu(rect.bottomRight())
|
||||
qtbot.mouseClick(nwGUI.docEditor, Qt.LeftButton, pos=rect.topLeft())
|
||||
qtbot.mouseClick(nwGUI.docEditor, QtMouseLeft, pos=rect.topLeft())
|
||||
|
||||
nwGUI.docEditor._makePosSelection(QTextCursor.WordUnderCursor, rect.center())
|
||||
cursor = nwGUI.docEditor.textCursor()
|
||||
@@ -386,7 +386,7 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
|
||||
rect = nwGUI.docViewer.cursorRect()
|
||||
|
||||
nwGUI.docViewer._openContextMenu(rect.bottomRight())
|
||||
qtbot.mouseClick(nwGUI.docViewer, Qt.LeftButton, pos=rect.topLeft())
|
||||
qtbot.mouseClick(nwGUI.docViewer, QtMouseLeft, pos=rect.topLeft())
|
||||
|
||||
nwGUI.docViewer._makePosSelection(QTextCursor.WordUnderCursor, rect.center())
|
||||
cursor = nwGUI.docViewer.textCursor()
|
||||
@@ -410,12 +410,12 @@ def testGuiMenu_ContextMenus(qtbot, nwGUI, prjLipsum):
|
||||
assert nwGUI.docViewer.docHeader.backButton.isEnabled()
|
||||
assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled()
|
||||
|
||||
qtbot.mouseClick(nwGUI.docViewer.docHeader.backButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(nwGUI.docViewer.docHeader.backButton, QtMouseLeft)
|
||||
assert nwGUI.docViewer.docHandle == "4c4f28287af27"
|
||||
assert not nwGUI.docViewer.docHeader.backButton.isEnabled()
|
||||
assert nwGUI.docViewer.docHeader.forwardButton.isEnabled()
|
||||
|
||||
qtbot.mouseClick(nwGUI.docViewer.docHeader.forwardButton, Qt.LeftButton)
|
||||
qtbot.mouseClick(nwGUI.docViewer.docHeader.forwardButton, QtMouseLeft)
|
||||
assert nwGUI.docViewer.docHandle == "04468803b92e1"
|
||||
assert nwGUI.docViewer.docHeader.backButton.isEnabled()
|
||||
assert not nwGUI.docViewer.docHeader.forwardButton.isEnabled()
|
||||
|
||||
@@ -26,14 +26,15 @@ from pathlib import Path
|
||||
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtGui import QFocusEvent
|
||||
from PyQt5.QtCore import QPoint, Qt, QEvent
|
||||
from PyQt5.QtGui import QFocusEvent
|
||||
from PyQt5.QtWidgets import QInputDialog, QToolTip
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
from novelwriter.enum import nwWidget, nwItemType
|
||||
from novelwriter.gui.noveltree import GuiNovelTree, NovelTreeColumn
|
||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
from novelwriter.types import QtMouseLeft
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -112,7 +113,7 @@ def testGuiNovelTree_TreeItems(qtbot, monkeypatch, nwGUI, projPath, mockRnd):
|
||||
|
||||
# Clear selection with mouse
|
||||
vPort = novelTree.viewport()
|
||||
qtbot.mouseClick(vPort, Qt.LeftButton, pos=vPort.rect().center(), delay=10)
|
||||
qtbot.mouseClick(vPort, QtMouseLeft, pos=vPort.rect().center(), delay=10)
|
||||
assert not scItem.isSelected()
|
||||
|
||||
# Double-click item
|
||||
|
||||
@@ -23,23 +23,24 @@ from __future__ import annotations
|
||||
import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from novelwriter.core.project import NWProject
|
||||
|
||||
from tools import C, buildTestProject
|
||||
from mocked import causeOSError
|
||||
from tools import C, buildTestProject
|
||||
|
||||
from PyQt5.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent, QMouseEvent
|
||||
from PyQt5.QtCore import QEvent, QMimeData, QPoint, QTimer, Qt
|
||||
from PyQt5.QtGui import QDragEnterEvent, QDragMoveEvent, QDropEvent, QMouseEvent
|
||||
from PyQt5.QtWidgets import QMessageBox, QMenu, QTreeWidget, QTreeWidgetItem, QDialog
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass, nwWidget
|
||||
from novelwriter.guimain import GuiMain
|
||||
from novelwriter.core.item import NWItem
|
||||
from novelwriter.gui.projtree import GuiProjectTree, GuiProjectView, _TreeContextMenu
|
||||
from novelwriter.core.project import NWProject
|
||||
from novelwriter.dialogs.docmerge import GuiDocMerge
|
||||
from novelwriter.dialogs.docsplit import GuiDocSplit
|
||||
from novelwriter.dialogs.editlabel import GuiEditLabel
|
||||
from novelwriter.enum import nwItemLayout, nwItemType, nwItemClass, nwWidget
|
||||
from novelwriter.gui.projtree import GuiProjectTree, GuiProjectView, _TreeContextMenu
|
||||
from novelwriter.guimain import GuiMain
|
||||
from novelwriter.types import QtMouseLeft, QtMouseMiddle, QtModeNone
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -821,8 +822,8 @@ def testGuiProjTree_AutoScroll(qtbot, monkeypatch, nwGUI: GuiMain, projPath, moc
|
||||
|
||||
action = Qt.DropAction.MoveAction
|
||||
mime = QMimeData()
|
||||
mouse = Qt.MouseButton.LeftButton
|
||||
modifier = Qt.KeyboardModifier.NoModifier
|
||||
mouse = QtMouseLeft
|
||||
modifier = QtModeNone
|
||||
|
||||
# Scroll Down
|
||||
h = projTree.height()
|
||||
@@ -880,8 +881,8 @@ def testGuiProjTree_DragAndDrop(qtbot, monkeypatch, caplog, nwGUI: GuiMain, proj
|
||||
nPos = projTree.visualItemRect(projTree._getTreeItem(C.hNovelRoot)).bottomLeft()
|
||||
action = Qt.DropAction.MoveAction
|
||||
mime = QMimeData()
|
||||
mouse = Qt.MouseButton.LeftButton
|
||||
modifier = Qt.KeyboardModifier.NoModifier
|
||||
mouse = QtMouseLeft
|
||||
modifier = QtModeNone
|
||||
|
||||
projTree.saveTreeOrder()
|
||||
treeOrder = SHARED.project.tree._order
|
||||
@@ -1082,8 +1083,8 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd)
|
||||
|
||||
eType = QEvent.Type.MouseButtonPress
|
||||
pos = projTree.visualItemRect(projTree._getTreeItem(C.hChapterDoc)).center()
|
||||
button = Qt.MouseButton.MiddleButton
|
||||
modifier = Qt.KeyboardModifier.NoModifier
|
||||
button = QtMouseMiddle
|
||||
modifier = QtModeNone
|
||||
|
||||
# Trigger the viewer
|
||||
event = QMouseEvent(eType, pos, button, button, modifier)
|
||||
@@ -1092,7 +1093,7 @@ def testGuiProjTree_Other(qtbot, monkeypatch, nwGUI: GuiMain, projPath, mockRnd)
|
||||
|
||||
# Trigger the left click clear
|
||||
pos = QPoint(5000, 5000)
|
||||
button = Qt.MouseButton.LeftButton
|
||||
button = QtMouseLeft
|
||||
event = QMouseEvent(eType, pos, button, button, modifier)
|
||||
projTree.setSelectedHandle(C.hChapterDoc)
|
||||
projTree.mousePressEvent(event)
|
||||
|
||||
@@ -26,13 +26,14 @@ from pathlib import Path
|
||||
from datetime import datetime
|
||||
from pytestqt.qtbot import QtBot
|
||||
|
||||
from PyQt5.QtCore import QPoint, Qt
|
||||
from PyQt5.QtCore import QPoint
|
||||
from PyQt5.QtWidgets import QAction, QFileDialog, QMenu
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.enum import nwItemClass
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.tools.welcome import GuiWelcome
|
||||
from novelwriter.types import QtMouseLeft
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -100,19 +101,19 @@ def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath):
|
||||
|
||||
# Single click item
|
||||
assert tabOpen.selectedPath.text() == "Path: /stuff/project_two"
|
||||
qtbot.mouseClick(vPort, Qt.MouseButton.LeftButton, pos=posTwo, delay=10)
|
||||
qtbot.mouseClick(vPort, QtMouseLeft, pos=posTwo, delay=10)
|
||||
assert tabOpen.selectedPath.text() == "Path: /stuff/project_one"
|
||||
|
||||
# Double click item
|
||||
qtbot.mouseClick(vPort, Qt.MouseButton.LeftButton, pos=posTwo, delay=10)
|
||||
qtbot.mouseClick(vPort, QtMouseLeft, pos=posTwo, delay=10)
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(welcome, "close", lambda *a: None)
|
||||
with qtbot.waitSignal(welcome.openProjectRequest, timeout=5000) as signal:
|
||||
qtbot.mouseDClick(vPort, Qt.MouseButton.LeftButton, pos=posTwo, delay=10)
|
||||
qtbot.mouseDClick(vPort, QtMouseLeft, pos=posTwo, delay=10)
|
||||
assert signal.args and signal.args[0] == Path("/stuff/project_one")
|
||||
|
||||
# Press open button
|
||||
qtbot.mouseClick(vPort, Qt.MouseButton.LeftButton, pos=posTwo, delay=10)
|
||||
qtbot.mouseClick(vPort, QtMouseLeft, pos=posTwo, delay=10)
|
||||
with monkeypatch.context() as mp:
|
||||
mp.setattr(welcome, "close", lambda *a: None)
|
||||
with qtbot.waitSignal(welcome.openProjectRequest, timeout=5000) as signal:
|
||||
@@ -128,7 +129,7 @@ def testToolWelcome_Open(qtbot: QtBot, monkeypatch, nwGUI, fncPath):
|
||||
return obj
|
||||
return None
|
||||
|
||||
qtbot.mouseClick(vPort, Qt.MouseButton.LeftButton, pos=posOne, delay=10)
|
||||
qtbot.mouseClick(vPort, QtMouseLeft, pos=posOne, delay=10)
|
||||
ctxMenu = getMenuForPos(posOne)
|
||||
assert isinstance(ctxMenu, QMenu)
|
||||
assert ctxMenu.actions()[0].text() == "Open Project"
|
||||
|
||||
@@ -25,15 +25,15 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from tools import buildTestProject
|
||||
from mocked import causeOSError
|
||||
from tools import buildTestProject
|
||||
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import QAction, QFileDialog
|
||||
|
||||
from novelwriter import SHARED
|
||||
from novelwriter.constants import nwFiles
|
||||
from novelwriter.tools.writingstats import GuiWritingStats
|
||||
from novelwriter.types import QtMouseLeft
|
||||
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -97,11 +97,11 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda *a, **k: ("", ""))
|
||||
assert not sessLog._saveData(sessLog.FMT_CSV)
|
||||
assert not sessLog._saveData(sessLog.FMT_JSON)
|
||||
assert not sessLog._saveData(None)
|
||||
assert not sessLog._saveData(None) # type: ignore
|
||||
|
||||
# Make the save succeed
|
||||
monkeypatch.setattr(QFileDialog, "getSaveFileName", lambda ss, tt, pp, options: (pp, ""))
|
||||
sessLog.listBox.sortByColumn(sessLog.C_TIME, 0)
|
||||
sessLog.listBox.sortByColumn(sessLog.C_TIME, 0) # type: ignore
|
||||
|
||||
assert sessLog.novelWords.text() == "{:n}".format(600)
|
||||
assert sessLog.notesWords.text() == "{:n}".format(275)
|
||||
@@ -156,7 +156,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
# ============
|
||||
|
||||
# No Novel Files
|
||||
qtbot.mouseClick(sessLog.incNovel, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
|
||||
jsonStats = tstPaths.tmpDir / "sessionStats.json"
|
||||
@@ -201,8 +201,8 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
]
|
||||
|
||||
# No Note Files
|
||||
qtbot.mouseClick(sessLog.incNovel, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.incNotes, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
|
||||
qtbot.mouseClick(sessLog.incNotes, QtMouseLeft)
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
|
||||
jsonStats = tstPaths.tmpDir / "sessionStats.json"
|
||||
@@ -247,8 +247,8 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
]
|
||||
|
||||
# No Negative Entries
|
||||
qtbot.mouseClick(sessLog.incNotes, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.hideNegative, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.incNotes, QtMouseLeft)
|
||||
qtbot.mouseClick(sessLog.hideNegative, QtMouseLeft)
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
|
||||
# qtbot.stop()
|
||||
@@ -279,8 +279,8 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
]
|
||||
|
||||
# Un-hide Zero Entries
|
||||
qtbot.mouseClick(sessLog.hideNegative, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.hideZeros, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.hideNegative, QtMouseLeft)
|
||||
qtbot.mouseClick(sessLog.hideZeros, QtMouseLeft)
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
|
||||
jsonStats = tstPaths.tmpDir / "sessionStats.json"
|
||||
@@ -333,7 +333,7 @@ def testToolWritingStats_Main(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
|
||||
]
|
||||
|
||||
# Group by Day
|
||||
qtbot.mouseClick(sessLog.groupByDay, Qt.LeftButton)
|
||||
qtbot.mouseClick(sessLog.groupByDay, QtMouseLeft)
|
||||
assert sessLog._saveData(sessLog.FMT_JSON)
|
||||
|
||||
jsonStats = tstPaths.tmpDir / "sessionStats.json"
|
||||
|
||||
Reference in New Issue
Block a user