Update main menu

This commit is contained in:
Veronica Berglyd Olsen
2024-10-28 16:24:24 +01:00
parent f2d2b4c4f2
commit 857b6ddc55
2 changed files with 257 additions and 282 deletions
+15 -19
View File
@@ -34,7 +34,10 @@ from PyQt5.QtWidgets import QAction, QMenuBar
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.common import openExternalPath, qtLambda from novelwriter.common import openExternalPath, qtLambda
from novelwriter.constants import nwConst, nwKeyWords, nwLabels, nwStyles, nwUnicode, trConst from novelwriter.constants import (
nwConst, nwKeyWords, nwLabels, nwShortcode, nwStats, nwStyles, nwUnicode,
trConst
)
from novelwriter.enum import nwDocAction, nwDocInsert, nwFocus, nwView from novelwriter.enum import nwDocAction, nwDocInsert, nwFocus, nwView
from novelwriter.extensions.eventfilters import StatusTipFilter from novelwriter.extensions.eventfilters import StatusTipFilter
@@ -571,25 +574,11 @@ class GuiMainMenu(QMenuBar):
# Insert > Tags and References # Insert > Tags and References
self.mInsKeywords = self.insMenu.addMenu(self.tr("Tags and References")) self.mInsKeywords = self.insMenu.addMenu(self.tr("Tags and References"))
self.mInsKWItems = {} for key in nwKeyWords.ALL_KEYS:
self.mInsKWItems[nwKeyWords.TAG_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, G") action = self.mInsKeywords.addAction(trConst(nwLabels.KEY_NAME[key]))
self.mInsKWItems[nwKeyWords.POV_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, V") action.setShortcut(nwLabels.KEY_SHORTCUT[key])
self.mInsKWItems[nwKeyWords.FOCUS_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, F")
self.mInsKWItems[nwKeyWords.CHAR_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, C")
self.mInsKWItems[nwKeyWords.PLOT_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, P")
self.mInsKWItems[nwKeyWords.TIME_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, T")
self.mInsKWItems[nwKeyWords.WORLD_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, L")
self.mInsKWItems[nwKeyWords.OBJECT_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, O")
self.mInsKWItems[nwKeyWords.ENTITY_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, E")
self.mInsKWItems[nwKeyWords.CUSTOM_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, X")
self.mInsKWItems[nwKeyWords.MENTION_KEY] = (QAction(self.mInsKeywords), "Ctrl+K, M")
for key in self.mInsKWItems:
action = self.mInsKWItems[key][0]
action.setText(trConst(nwLabels.KEY_NAME[key]))
action.setShortcut(self.mInsKWItems[key][1])
action.triggered.connect(qtLambda(self.requestDocKeyWordInsert.emit, key)) action.triggered.connect(qtLambda(self.requestDocKeyWordInsert.emit, key))
self.mInsKeywords.addAction(action) self.mainGui.addAction(action)
self.mainGui.addAction(self.mInsKWItems[key][0])
# Insert > Special Comments # Insert > Special Comments
self.mInsComments = self.insMenu.addMenu(self.tr("Special Comments")) self.mInsComments = self.insMenu.addMenu(self.tr("Special Comments"))
@@ -610,6 +599,13 @@ class GuiMainMenu(QMenuBar):
) )
self.mainGui.addAction(self.aInsShort) self.mainGui.addAction(self.aInsShort)
# Insert > Word/Character Count
self.mInsField = self.insMenu.addMenu(self.tr("Word/Character Count"))
for field in nwStats.ALL_FIELDS:
value = nwShortcode.FIELD_VALUE.format(field)
action = self.mInsField.addAction(trConst(nwLabels.STATS_NAME[field]))
action.triggered.connect(qtLambda(self.requestDocInsertText.emit, value))
# Insert > Breaks and Vertical Space # Insert > Breaks and Vertical Space
self.mInsBreaks = self.insMenu.addMenu(self.tr("Breaks and Vertical Space")) self.mInsBreaks = self.insMenu.addMenu(self.tr("Breaks and Vertical Space"))
+242 -263
View File
@@ -29,7 +29,7 @@ from PyQt5.QtGui import QDesktopServices, QTextBlock, QTextCursor
from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox from PyQt5.QtWidgets import QAction, QFileDialog, QMessageBox
from novelwriter import CONFIG, SHARED from novelwriter import CONFIG, SHARED
from novelwriter.constants import nwKeyWords, nwUnicode from novelwriter.constants import nwKeyWords, nwShortcode, nwStats, nwUnicode
from novelwriter.enum import nwDocAction, nwDocInsert from novelwriter.enum import nwDocAction, nwDocInsert
from novelwriter.gui.doceditor import GuiDocEditor from novelwriter.gui.doceditor import GuiDocEditor
from novelwriter.types import QtKeepAnchor, QtMoveRight from novelwriter.types import QtKeepAnchor, QtMoveRight
@@ -70,161 +70,163 @@ def testGuiMainMenu_Slots(qtbot, monkeypatch, nwGUI, projPath):
def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum): def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"""Test the main menu Edit and Format entries.""" """Test the main menu Edit and Format entries."""
monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True) monkeypatch.setattr(GuiDocEditor, "hasFocus", lambda *a: True)
mainMenu = nwGUI.mainMenu
docEditor = nwGUI.docEditor
# Test Document Action with No Project # Test Document Action with No Project
assert nwGUI.docEditor.docAction(nwDocAction.COPY) is False assert docEditor.docAction(nwDocAction.COPY) is False
assert nwGUI.openProject(prjLipsum) is True assert nwGUI.openProject(prjLipsum) is True
# Split By Chapter # Split By Chapter
assert nwGUI.openDocument("4c4f28287af27") is True assert nwGUI.openDocument("4c4f28287af27") is True
nwGUI.docEditor.setCursorPosition(57) docEditor.setCursorPosition(57)
cleanText = nwGUI.docEditor.getText()[54:101] cleanText = docEditor.getText()[54:101]
# Bold # Bold
nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo." fmtStr = "**Pellentesque** nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert docEditor.getText()[54:105] == fmtStr
nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Italic # Italic
nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo." fmtStr = "_Pellentesque_ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Strikethrough # Strikethrough
nwGUI.mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger)
fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo." fmtStr = "~~Pellentesque~~ nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert docEditor.getText()[54:105] == fmtStr
nwGUI.mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtStrike.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Should get us back to plain # Should get us back to plain
nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtItalic.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtBold.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Double Quotes # Double Quotes
nwGUI.mainMenu.aFmtDQuote.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtDQuote.activate(QAction.ActionEvent.Trigger)
fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo." fmtStr = "“Pellentesque” nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger) mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Single Quotes # Single Quotes
nwGUI.mainMenu.aFmtSQuote.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtSQuote.activate(QAction.ActionEvent.Trigger)
fmtStr = "Pellentesque nec erat ut nulla posuere commodo." fmtStr = "Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert docEditor.getText()[54:103] == fmtStr
nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger) mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Block Formats # Block Formats
# ============= # =============
# cSpell:ignore Pellentesque erat nulla posuere commodo # cSpell:ignore Pellentesque erat nulla posuere commodo
nwGUI.docEditor.setCursorPosition(57) docEditor.setCursorPosition(57)
# Header 1 # Header 1
nwGUI.mainMenu.aFmtHead1.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtHead1.activate(QAction.ActionEvent.Trigger)
fmtStr = "# Pellentesque nec erat ut nulla posuere commodo." fmtStr = "# Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert docEditor.getText()[54:103] == fmtStr
# Header 2 # Header 2
nwGUI.mainMenu.aFmtHead2.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtHead2.activate(QAction.ActionEvent.Trigger)
fmtStr = "## Pellentesque nec erat ut nulla posuere commodo." fmtStr = "## Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:104] == fmtStr assert docEditor.getText()[54:104] == fmtStr
# Header 3 # Header 3
nwGUI.mainMenu.aFmtHead3.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtHead3.activate(QAction.ActionEvent.Trigger)
fmtStr = "### Pellentesque nec erat ut nulla posuere commodo." fmtStr = "### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert docEditor.getText()[54:105] == fmtStr
# Header 4 # Header 4
nwGUI.mainMenu.aFmtHead4.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtHead4.activate(QAction.ActionEvent.Trigger)
fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo." fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:106] == fmtStr assert docEditor.getText()[54:106] == fmtStr
# Title Format # Title Format
nwGUI.mainMenu.aFmtTitle.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtTitle.activate(QAction.ActionEvent.Trigger)
fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:104] == fmtStr assert docEditor.getText()[54:104] == fmtStr
# Unnumbered Chapter # Unnumbered Chapter
nwGUI.mainMenu.aFmtUnNum.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtUnNum.activate(QAction.ActionEvent.Trigger)
fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:105] == fmtStr assert docEditor.getText()[54:105] == fmtStr
# Hard Scene # Hard Scene
nwGUI.mainMenu.aFmtHardSc.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtHardSc.activate(QAction.ActionEvent.Trigger)
fmtStr = "###! Pellentesque nec erat ut nulla posuere commodo." fmtStr = "###! Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:106] == fmtStr assert docEditor.getText()[54:106] == fmtStr
# Clear Format # Clear Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Comment On # Comment On
nwGUI.mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger)
fmtStr = "% Pellentesque nec erat ut nulla posuere commodo." fmtStr = "% Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:103] == fmtStr assert docEditor.getText()[54:103] == fmtStr
# Comment Off # Comment Off
nwGUI.mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtComment.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Check comment with no space before text # Check comment with no space before text
nwGUI.docEditor.setCursorPosition(54) docEditor.setCursorPosition(54)
nwGUI.docEditor.insertText("%") docEditor.insertText("%")
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo." fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:102] == fmtStr assert docEditor.getText()[54:102] == fmtStr
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Undo/Redo # Undo/Redo
nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger) mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
fmtStr = "%Pellentesque nec erat ut nulla posuere commodo." fmtStr = "%Pellentesque nec erat ut nulla posuere commodo."
assert nwGUI.docEditor.getText()[54:102] == fmtStr assert docEditor.getText()[54:102] == fmtStr
nwGUI.mainMenu.aEditRedo.activate(QAction.ActionEvent.Trigger) mainMenu.aEditRedo.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:101] == cleanText assert docEditor.getText()[54:101] == cleanText
# Cut, Copy and Paste # Cut, Copy and Paste
nwGUI.docEditor.setCursorPosition(54) docEditor.setCursorPosition(54)
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor) docEditor._makeSelection(QTextCursor.WordUnderCursor)
nwGUI.mainMenu.aEditCut.activate(QAction.ActionEvent.Trigger) mainMenu.aEditCut.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert docEditor.getText()[54:104] == (
" nec erat ut nulla posuere commodo. Curabitur nisi" " nec erat ut nulla posuere commodo. Curabitur nisi"
) )
nwGUI.mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger) mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert docEditor.getText()[54:104] == (
"Pellentesque nec erat ut nulla posuere commodo. Cu" "Pellentesque nec erat ut nulla posuere commodo. Cu"
) )
nwGUI.docEditor.setCursorPosition(54) docEditor.setCursorPosition(54)
nwGUI.docEditor._makeSelection(QTextCursor.WordUnderCursor) docEditor._makeSelection(QTextCursor.WordUnderCursor)
nwGUI.mainMenu.aEditCopy.activate(QAction.ActionEvent.Trigger) mainMenu.aEditCopy.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert docEditor.getText()[54:104] == (
"Pellentesque nec erat ut nulla posuere commodo. Cu" "Pellentesque nec erat ut nulla posuere commodo. Cu"
) )
nwGUI.docEditor.setCursorPosition(54) docEditor.setCursorPosition(54)
nwGUI.mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger) mainMenu.aEditPaste.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[54:104] == ( assert docEditor.getText()[54:104] == (
"PellentesquePellentesque nec erat ut nulla posuere" "PellentesquePellentesque nec erat ut nulla posuere"
) )
nwGUI.mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger) mainMenu.aEditUndo.activate(QAction.ActionEvent.Trigger)
# Select Paragraph/All # Select Paragraph/All
nwGUI.docEditor.setCursorPosition(57) docEditor.setCursorPosition(57)
nwGUI.mainMenu.aSelectPar.activate(QAction.ActionEvent.Trigger) mainMenu.aSelectPar.activate(QAction.ActionEvent.Trigger)
cursor = nwGUI.docEditor.textCursor() cursor = docEditor.textCursor()
assert cursor.selectedText() == ( assert cursor.selectedText() == (
"Pellentesque nec erat ut nulla posuere commodo. Curabitur nisi augue, imperdiet et porta " "Pellentesque nec erat ut nulla posuere commodo. Curabitur nisi augue, imperdiet et porta "
"imperdiet, efficitur id leo. Cras finibus arcu at nibh commodo congue. Proin suscipit " "imperdiet, efficitur id leo. Cras finibus arcu at nibh commodo congue. Proin suscipit "
@@ -235,78 +237,78 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"nunc lacus, imperdiet nec posuere ac, interdum non lectus." "nunc lacus, imperdiet nec posuere ac, interdum non lectus."
) )
nwGUI.docEditor.setCursorPosition(57) docEditor.setCursorPosition(57)
nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger) mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
cursor = nwGUI.docEditor.textCursor() cursor = docEditor.textCursor()
assert len(cursor.selectedText()) == 1910 assert len(cursor.selectedText()) == 1910
# Clear the Text # Clear the Text
nwGUI.docEditor.clear() docEditor.clear()
assert nwGUI.docEditor.isEmpty assert docEditor.isEmpty
# Alignment & Indent # Alignment & Indent
# ================== # ==================
cleanText = "A single, short paragraph.\n\n" cleanText = "A single, short paragraph.\n\n"
nwGUI.docEditor.setPlainText(cleanText) docEditor.setPlainText(cleanText)
nwGUI.docEditor.setCursorPosition(0) docEditor.setCursorPosition(0)
# Left Align # Left Align
nwGUI.mainMenu.aFmtAlignLeft.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtAlignLeft.activate(QAction.ActionEvent.Trigger)
fmtStr = "A single, short paragraph. <<" fmtStr = "A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:29] == fmtStr assert docEditor.getText()[:29] == fmtStr
# Right Align # Right Align
nwGUI.mainMenu.aFmtAlignRight.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtAlignRight.activate(QAction.ActionEvent.Trigger)
fmtStr = ">> A single, short paragraph." fmtStr = ">> A single, short paragraph."
assert nwGUI.docEditor.getText()[:29] == fmtStr assert docEditor.getText()[:29] == fmtStr
# Centre Align # Centre Align
nwGUI.mainMenu.aFmtAlignCentre.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtAlignCentre.activate(QAction.ActionEvent.Trigger)
fmtStr = ">> A single, short paragraph. <<" fmtStr = ">> A single, short paragraph. <<"
assert nwGUI.docEditor.getText()[:32] == fmtStr assert docEditor.getText()[:32] == fmtStr
# Left Indent # Left Indent
nwGUI.mainMenu.aFmtIndentLeft.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtIndentLeft.activate(QAction.ActionEvent.Trigger)
fmtStr = "> A single, short paragraph." fmtStr = "> A single, short paragraph."
assert nwGUI.docEditor.getText()[:28] == fmtStr assert docEditor.getText()[:28] == fmtStr
# Right Indent # Right Indent
nwGUI.mainMenu.aFmtIndentRight.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtIndentRight.activate(QAction.ActionEvent.Trigger)
fmtStr = "> A single, short paragraph. <" fmtStr = "> A single, short paragraph. <"
assert nwGUI.docEditor.getText()[:30] == fmtStr assert docEditor.getText()[:30] == fmtStr
# No Format # No Format
nwGUI.mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtNoFormat.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText()[:30] == cleanText assert docEditor.getText()[:30] == cleanText
# Other Checks # Other Checks
# Replace Quotes # Replace Quotes
nwGUI.docEditor.setPlainText(( docEditor.setPlainText((
"### New Text\n\n" "### New Text\n\n"
"Text with 'single' quotes and 'tricky stuff's'.\n\n" "Text with 'single' quotes and 'tricky stuff's'.\n\n"
"Also text with \"double\" quotes which are \"less tricky\".\n\n" "Also text with \"double\" quotes which are \"less tricky\".\n\n"
)) ))
nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger) mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtReplSng.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtReplSng.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"Text with single quotes and tricky stuffs.\n\n" "Text with single quotes and tricky stuffs.\n\n"
"Also text with \"double\" quotes which are \"less tricky\".\n\n" "Also text with \"double\" quotes which are \"less tricky\".\n\n"
) )
nwGUI.mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger) mainMenu.aSelectAll.activate(QAction.ActionEvent.Trigger)
nwGUI.mainMenu.aFmtReplDbl.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtReplDbl.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"Text with single quotes and tricky stuffs.\n\n" "Text with single quotes and tricky stuffs.\n\n"
"Also text with “double” quotes which are “less tricky”.\n\n" "Also text with “double” quotes which are “less tricky”.\n\n"
) )
# Remove in-paragraph line breaks # Remove in-paragraph line breaks
nwGUI.docEditor.setPlainText(( docEditor.setPlainText((
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
"@location: Somewhere\n\n" "@location: Somewhere\n\n"
@@ -314,8 +316,8 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"Here is some text\non multiple\nlines.\n\n" "Here is some text\non multiple\nlines.\n\n"
"With another paragraph\nhere." "With another paragraph\nhere."
)) ))
nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
"@location: Somewhere\n\n" "@location: Somewhere\n\n"
@@ -324,7 +326,7 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"With another paragraph here.\n" "With another paragraph here.\n"
) )
nwGUI.docEditor.setPlainText(( docEditor.setPlainText((
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
"@location: Somewhere\n\n" "@location: Somewhere\n\n"
@@ -332,12 +334,12 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
"Here is some text\non multiple\nlines.\n\n" "Here is some text\non multiple\nlines.\n\n"
"With another paragraph\nhere." "With another paragraph\nhere."
)) ))
cursor = nwGUI.docEditor.textCursor() cursor = docEditor.textCursor()
cursor.setPosition(74) cursor.setPosition(74)
cursor.movePosition(QtMoveRight, QtKeepAnchor, 29) cursor.movePosition(QtMoveRight, QtKeepAnchor, 29)
nwGUI.docEditor.setTextCursor(cursor) docEditor.setTextCursor(cursor)
nwGUI.mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger) mainMenu.aFmtRmBreaks.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == ( assert docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"@char: Someone\n" "@char: Someone\n"
"@location: Somewhere\n\n" "@location: Somewhere\n\n"
@@ -347,10 +349,10 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
) )
# Test Invalid Document Action # Test Invalid Document Action
assert not nwGUI.docEditor.docAction(nwDocAction.NO_ACTION) assert not docEditor.docAction(nwDocAction.NO_ACTION)
# Test Invalid Formats # Test Invalid Formats
nwGUI.docEditor.setPlainText(( docEditor.setPlainText((
"### New Text\n\n" "### New Text\n\n"
"@tag: Bod\n\n" "@tag: Bod\n\n"
"Text with 'single' quotes and 'tricky stuff's'.\n\n" "Text with 'single' quotes and 'tricky stuff's'.\n\n"
@@ -358,15 +360,15 @@ def testGuiMainMenu_EditFormat(qtbot, monkeypatch, nwGUI, prjLipsum):
)) ))
# Cannot Format Tag # Cannot Format Tag
nwGUI.docEditor.setCursorPosition(17) docEditor.setCursorPosition(17)
assert not nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) assert not docEditor._formatBlock(nwDocAction.BLOCK_TXT)
# Invalid Action # Invalid Action
nwGUI.docEditor.setCursorPosition(30) docEditor.setCursorPosition(30)
assert not nwGUI.docEditor._formatBlock(nwDocAction.NO_ACTION) assert not docEditor._formatBlock(nwDocAction.NO_ACTION)
# Ensure No Changes # Ensure No Changes
assert nwGUI.docEditor.getText() == ( assert docEditor.getText() == (
"### New Text\n\n" "### New Text\n\n"
"@tag: Bod\n\n" "@tag: Bod\n\n"
"Text with 'single' quotes and 'tricky stuff's'.\n\n" "Text with 'single' quotes and 'tricky stuff's'.\n\n"
@@ -383,198 +385,175 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
assert nwGUI.projView.projTree._getTreeItem(C.hSceneDoc) is not None assert nwGUI.projView.projTree._getTreeItem(C.hSceneDoc) is not None
assert nwGUI.openDocument(C.hSceneDoc) is True assert nwGUI.openDocument(C.hSceneDoc) is True
nwGUI.docEditor.clear() mainMenu = nwGUI.mainMenu
docEditor = nwGUI.docEditor
docEditor.clear()
# Test Faulty Inserts # Test Faulty Inserts
nwGUI.docEditor.insertText("hello world") docEditor.insertText("hello world")
assert nwGUI.docEditor.getText() == "hello world" assert docEditor.getText() == "hello world"
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.docEditor.insertText(nwDocInsert.NO_INSERT) docEditor.insertText(nwDocInsert.NO_INSERT)
assert nwGUI.docEditor.isEmpty assert docEditor.isEmpty
nwGUI.docEditor.insertText(None) docEditor.insertText(None)
assert nwGUI.docEditor.isEmpty assert docEditor.isEmpty
# qtbot.stop() # qtbot.stop()
nwGUI.docEditor.clear() docEditor.clear()
# Check Menu Entries # Check Menu Entries
nwGUI.mainMenu.aInsENDash.activate(QAction.ActionEvent.Trigger) mainMenu.aInsENDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_ENDASH assert docEditor.getText() == nwUnicode.U_ENDASH
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsEMDash.activate(QAction.ActionEvent.Trigger) mainMenu.aInsEMDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_EMDASH assert docEditor.getText() == nwUnicode.U_EMDASH
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsHorBar.activate(QAction.ActionEvent.Trigger) mainMenu.aInsHorBar.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HBAR assert docEditor.getText() == nwUnicode.U_HBAR
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsFigDash.activate(QAction.ActionEvent.Trigger) mainMenu.aInsFigDash.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_FGDASH assert docEditor.getText() == nwUnicode.U_FGDASH
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsQuoteLS.activate(QAction.ActionEvent.Trigger) mainMenu.aInsQuoteLS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteOpen assert docEditor.getText() == CONFIG.fmtSQuoteOpen
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsQuoteRS.activate(QAction.ActionEvent.Trigger) mainMenu.aInsQuoteRS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtSQuoteClose assert docEditor.getText() == CONFIG.fmtSQuoteClose
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsQuoteLD.activate(QAction.ActionEvent.Trigger) mainMenu.aInsQuoteLD.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteOpen assert docEditor.getText() == CONFIG.fmtDQuoteOpen
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsQuoteRD.activate(QAction.ActionEvent.Trigger) mainMenu.aInsQuoteRD.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == CONFIG.fmtDQuoteClose assert docEditor.getText() == CONFIG.fmtDQuoteClose
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsMSApos.activate(QAction.ActionEvent.Trigger) mainMenu.aInsMSApos.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_MAPOS assert docEditor.getText() == nwUnicode.U_MAPOS
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsEllipsis.activate(QAction.ActionEvent.Trigger) mainMenu.aInsEllipsis.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HELLIP assert docEditor.getText() == nwUnicode.U_HELLIP
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsPrime.activate(QAction.ActionEvent.Trigger) mainMenu.aInsPrime.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_PRIME assert docEditor.getText() == nwUnicode.U_PRIME
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsDPrime.activate(QAction.ActionEvent.Trigger) mainMenu.aInsDPrime.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DPRIME assert docEditor.getText() == nwUnicode.U_DPRIME
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsBullet.activate(QAction.ActionEvent.Trigger) mainMenu.aInsBullet.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_BULL assert docEditor.getText() == nwUnicode.U_BULL
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsHyBull.activate(QAction.ActionEvent.Trigger) mainMenu.aInsHyBull.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_HYBULL assert docEditor.getText() == nwUnicode.U_HYBULL
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsFlower.activate(QAction.ActionEvent.Trigger) mainMenu.aInsFlower.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_FLOWER assert docEditor.getText() == nwUnicode.U_FLOWER
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsPerMille.activate(QAction.ActionEvent.Trigger) mainMenu.aInsPerMille.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_PERMIL assert docEditor.getText() == nwUnicode.U_PERMIL
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsDegree.activate(QAction.ActionEvent.Trigger) mainMenu.aInsDegree.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DEGREE assert docEditor.getText() == nwUnicode.U_DEGREE
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsMinus.activate(QAction.ActionEvent.Trigger) mainMenu.aInsMinus.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_MINUS assert docEditor.getText() == nwUnicode.U_MINUS
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsTimes.activate(QAction.ActionEvent.Trigger) mainMenu.aInsTimes.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_TIMES assert docEditor.getText() == nwUnicode.U_TIMES
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsDivide.activate(QAction.ActionEvent.Trigger) mainMenu.aInsDivide.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_DIVIDE assert docEditor.getText() == nwUnicode.U_DIVIDE
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsNBSpace.activate(QAction.ActionEvent.Trigger) mainMenu.aInsNBSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_NBSP assert docEditor.getText() == nwUnicode.U_NBSP
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsThinSpace.activate(QAction.ActionEvent.Trigger) mainMenu.aInsThinSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_THSP assert docEditor.getText() == nwUnicode.U_THSP
nwGUI.docEditor.clear() docEditor.clear()
nwGUI.mainMenu.aInsThinNBSpace.activate(QAction.ActionEvent.Trigger) mainMenu.aInsThinNBSpace.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP assert docEditor.getText() == nwUnicode.U_THNBSP
nwGUI.docEditor.clear() docEditor.clear()
# Insert Keywords # Insert Keywords
# =============== # ===============
nwGUI.docEditor.setPlainText("Stuff") for action, key in zip(mainMenu.mInsKeywords.actions(), nwKeyWords.ALL_KEYS):
nwGUI.mainMenu.mInsKWItems[nwKeyWords.TAG_KEY][0].activate(QAction.ActionEvent.Trigger) docEditor.setPlainText("Stuff")
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TAG_KEY action.activate(QAction.ActionEvent.Trigger)
assert docEditor.getText() == f"Stuff\n{key}: "
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.POV_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.POV_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.FOCUS_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.FOCUS_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.CHAR_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CHAR_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.PLOT_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.PLOT_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.TIME_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.TIME_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.WORLD_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.WORLD_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.OBJECT_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.OBJECT_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.ENTITY_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.ENTITY_KEY
nwGUI.docEditor.setPlainText("Stuff")
nwGUI.mainMenu.mInsKWItems[nwKeyWords.CUSTOM_KEY][0].activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%s: " % nwKeyWords.CUSTOM_KEY
# Faulty Keyword Inserts # Faulty Keyword Inserts
assert not nwGUI.docEditor.insertKeyWord("blabla") assert not docEditor.insertKeyWord("blabla")
with monkeypatch.context() as mp: with monkeypatch.context() as mp:
mp.setattr(QTextBlock, "isValid", lambda *a, **k: False) mp.setattr(QTextBlock, "isValid", lambda *a, **k: False)
assert not nwGUI.docEditor.insertKeyWord(nwKeyWords.TAG_KEY) assert not docEditor.insertKeyWord(nwKeyWords.TAG_KEY)
nwGUI.docEditor.clear() # Insert Fields
# =============
for action, field in zip(mainMenu.mInsField.actions(), nwStats.ALL_FIELDS):
value = nwShortcode.FIELD_VALUE.format(field)
docEditor.setPlainText("Stuff ")
docEditor.setCursorPosition(6)
action.activate(QAction.ActionEvent.Trigger)
assert docEditor.getText() == f"Stuff {value}"
docEditor.clear()
# Insert Special Comments # Insert Special Comments
# ======================= # =======================
nwGUI.docEditor.setPlainText("Stuff\n") docEditor.setPlainText("Stuff\n")
nwGUI.mainMenu.aInsSynopsis.activate(QAction.ActionEvent.Trigger) mainMenu.aInsSynopsis.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%Synopsis: \n" assert docEditor.getText() == "Stuff\n%Synopsis: \n"
nwGUI.docEditor.setPlainText("Stuff\n") docEditor.setPlainText("Stuff\n")
nwGUI.mainMenu.aInsShort.activate(QAction.ActionEvent.Trigger) mainMenu.aInsShort.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Stuff\n%Short: \n" assert docEditor.getText() == "Stuff\n%Short: \n"
# Breaks and Vertical Space # Breaks and Vertical Space
# ========================= # =========================
nwGUI.docEditor.setPlainText("### Stuff\n") docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsNewPage.activate(QAction.ActionEvent.Trigger) mainMenu.aInsNewPage.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[newpage]\n### Stuff\n" assert docEditor.getText() == "[newpage]\n### Stuff\n"
nwGUI.docEditor.setPlainText("Line OneLine Two\n") docEditor.setPlainText("Line OneLine Two\n")
nwGUI.docEditor.setCursorPosition(8) docEditor.setCursorPosition(8)
nwGUI.mainMenu.aInsLineBreak.activate(QAction.ActionEvent.Trigger) mainMenu.aInsLineBreak.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Line One[br]Line Two\n" assert docEditor.getText() == "Line One[br]Line Two\n"
nwGUI.docEditor.setPlainText("### Stuff\n") docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsVSpaceS.activate(QAction.ActionEvent.Trigger) mainMenu.aInsVSpaceS.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[vspace]\n### Stuff\n" assert docEditor.getText() == "[vspace]\n### Stuff\n"
nwGUI.docEditor.setPlainText("### Stuff\n") docEditor.setPlainText("### Stuff\n")
nwGUI.mainMenu.aInsVSpaceM.activate(QAction.ActionEvent.Trigger) mainMenu.aInsVSpaceM.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "[vspace:2]\n### Stuff\n" assert docEditor.getText() == "[vspace:2]\n### Stuff\n"
nwGUI.docEditor.clear() docEditor.clear()
# Insert Text from File # Insert Text from File
# ===================== # =====================
@@ -600,23 +579,23 @@ def testGuiMainMenu_Insert(qtbot, monkeypatch, nwGUI, fncPath, projPath, mockRnd
# Open the document from before, and add some text to it # Open the document from before, and add some text to it
nwGUI.openDocument(C.hSceneDoc) nwGUI.openDocument(C.hSceneDoc)
nwGUI.docEditor.setPlainText("Bar") docEditor.setPlainText("Bar")
assert nwGUI.docEditor.getText() == "Bar" assert docEditor.getText() == "Bar"
# The document isn't empty, so the message box should pop # The document isn't empty, so the message box should pop
with monkeypatch.context() as mp: with monkeypatch.context() as mp:
mp.setattr(QMessageBox, "result", lambda *a, **k: QMessageBox.StandardButton.No) mp.setattr(QMessageBox, "result", lambda *a, **k: QMessageBox.StandardButton.No)
assert not nwGUI.importDocument() assert not nwGUI.importDocument()
assert nwGUI.docEditor.getText() == "Bar" assert docEditor.getText() == "Bar"
# Finally, accept the replaced text, this time we use the menu entry to trigger it # Finally, accept the replaced text, this time we use the menu entry to trigger it
nwGUI.mainMenu.aImportFile.activate(QAction.ActionEvent.Trigger) mainMenu.aImportFile.activate(QAction.ActionEvent.Trigger)
assert nwGUI.docEditor.getText() == "Foo" assert docEditor.getText() == "Foo"
# Reveal File Location # Reveal File Location
# ==================== # ====================
nwGUI.mainMenu.aFileDetails.activate(QAction.ActionEvent.Trigger) mainMenu.aFileDetails.activate(QAction.ActionEvent.Trigger)
path = str(projPath / "content" / "000000000000f.nwd") path = str(projPath / "content" / "000000000000f.nwd")
assert SHARED.lastAlert.endswith(f"File Location: {path}") assert SHARED.lastAlert.endswith(f"File Location: {path}")