From 6d15bc5f145d4542e69b140d99edc8eb68a5426b Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 29 Oct 2022 00:56:39 +0200 Subject: [PATCH 1/5] Fix help text in Preferences --- novelwriter/dialogs/preferences.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/novelwriter/dialogs/preferences.py b/novelwriter/dialogs/preferences.py index 6b9dbd9f..72498421 100644 --- a/novelwriter/dialogs/preferences.py +++ b/novelwriter/dialogs/preferences.py @@ -183,7 +183,7 @@ class GuiPreferencesGeneral(QWidget): self.mainForm.addRow( self.tr("Main GUI language"), self.guiLang, - self.tr("Requires restart.") + self.tr("Requires restart to take effect.") ) # Select Theme @@ -199,7 +199,7 @@ class GuiPreferencesGeneral(QWidget): self.mainForm.addRow( self.tr("Main GUI theme"), self.guiTheme, - self.tr("Requires restart.") + self.tr("General colour theme and icons.") ) # Editor Theme @@ -229,7 +229,7 @@ class GuiPreferencesGeneral(QWidget): self.mainForm.addRow( self.tr("Font family"), self.guiFont, - self.tr("Requires restart."), + self.tr("Requires restart to take effect."), theButton=self.fontButton ) @@ -242,7 +242,7 @@ class GuiPreferencesGeneral(QWidget): self.mainForm.addRow( self.tr("Font size"), self.guiFontSize, - self.tr("Requires restart."), + self.tr("Requires restart to take effect."), theUnit=self.tr("pt") ) From 33eb3efb11ec0482a05d9853258b813eab24d93d Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 29 Oct 2022 01:05:33 +0200 Subject: [PATCH 2/5] Remove restriction on formatting empty block (#1178) --- novelwriter/gui/doceditor.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 3e4a965f..9126872b 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -1709,12 +1709,8 @@ class GuiDocEditor(QTextEdit): logger.debug("Invalid block selected for action '%s'", str(docAction)) return False - theText = theBlock.text() - if len(theText.strip()) == 0: - logger.debug("Empty block selected for action '%s'", str(docAction)) - return False - # Remove existing format first, if any + theText = theBlock.text() if theText.startswith("@"): logger.error("Cannot apply block format to keyword/value line") return False From dc401278fb93711e518f918b3e757f88b19796f4 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 29 Oct 2022 01:05:41 +0200 Subject: [PATCH 3/5] Update tests --- tests/test_gui/test_gui_doceditor.py | 4 ---- tests/test_gui/test_gui_mainmenu.py | 14 ++++++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/test_gui/test_gui_doceditor.py b/tests/test_gui/test_gui_doceditor.py index e2ba77ae..22a960c2 100644 --- a/tests/test_gui/test_gui_doceditor.py +++ b/tests/test_gui/test_gui_doceditor.py @@ -783,10 +783,6 @@ def testGuiEditor_BlockFormatting(qtbot, monkeypatch, nwGUI, nwMinimal, ipsumTex mp.setattr(QTextBlock, "isValid", lambda *a, **k: False) assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) is False - # Empty Block - assert nwGUI.docEditor.setCursorLine(1) is True - assert nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) is False - # Keyword assert nwGUI.docEditor.replaceText("@pov: Jane\n\n") is True assert nwGUI.docEditor.setCursorPosition(5) is True diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index e55e1039..f10514ad 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -116,6 +116,16 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): fmtStr = "#### Pellentesque nec erat ut nulla posuere commodo." assert nwGUI.docEditor.getText()[39:91] == fmtStr + # Title Format + nwGUI.mainMenu.aFmtTitle.activate(QAction.Trigger) + fmtStr = "#! Pellentesque nec erat ut nulla posuere commodo." + assert nwGUI.docEditor.getText()[39:89] == fmtStr + + # Unnumbered Chapter + nwGUI.mainMenu.aFmtUnNum.activate(QAction.Trigger) + fmtStr = "##! Pellentesque nec erat ut nulla posuere commodo." + assert nwGUI.docEditor.getText()[39:90] == fmtStr + # Clear Format nwGUI.mainMenu.aFmtNoFormat.activate(QAction.Trigger) assert nwGUI.docEditor.getText()[39:86] == cleanText @@ -314,10 +324,6 @@ def testGuiMenu_EditFormat(qtbot, monkeypatch, nwGUI, nwLipsum): assert nwGUI.docEditor.setCursorPosition(17) assert not nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) - # Cannot Format Empty Line - assert nwGUI.docEditor.setCursorPosition(13) - assert not nwGUI.docEditor._formatBlock(nwDocAction.BLOCK_TXT) - # Invalid Action assert nwGUI.docEditor.setCursorPosition(30) assert not nwGUI.docEditor._formatBlock(nwDocAction.NO_ACTION) From 3a90ee2b0d5aa0eb1ce927f3b4fc03a947c08612 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 29 Oct 2022 01:26:26 +0200 Subject: [PATCH 4/5] Add insert menu entry for synopsis comment (#1177) --- novelwriter/enum.py | 7 ++++--- novelwriter/gui/doceditor.py | 10 +++++++++- novelwriter/gui/mainmenu.py | 9 +++++++++ 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/novelwriter/enum.py b/novelwriter/enum.py index 48b894ba..ecb4ea4a 100644 --- a/novelwriter/enum.py +++ b/novelwriter/enum.py @@ -112,9 +112,10 @@ class nwDocInsert(Enum): QUOTE_RS = 2 QUOTE_LD = 3 QUOTE_RD = 4 - NEW_PAGE = 5 - VSPACE_S = 6 - VSPACE_M = 7 + SYNOPSIS = 5 + NEW_PAGE = 6 + VSPACE_S = 7 + VSPACE_M = 8 # END Enum nwDocInsert diff --git a/novelwriter/gui/doceditor.py b/novelwriter/gui/doceditor.py index 9126872b..0bde6d8c 100644 --- a/novelwriter/gui/doceditor.py +++ b/novelwriter/gui/doceditor.py @@ -877,6 +877,7 @@ class GuiDocEditor(QTextEdit): return False newBlock = False + goAfter = False if isinstance(theInsert, str): theText = theInsert @@ -889,22 +890,29 @@ class GuiDocEditor(QTextEdit): theText = self._typDQOpen elif theInsert == nwDocInsert.QUOTE_RD: theText = self._typDQClose + elif theInsert == nwDocInsert.SYNOPSIS: + theText = "% Synopsis: " + newBlock = True + goAfter = True elif theInsert == nwDocInsert.NEW_PAGE: theText = "[NEW PAGE]" newBlock = True + goAfter = False elif theInsert == nwDocInsert.VSPACE_S: theText = "[VSPACE]" newBlock = True + goAfter = False elif theInsert == nwDocInsert.VSPACE_M: theText = "[VSPACE:2]" newBlock = True + goAfter = False else: return False else: return False if newBlock: - self.insertNewBlock(theText, defaultAfter=False) + self.insertNewBlock(theText, defaultAfter=goAfter) else: theCursor = self.textCursor() theCursor.beginEditBlock() diff --git a/novelwriter/gui/mainmenu.py b/novelwriter/gui/mainmenu.py index a110cb8a..8a74035e 100644 --- a/novelwriter/gui/mainmenu.py +++ b/novelwriter/gui/mainmenu.py @@ -554,6 +554,15 @@ class GuiMainMenu(QMenuBar): ) self.mInsKeywords.addAction(self.mInsKWItems[keyWord][0]) + # Insert > Special Comments + self.mInsComments = self.insertMenu.addMenu(self.tr("Special Comments")) + + # Insert > Synopsis Comment + self.aInsSynopsis = QAction(self.tr("Synopsis Comment"), self) + self.aInsSynopsis.setShortcut("Ctrl+K, S") + self.aInsSynopsis.triggered.connect(lambda: self._docInsert(nwDocInsert.SYNOPSIS)) + self.mInsComments.addAction(self.aInsSynopsis) + # Insert > Symbols self.mInsBreaks = self.insertMenu.addMenu(self.tr("Page Break and Space")) From dcb473137b4bf61976bc83de09afb11dc4b3a625 Mon Sep 17 00:00:00 2001 From: Veronica Berglyd Olsen <1619840+vkbo@users.noreply.github.com> Date: Sat, 29 Oct 2022 01:26:58 +0200 Subject: [PATCH 5/5] Update documentation and test with synopsis insert feature --- docs/source/usage_shortcuts.rst | 1 + tests/test_gui/test_gui_mainmenu.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/source/usage_shortcuts.rst b/docs/source/usage_shortcuts.rst index 7a321bcc..8254dfe0 100644 --- a/docs/source/usage_shortcuts.rst +++ b/docs/source/usage_shortcuts.rst @@ -137,6 +137,7 @@ a key or key combination for the inserted content. ":kbd:`Ctrl`:kbd:`K`, :kbd:`F`", "Insert a ``@focus`` keyword." ":kbd:`Ctrl`:kbd:`K`, :kbd:`C`", "Insert a ``@char`` keyword." ":kbd:`Ctrl`:kbd:`K`, :kbd:`P`", "Insert a ``@plot`` keyword." + ":kbd:`Ctrl`:kbd:`K`, :kbd:`S`", "Insert a synopsis comment." ":kbd:`Ctrl`:kbd:`K`, :kbd:`T`", "Insert a ``@time`` keyword." ":kbd:`Ctrl`:kbd:`K`, :kbd:`L`", "Insert a ``@location`` keyword." ":kbd:`Ctrl`:kbd:`K`, :kbd:`O`", "Insert an ``@object`` keyword." diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index f10514ad..7d7caaf7 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -537,9 +537,8 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): assert nwGUI.docEditor.getText() == nwUnicode.U_THNBSP nwGUI.docEditor.clear() - ## - # Insert Keywords - ## + # Insert Keywords + # =============== nwGUI.docEditor.setText("Stuff") nwGUI.mainMenu.mInsKWItems[nwKeyWords.TAG_KEY][0].activate(QAction.Trigger) @@ -589,9 +588,15 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): nwGUI.docEditor.clear() - ## - # Insert Break or Space - ## + # Insert Special Comments + # ======================= + + nwGUI.docEditor.setText("Stuff\n") + nwGUI.mainMenu.aInsSynopsis.activate(QAction.Trigger) + assert nwGUI.docEditor.getText() == "Stuff\n% Synopsis: \n" + + # Insert Break or Space + # ===================== nwGUI.docEditor.setText("### Stuff\n") nwGUI.mainMenu.aInsNewPage.activate(QAction.Trigger) @@ -607,9 +612,8 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): nwGUI.docEditor.clear() - ## - # Insert text from file - ## + # Insert Text from File + # ===================== nwGUI.closeDocument() @@ -645,9 +649,8 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj, mockRnd): nwGUI.mainMenu.aImportFile.activate(QAction.Trigger) assert nwGUI.docEditor.getText() == "Foo" - ## - # Reveal file location - ## + # Reveal File Location + # ==================== theMessage = ""