From 09504508d99e44173246268b58d180cdfa2c5a0a Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 26 Jan 2021 14:03:19 +0100 Subject: [PATCH] Add proper minus sign, and change a few shortcuts to more sensible ones --- docs/source/int_interface.rst | 13 ++++++------- nw/constants/constants.py | 2 ++ nw/gui/mainmenu.py | 19 +++++++++++++------ nw/guimain.py | 1 + tests/test_gui/test_gui_mainmenu.py | 4 ++++ 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/docs/source/int_interface.rst b/docs/source/int_interface.rst index 310eea02..e6b35c84 100644 --- a/docs/source/int_interface.rst +++ b/docs/source/int_interface.rst @@ -349,7 +349,6 @@ Most features are available as keyboard shortcuts. These are as follows: ":kbd:`Ctrl`:kbd:`.`", "Open menu to correct word under cursor." ":kbd:`Ctrl`:kbd:`,`", "Open the :guilabel:`Preferences` dialog." ":kbd:`Ctrl`:kbd:`/`", "Change block format to comment." - ":kbd:`Ctrl`:kbd:`-`", "Strikethrough selected text, or word under cursor." ":kbd:`Ctrl`:kbd:`0`", "Remove block formatting for block under cursor." ":kbd:`Ctrl`:kbd:`1`", "Change block format to header level 1." ":kbd:`Ctrl`:kbd:`2`", "Change block format to header level 2." @@ -358,7 +357,7 @@ Most features are available as keyboard shortcuts. These are as follows: ":kbd:`Ctrl`:kbd:`A`", "Select all text in the document." ":kbd:`Ctrl`:kbd:`B`", "Format selected text, or word under cursor, with strong emphasis (bold)." ":kbd:`Ctrl`:kbd:`C`", "Copy selected text to clipboard." - ":kbd:`Ctrl`:kbd:`D`", "Wrap selected text, or word under cursor, in double quotes." + ":kbd:`Ctrl`:kbd:`D`", "Strikethrough selected text, or word under cursor." ":kbd:`Ctrl`:kbd:`E`", "If in the project tree, edit a document or folder settings. (Same as :kbd:`F2`.)" ":kbd:`Ctrl`:kbd:`F`", "Open the search bar and search for the selected word, if any is selected." ":kbd:`Ctrl`:kbd:`G`", "Find next occurrence of search word in current document. (Same as :kbd:`F3`.)" @@ -378,12 +377,13 @@ Most features are available as keyboard shortcuts. These are as follows: ":kbd:`Ctrl`:kbd:`F7`", "Toggle spell checking." ":kbd:`Ctrl`:kbd:`F10`", "Toggle automatic updating of project outline." ":kbd:`Ctrl`:kbd:`Del`", "If in the project tree, move a document to trash, or delete a folder." + ":kbd:`Ctrl`:kbd:`'`", "Wrap selected text, or word under cursor, in single quotes." + ":kbd:`Ctrl`:kbd:`""`", "Wrap selected text, or word under cursor, in double quotes." ":kbd:`Ctrl`:kbd:`Enter`", "Open the tag or reference under the cursor in the Viewer." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`,`", "Open the :guilabel:`Project Settings` dialog." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`/`", "Remove block formatting for block under cursor." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`1`", "Replace occurrence of search word in current document, and search for next occurrence." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`A`", "Select all text in current paragraph." - ":kbd:`Ctrl`:kbd:`Shift`:kbd:`D`", "Wrap selected text, or word under cursor, in single quotes." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`G`", "Find previous occurrence of search word in current document. (Same as :kbd:`Shift`:kbd:`F3`.)" ":kbd:`Ctrl`:kbd:`Shift`:kbd:`I`", "Import text to the current document from a text file." ":kbd:`Ctrl`:kbd:`Shift`:kbd:`N`", "Create new folder." @@ -427,7 +427,7 @@ a key or key combination for the inserted content. :widths: 40, 60 :class: "tight-table" - ":kbd:`Ctrl`:kbd:`K`, :kbd:`-`", "Insert a short dash (en dash)." + ":kbd:`Ctrl`:kbd:`K`, :kbd:`−`", "Insert a short dash (en dash)." ":kbd:`Ctrl`:kbd:`K`, :kbd:`_`", "Insert a long dash (em dash)." ":kbd:`Ctrl`:kbd:`K`, :kbd:`~`", "Insert a figure dash (same width as a number)." ":kbd:`Ctrl`:kbd:`K`, :kbd:`1`", "Insert a left single quote." @@ -443,11 +443,10 @@ a key or key combination for the inserted content. ":kbd:`Ctrl`:kbd:`K`, :kbd:`Shift`:kbd:`Space`", "Insert a thin space." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`Space`", "Insert a thin non-breaking space." ":kbd:`Ctrl`:kbd:`K`, :kbd:`*`", "Insert a list bullet." - ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`T`", "Insert a triangle bullet (alternative bullet)." - ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`-`", "Insert a hyphen bullet (alternative bullet)." + ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`−`", "Insert a hyphen bullet (alternative bullet)." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`*`", "Insert a flower mark (alternative bullet)." ":kbd:`Ctrl`:kbd:`K`, :kbd:`%`", "Insert a per mille symbol." - ":kbd:`Ctrl`:kbd:`K`, :kbd:`0`", "Insert a degree symbol." + ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`O`", "Insert a degree symbol." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`X`", "Insert a times sign." ":kbd:`Ctrl`:kbd:`K`, :kbd:`Ctrl`:kbd:`D`", "Insert a division sign." ":kbd:`Ctrl`:kbd:`K`, :kbd:`G`", "Insert a ``@tag`` keyword." diff --git a/nw/constants/constants.py b/nw/constants/constants.py index 8ee9eb2c..fc095fa1 100644 --- a/nw/constants/constants.py +++ b/nw/constants/constants.py @@ -294,6 +294,7 @@ class nwUnicode: U_FLOWER = "\u2055" # Flower punctuation mark U_PERMIL = "\u2030" # Per mille sign U_DEGREE = "\u00b0" # Degree symbol + U_MINUS = "\u2212" # Minus sign U_TIMES = "\u00d7" # Multiplaction sign U_DIVIDE = "\u00f7" # Division sign @@ -356,6 +357,7 @@ class nwUnicode: H_FLOWER = "⁕" H_PERMIL = "‰" H_DEGREE = "°" + H_MINUS = "−" H_TIMES = "×" H_DIVIDE = "÷" diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index 14a0c729..da42d269 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -662,14 +662,21 @@ class GuiMainMenu(QMenuBar): # Insert > Degree Symbol self.aInsDegree = QAction("Degree Symbol", self) - self.aInsDegree.setStatusTip("Insert a segree symbol") - self.aInsDegree.setShortcut("Ctrl+K, 0") + self.aInsDegree.setStatusTip("Insert a degree symbol") + self.aInsDegree.setShortcut("Ctrl+K, Ctrl+O") self.aInsDegree.triggered.connect(lambda: self._docInsert(nwUnicode.U_DEGREE)) self.mInsSymbol.addAction(self.aInsDegree) + # Insert > Minus Sign + self.aInsMinus = QAction("Minus Sign", self) + self.aInsMinus.setStatusTip("Insert a minus sign (not a hypen or dash)") + self.aInsMinus.setShortcut("Ctrl+K, Ctrl+M") + self.aInsMinus.triggered.connect(lambda: self._docInsert(nwUnicode.U_MINUS)) + self.mInsSymbol.addAction(self.aInsMinus) + # Insert > Times Sign self.aInsTimes = QAction("Times Sign", self) - self.aInsTimes.setStatusTip("Insert a times (multiplication) sign") + self.aInsTimes.setStatusTip("Insert a times sign (multiplication cross)") self.aInsTimes.setShortcut("Ctrl+K, Ctrl+X") self.aInsTimes.triggered.connect(lambda: self._docInsert(nwUnicode.U_TIMES)) self.mInsSymbol.addAction(self.aInsTimes) @@ -781,7 +788,7 @@ class GuiMainMenu(QMenuBar): # Format > Strikethrough self.aFmtStrike = QAction("Strikethrough", self) self.aFmtStrike.setStatusTip("Add strikethrough to selected text") - self.aFmtStrike.setShortcut("Ctrl+-") + self.aFmtStrike.setShortcut("Ctrl+D") self.aFmtStrike.triggered.connect(lambda: self._docAction(nwDocAction.STRIKE)) self.fmtMenu.addAction(self.aFmtStrike) @@ -791,14 +798,14 @@ class GuiMainMenu(QMenuBar): # Format > Double Quotes self.aFmtDQuote = QAction("Wrap Double Quotes", self) self.aFmtDQuote.setStatusTip("Wrap selected text in double quotes") - self.aFmtDQuote.setShortcut("Ctrl+D") + self.aFmtDQuote.setShortcut("Ctrl+\"") self.aFmtDQuote.triggered.connect(lambda: self._docAction(nwDocAction.D_QUOTE)) self.fmtMenu.addAction(self.aFmtDQuote) # Format > Single Quotes self.aFmtSQuote = QAction("Wrap Single Quotes", self) self.aFmtSQuote.setStatusTip("Wrap selected text in single quotes") - self.aFmtSQuote.setShortcut("Ctrl+Shift+D") + self.aFmtSQuote.setShortcut("Ctrl+'") self.aFmtSQuote.triggered.connect(lambda: self._docAction(nwDocAction.S_QUOTE)) self.fmtMenu.addAction(self.aFmtSQuote) diff --git a/nw/guimain.py b/nw/guimain.py index aa32b521..f38b378e 100644 --- a/nw/guimain.py +++ b/nw/guimain.py @@ -1258,6 +1258,7 @@ class GuiMain(QMainWindow): self.addAction(self.mainMenu.aInsFlower) self.addAction(self.mainMenu.aInsPerMille) self.addAction(self.mainMenu.aInsDegree) + self.addAction(self.mainMenu.aInsMinus) self.addAction(self.mainMenu.aInsTimes) self.addAction(self.mainMenu.aInsDivide) diff --git a/tests/test_gui/test_gui_mainmenu.py b/tests/test_gui/test_gui_mainmenu.py index 9e2182da..ae61e14c 100644 --- a/tests/test_gui/test_gui_mainmenu.py +++ b/tests/test_gui/test_gui_mainmenu.py @@ -448,6 +448,10 @@ def testGuiMenu_Insert(qtbot, monkeypatch, nwGUI, fncDir, fncProj): assert nwGUI.docEditor.getText() == nwUnicode.U_DEGREE nwGUI.docEditor.clear() + nwGUI.mainMenu.aInsMinus.activate(QAction.Trigger) + assert nwGUI.docEditor.getText() == nwUnicode.U_MINUS + nwGUI.docEditor.clear() + nwGUI.mainMenu.aInsTimes.activate(QAction.Trigger) assert nwGUI.docEditor.getText() == nwUnicode.U_TIMES nwGUI.docEditor.clear()