From 28d347c848040513012e0eb53a8b08cc3d393a77 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Tue, 5 Nov 2019 10:38:44 +0100 Subject: [PATCH] Some keyboard shortcut tweaks for macOS --- docs/source/interface.txt | 15 ++++++++++----- nw/gui/mainmenu.py | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/source/interface.txt b/docs/source/interface.txt index 4bfe2d4d..5818b65b 100644 --- a/docs/source/interface.txt +++ b/docs/source/interface.txt @@ -68,9 +68,10 @@ These are as following: ":kbd:`Ctrl-B`", "Format selected text, or word under cursor, as bold." ":kbd:`Ctrl-C`", "Copy selected text to clipboard." ":kbd:`Ctrl-D`", "Wrap selected text, or word under cursor, in double quotes." - ":kbd:`Ctrl-E`", "If in tree view, edit a document or folder settings." + ":kbd:`Ctrl-E`", "If in tree view, edit a document or folder settings. (Same as :kbd:`F2`)" ":kbd:`Ctrl-F`", "Open the search bar and search for selected word, if any is selected." - ":kbd:`Ctrl-H`", "Open the search and replace bar and search for selected word, if any is selected." + ":kbd:`Ctrl-G`", "Find next occurrence of word in current document. (Same as :kbd:`F3`)" + ":kbd:`Ctrl-H`", "Open the search and replace bar and search for selected word, if any is selected. (On Mac, this is :kbd:`Cmd+=`)" ":kbd:`Ctrl-I`", "Format selected text, or word under cursor, as italic." ":kbd:`Ctrl-N`", "Create new document." ":kbd:`Ctrl-O`", "Open selected document." @@ -91,6 +92,7 @@ These are as following: ":kbd:`Ctrl-Shift-1`", "Replace occurrence of word in current document, and search for next occurrence." ":kbd:`Ctrl-Shift-A`", "Select all text in current paragraph." ":kbd:`Ctrl-Shift-D`", "Wrap selected text, or word under cursor, in single quotes." + ":kbd:`Ctrl-Shift+G`", "Find previous occurrence of word in current document. (Same as :kbd:`Shift-F3`" ":kbd:`Ctrl-Shift-I`", "Import text to the current document from a text file." ":kbd:`Ctrl-Shift-N`", "Create new folder." ":kbd:`Ctrl-Shift-O`", "Open a project." @@ -100,12 +102,15 @@ These are as following: ":kbd:`Ctrl-Shift-Up`", "Move item one step up in the tree view." ":kbd:`Ctrl-Shift-Down`", "Move item one step down in the tree view." ":kbd:`F1`", "Open documentation." - ":kbd:`F2`", "Alternative to :kbd:`Ctrl-E`." - ":kbd:`F3`", "Find next occurrence of word in current document." + ":kbd:`F2`", "If in tree view, edit a document or folder settings. (Same as :kbd:`Ctrl-E`)" + ":kbd:`F3`", "Find next occurrence of word in current document. (Same as :kbd:`Ctrl-G`)" ":kbd:`F5`", "Export project dialog." ":kbd:`F7`", "Re-run spell checker." ":kbd:`F9`", "Re-build project indices." ":kbd:`Shift-Enter`", "Insert a hard line break at the cursor position." - ":kbd:`Shift-F3`", "Find previous occurrence of word in current document." + ":kbd:`Shift-F3`", "Find previous occurrence of word in current document. (Same as :kbd:`Ctrl-Shift-G`" ":kbd:`Shift-Space`", "Insert a non-breaking space at the cursor position." ":kbd:`Enter`", "If in tree view, open a document for editing." + +.. note:: + On macOS, replace :kbd:`Ctrl` with :kbd:`Cmd`. diff --git a/nw/gui/mainmenu.py b/nw/gui/mainmenu.py index e46dfd4e..c1366662 100644 --- a/nw/gui/mainmenu.py +++ b/nw/gui/mainmenu.py @@ -475,21 +475,30 @@ class GuiMainMenu(QMenuBar): # Edit > Replace menuItem = QAction("Replace", self) menuItem.setStatusTip("Replace text in document") - menuItem.setShortcut("Ctrl+H") + if self.mainConf.osDarwin: + menuItem.setShortcut("Ctrl+=") + else: + menuItem.setShortcut("Ctrl+H") menuItem.triggered.connect(lambda: self._docAction(nwDocAction.REPLACE)) self.editMenu.addAction(menuItem) # Edit > Find Next menuItem = QAction("Find Next", self) menuItem.setStatusTip("Find next occurrence text in document") - menuItem.setShortcut("F3") + if self.mainConf.osDarwin: + menuItem.setShortcuts(["Ctrl+G","F3"]) + else: + menuItem.setShortcuts(["F3","Ctrl+G"]) menuItem.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT)) self.editMenu.addAction(menuItem) # Edit > Find Prev menuItem = QAction("Find Previous", self) menuItem.setStatusTip("Find previous occurrence text in document") - menuItem.setShortcut("Shift+F3") + if self.mainConf.osDarwin: + menuItem.setShortcuts(["Ctrl+Shift+G","Shift+F3"]) + else: + menuItem.setShortcuts(["Shift+F3","Ctrl+Shift+G"]) menuItem.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV)) self.editMenu.addAction(menuItem)