Allow Ctrl+Del to be propagated to the document editor
This commit is contained in:
@@ -94,6 +94,7 @@ class nwDocAction(Enum):
|
||||
BLOCK_TXT = 23
|
||||
REPL_SNG = 24
|
||||
REPL_DBL = 25
|
||||
DEL_WORD = 26
|
||||
|
||||
# END Enum nwDocAction
|
||||
|
||||
|
||||
+5
-2
@@ -37,11 +37,11 @@ from time import time
|
||||
|
||||
from PyQt5.QtCore import (
|
||||
Qt, QSize, QTimer, pyqtSlot, pyqtSignal, QRegExp, QRegularExpression,
|
||||
QPointF, QObject, QRunnable, QPropertyAnimation
|
||||
QPointF, QObject, QRunnable, QPropertyAnimation, QEvent
|
||||
)
|
||||
from PyQt5.QtGui import (
|
||||
QTextCursor, QTextOption, QKeySequence, QFont, QColor, QPalette,
|
||||
QTextDocument, QCursor, QPixmap
|
||||
QTextDocument, QCursor, QPixmap, QKeyEvent
|
||||
)
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QTextEdit, QAction, QMenu, QShortcut, QMessageBox, QWidget, QLabel,
|
||||
@@ -719,6 +719,8 @@ class GuiDocEditor(QTextEdit):
|
||||
self._replaceQuotes("'", self.typSQOpen, self.typSQClose)
|
||||
elif theAction == nwDocAction.REPL_DBL:
|
||||
self._replaceQuotes("\"", self.typDQOpen, self.typDQClose)
|
||||
elif theAction == nwDocAction.DEL_WORD:
|
||||
self.keyPressEvent(QKeyEvent(QEvent.KeyPress, Qt.Key_Delete, Qt.ControlModifier))
|
||||
else:
|
||||
logger.debug("Unknown or unsupported document action %s" % str(theAction))
|
||||
self._allowAutoReplace(True)
|
||||
@@ -843,6 +845,7 @@ class GuiDocEditor(QTextEdit):
|
||||
* The undo/redo/select all sequences bypasses the docAction
|
||||
pathway from the menu, so we redirect them back from here.
|
||||
"""
|
||||
print(keyEvent.type())
|
||||
self.lastActive = time()
|
||||
isReturn = keyEvent.key() == Qt.Key_Return
|
||||
isReturn |= keyEvent.key() == Qt.Key_Enter
|
||||
|
||||
+11
-1
@@ -172,6 +172,16 @@ class GuiMainMenu(QMenuBar):
|
||||
QDesktopServices.openUrl(QUrl(theUrl))
|
||||
return True
|
||||
|
||||
def _handleCtrlDel(self):
|
||||
"""Direct the Ctrl+Del key press to the correct widget.
|
||||
"""
|
||||
if self.theParent.treeView.hasFocus():
|
||||
self.theParent.treeView.deleteItem(None)
|
||||
elif self.theParent.docEditor.hasFocus():
|
||||
self.theParent.docEditor.docAction(nwDocAction.DEL_WORD)
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
# Menu Builders
|
||||
##
|
||||
@@ -270,7 +280,7 @@ class GuiMainMenu(QMenuBar):
|
||||
self.aDeleteItem = QAction("Delete Item", self)
|
||||
self.aDeleteItem.setStatusTip("Delete selected project item")
|
||||
self.aDeleteItem.setShortcut("Ctrl+Del")
|
||||
self.aDeleteItem.triggered.connect(lambda: self.theParent.treeView.deleteItem(None))
|
||||
self.aDeleteItem.triggered.connect(self._handleCtrlDel)
|
||||
self.projMenu.addAction(self.aDeleteItem)
|
||||
|
||||
# Project > Move Up
|
||||
|
||||
Reference in New Issue
Block a user