def __init__(self) -> None:
super().__init__()
self._handle = TranslateToolHandle.TranslateToolHandle() #type: TranslateToolHandle.TranslateToolHandle #Because for some reason MyPy thinks this variable contains Optional[ToolHandle].
self._enabled_axis = [ToolHandle.XAxis, ToolHandle.YAxis, ToolHandle.ZAxis]
self._grid_snap = False
self._grid_size = 10
self._moved = False
self._shortcut_key = Qt.Key_T
self._distance_update_time = None #type: Optional[float]
self._distance = None #type: Optional[Vector]
self.setExposedProperties("ToolHint",
"X", "Y", "Z",
SceneNodeSettings.LockPosition)
self._update_selection_center_timer = QTimer()
self._update_selection_center_timer.setInterval(50)
self._update_selection_center_timer.setSingleShot(True)
self._update_selection_center_timer.timeout.connect(self.propertyChanged.emit)
# Ensure that the properties (X, Y & Z) are updated whenever the selection center is changed.
Selection.selectionCenterChanged.connect(self._onSelectionCenterChanged)
# CURA-5966 Make sure to render whenever objects get selected/deselected.
Selection.selectionChanged.connect(self.propertyChanged)
def keyPressEvent(self, e):
if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_F:
text, okPressed = QInputDialog.getText(self, "Find", "Find what: ")
self.setSelectionBackgroundColor(QColor("#6be585"))
if okPressed:
if text == "":
text = " "
self.dialog.noMatch(text)
self.searchtext = text
"""
This is the way to implement a search function using QScintilla
http://pyqt.sourceforge.net/Docs/QScintilla2/classQsciScintilla.html#a37ac2bea94eafcfa639173557a821200
"""
if self.findFirst(
self.searchtext, False, True, False, True, True, -1, -1, True, False
):
pass
else:
self.dialog.noMatch(self.searchtext)
if e.key() == Qt.Key_F3:
self.findNext()
self.setSelectionBackgroundColor(QColor("#6be585"))
if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_L:
self.setCursorPosition(self.line, self.column + 1)
return
if e.modifiers() == Qt.ControlModifier and e.key() == 77:
self.setCursorPosition(self.line + 1, self.column)
return
if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_J:
self.setCursorPosition(self.line, self.column - 1)
if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_I:
self.setCursorPosition(self.line - 1, self.column)
if e.modifiers() == Qt.ControlModifier and e.key() == Qt.Key_T:
self.parent.parent.realterminal()
return
super().keyPressEvent(e)