Add some pyqtSlot decorators as they apparently improve perforamce a tiny bit
This commit is contained in:
@@ -30,7 +30,7 @@ import nw
|
|||||||
|
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from PyQt5.QtCore import Qt, QTimer
|
from PyQt5.QtCore import Qt, QTimer, pyqtSlot
|
||||||
from PyQt5.QtWidgets import (
|
from PyQt5.QtWidgets import (
|
||||||
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QLabel
|
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QLabel
|
||||||
)
|
)
|
||||||
@@ -589,6 +589,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
# Signals and Slots
|
# Signals and Slots
|
||||||
##
|
##
|
||||||
|
|
||||||
|
@pyqtSlot(int, int, int)
|
||||||
def _docChange(self, thePos, charsRemoved, charsAdded):
|
def _docChange(self, thePos, charsRemoved, charsAdded):
|
||||||
"""Triggered by QTextDocument->contentsChanged. This also
|
"""Triggered by QTextDocument->contentsChanged. This also
|
||||||
triggers the syntax highlighter.
|
triggers the syntax highlighter.
|
||||||
@@ -602,6 +603,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
self._docAutoReplace(self.qDocument.findBlock(thePos))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot("QPoint")
|
||||||
def _openContextMenu(self, thePos):
|
def _openContextMenu(self, thePos):
|
||||||
"""Triggered by right click to open the context menu. Also
|
"""Triggered by right click to open the context menu. Also
|
||||||
triggered by the Ctrl+. shortcut.
|
triggered by the Ctrl+. shortcut.
|
||||||
@@ -663,6 +665,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.hLight.rehighlightBlock(theCursor.block())
|
self.hLight.rehighlightBlock(theCursor.block())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _runCounter(self):
|
def _runCounter(self):
|
||||||
"""Decide whether to run the word counter, or stop the timer due
|
"""Decide whether to run the word counter, or stop the timer due
|
||||||
to inactivity.
|
to inactivity.
|
||||||
@@ -678,6 +681,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
self.wCounter.start()
|
self.wCounter.start()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@pyqtSlot()
|
||||||
def _updateCounts(self):
|
def _updateCounts(self):
|
||||||
"""Slot for the word counter's finished signal
|
"""Slot for the word counter's finished signal
|
||||||
"""
|
"""
|
||||||
@@ -730,6 +734,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def _insertHardBreak(self):
|
def _insertHardBreak(self):
|
||||||
|
"""Inserts a hard line break at the cursor position.
|
||||||
|
"""
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
theCursor.beginEditBlock()
|
theCursor.beginEditBlock()
|
||||||
theCursor.insertText(" \n")
|
theCursor.insertText(" \n")
|
||||||
@@ -737,6 +743,8 @@ class GuiDocEditor(QTextEdit):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def _insertNonBreakingSpace(self):
|
def _insertNonBreakingSpace(self):
|
||||||
|
"""Inserts a non-breaking space at the cursor position.
|
||||||
|
"""
|
||||||
theCursor = self.textCursor()
|
theCursor = self.textCursor()
|
||||||
theCursor.beginEditBlock()
|
theCursor.beginEditBlock()
|
||||||
theCursor.insertText(nwUnicode.U_NBSP)
|
theCursor.insertText(nwUnicode.U_NBSP)
|
||||||
|
|||||||
Reference in New Issue
Block a user