Open spell check context menu with ctrl+. shortcut
This commit is contained in:
+9
-2
@@ -16,9 +16,9 @@ import enchant
|
|||||||
|
|
||||||
from time import time
|
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.QtCore import Qt, QTimer
|
||||||
from PyQt5.QtGui import QTextCursor, QTextOption, QIcon
|
|
||||||
|
|
||||||
from nw.gui.dochighlight import GuiDocHighlighter
|
from nw.gui.dochighlight import GuiDocHighlighter
|
||||||
from nw.gui.wordcounter import WordCounter
|
from nw.gui.wordcounter import WordCounter
|
||||||
@@ -80,6 +80,9 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.setAcceptRichText(False)
|
self.setAcceptRichText(False)
|
||||||
self.setFontPointSize(self.mainConf.textSize)
|
self.setFontPointSize(self.mainConf.textSize)
|
||||||
|
|
||||||
|
# Custom Shortcuts
|
||||||
|
QShortcut(QKeySequence("Ctrl+."), self, context=Qt.WidgetShortcut, activated=self._openSpellContext)
|
||||||
|
|
||||||
# Set Up Word Count Thread and Timer
|
# Set Up Word Count Thread and Timer
|
||||||
self.wcInterval = self.mainConf.wordCountTimer
|
self.wcInterval = self.mainConf.wordCountTimer
|
||||||
self.wcTimer = QTimer()
|
self.wcTimer = QTimer()
|
||||||
@@ -163,6 +166,10 @@ class GuiDocEditor(QTextEdit):
|
|||||||
# Internal Functions
|
# Internal Functions
|
||||||
##
|
##
|
||||||
|
|
||||||
|
def _openSpellContext(self):
|
||||||
|
self._openContextMenu(self.cursorRect().center())
|
||||||
|
return
|
||||||
|
|
||||||
def _openContextMenu(self, thePos):
|
def _openContextMenu(self, thePos):
|
||||||
|
|
||||||
theCursor = self.cursorForPosition(thePos)
|
theCursor = self.cursorForPosition(thePos)
|
||||||
|
|||||||
Reference in New Issue
Block a user