From f26cb7c2814afbffbb910750437a16501a4f7a75 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" Date: Fri, 10 May 2019 21:16:11 +0200 Subject: [PATCH] Open spell check context menu with ctrl+. shortcut --- nw/gui/doceditor.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nw/gui/doceditor.py b/nw/gui/doceditor.py index 82baf8e3..7440e782 100644 --- a/nw/gui/doceditor.py +++ b/nw/gui/doceditor.py @@ -16,9 +16,9 @@ import enchant from time import time -from PyQt5.QtWidgets import QTextEdit, QAction, QMenu +from PyQt5.QtWidgets import QTextEdit, QAction, QMenu, QShortcut +from PyQt5.QtGui import QTextCursor, QTextOption, QIcon, QKeySequence from PyQt5.QtCore import Qt, QTimer -from PyQt5.QtGui import QTextCursor, QTextOption, QIcon from nw.gui.dochighlight import GuiDocHighlighter from nw.gui.wordcounter import WordCounter @@ -80,6 +80,9 @@ class GuiDocEditor(QTextEdit): self.setAcceptRichText(False) self.setFontPointSize(self.mainConf.textSize) + # Custom Shortcuts + QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext) + # Set Up Word Count Thread and Timer self.wcInterval = self.mainConf.wordCountTimer self.wcTimer = QTimer() @@ -163,6 +166,10 @@ class GuiDocEditor(QTextEdit): # Internal Functions ## + def _openSpellContext(self): + self._openContextMenu(self.cursorRect().center()) + return + def _openContextMenu(self, thePos): theCursor = self.cursorForPosition(thePos)