Open spell check context menu with ctrl+. shortcut

This commit is contained in:
Veronica K. B. Olsen
2019-05-10 21:16:11 +02:00
parent 87c786975a
commit f26cb7c281
+9 -2
View File
@@ -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)