- in Code Editor added shortcut combo key CTRL+SHIFT+V to function as a Special Paste that will replace the '\' char with '/' so the Windows paths will be pasted correctly for TCL Shell. Also doing SHIFT + LMB on the Paste in contextual menu is doing the same.
This commit is contained in:
parent
39eaf12fef
commit
e57b913b7f
@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||
- added ability to create new scripts and open scripts in FlatCAM Script Editor
|
||||
- the Code Editor tab name is changed according to the task; 'save' and 'open' buttons will have filters installed for the QOpenDialog fit to the task
|
||||
- added ability to run a FlatCAM Tcl script by double-clicking on the file
|
||||
- in Code Editor added shortcut combo key CTRL+SHIFT+V to function as a Special Paste that will replace the '\' char with '/' so the Windows paths will be pasted correctly for TCL Shell. Also doing SHIFT + LMB on the Paste in contextual menu is doing the same.
|
||||
|
||||
17.03.2019
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
|
||||
self.cncjob_tab.setLayout(self.cncjob_tab_layout)
|
||||
|
||||
self.code_editor = QtWidgets.QTextEdit()
|
||||
self.code_editor = FCTextAreaExtended()
|
||||
stylesheet = """
|
||||
QTextEdit { selection-background-color:yellow;
|
||||
selection-color:black;
|
||||
|
@ -490,6 +490,50 @@ class FCTextAreaRich(QtWidgets.QTextEdit):
|
||||
return QtCore.QSize(EDIT_SIZE_HINT, default_hint_size.height())
|
||||
|
||||
|
||||
class FCTextAreaExtended(QtWidgets.QTextEdit):
|
||||
def __init__(self, parent=None):
|
||||
super(FCTextAreaExtended, self).__init__(parent)
|
||||
|
||||
def set_value(self, val):
|
||||
self.setText(val)
|
||||
|
||||
def get_value(self):
|
||||
self.toPlainText()
|
||||
|
||||
def insertFromMimeData(self, data):
|
||||
"""
|
||||
Reimplemented such that when SHIFT is pressed and doing click Paste in the contextual menu, the '\' symbol
|
||||
is replaced with the '/' symbol. That's because of the difference in path separators in Windows and TCL
|
||||
:param data:
|
||||
:return:
|
||||
"""
|
||||
modifier = QtWidgets.QApplication.keyboardModifiers()
|
||||
if modifier == Qt.ShiftModifier:
|
||||
text = data.text()
|
||||
text = text.replace('\\', '/')
|
||||
self.insertPlainText(text)
|
||||
else:
|
||||
self.insertPlainText(data.text())
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""
|
||||
Reimplemented so the CTRL + SHIFT + V shortcut key combo will paste the text but replacing '\' with '/'
|
||||
:param event:
|
||||
:return:
|
||||
"""
|
||||
key = event.key()
|
||||
modifier = QtWidgets.QApplication.keyboardModifiers()
|
||||
|
||||
if modifier & Qt.ControlModifier and modifier & Qt.ShiftModifier:
|
||||
if key == QtCore.Qt.Key_V:
|
||||
clipboard = QtWidgets.QApplication.clipboard()
|
||||
clip_text = clipboard.text()
|
||||
clip_text = clip_text.replace('\\', '/')
|
||||
self.insertPlainText(clip_text)
|
||||
|
||||
super(FCTextAreaExtended, self).keyPressEvent(event)
|
||||
|
||||
|
||||
class FCComboBox(QtWidgets.QComboBox):
|
||||
|
||||
def __init__(self, parent=None, callback=None):
|
||||
|
Loading…
Reference in New Issue
Block a user