- in AppTextEditor made some changes (added some placeholders and a message popup when reaching the end of document)
- when viewing GCode the Find field can now keep the focus
This commit is contained in:
@@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
|
||||
|
||||
=================================================
|
||||
|
||||
22.11.2021
|
||||
|
||||
- in AppTextEditor made some changes (added some placeholders and a message popup when reaching the end of document)
|
||||
- when viewing GCode the Find field can now keep the focus
|
||||
|
||||
21.11.2021
|
||||
|
||||
- updated the language strings
|
||||
|
||||
@@ -91,6 +91,7 @@ class AppTextEditor(QtWidgets.QWidget):
|
||||
|
||||
# Entry FIND
|
||||
self.entryFind = FCEntry()
|
||||
self.entryFind.setPlaceholderText(_("Find box. Enter here the strings to be searched in the text."))
|
||||
self.entryFind.setToolTip(_("Find box. Enter here the strings to be searched in the text."))
|
||||
control_lay.addWidget(self.entryFind)
|
||||
|
||||
@@ -102,6 +103,7 @@ class AppTextEditor(QtWidgets.QWidget):
|
||||
|
||||
# Entry REPLACE
|
||||
self.entryReplace = FCEntry()
|
||||
self.entryReplace.setPlaceholderText(_("String to replace the one in the Find box throughout the text."))
|
||||
self.entryReplace.setToolTip(_("String to replace the one in the Find box throughout the text."))
|
||||
control_lay.addWidget(self.entryReplace)
|
||||
|
||||
@@ -163,6 +165,7 @@ class AppTextEditor(QtWidgets.QWidget):
|
||||
self.buttonPrint.clicked.connect(self.handlePrint)
|
||||
self.buttonPreview.clicked.connect(self.handlePreview)
|
||||
self.buttonFind.clicked.connect(self.handleFindGCode)
|
||||
self.entryFind.editingFinished.connect(self.handleFindGCode)
|
||||
self.buttonReplace.clicked.connect(self.handleReplaceGCode)
|
||||
# self.button_copy_all.clicked.connect(self.handleCopyAll)
|
||||
|
||||
@@ -333,9 +336,25 @@ class AppTextEditor(QtWidgets.QWidget):
|
||||
text_to_be_found = self.entryFind.get_value()
|
||||
|
||||
r = self.code_editor.find(str(text_to_be_found), flags)
|
||||
|
||||
if r is False:
|
||||
self.code_editor.moveCursor(QtGui.QTextCursor.MoveOperation.Start)
|
||||
self.code_editor.find(str(text_to_be_found), flags)
|
||||
msgbox = QtWidgets.QMessageBox()
|
||||
msgbox.setWindowTitle(_('Find'))
|
||||
msgbox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/find32.png'))
|
||||
msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question)
|
||||
|
||||
msgbox.setText(_("End of document."))
|
||||
msgbox.setInformativeText('%s' % _("Start from beginning?"))
|
||||
bt_ok = msgbox.addButton(_('Ok'), QtWidgets.QMessageBox.ButtonRole.AcceptRole)
|
||||
bt_cancel = msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.RejectRole)
|
||||
|
||||
msgbox.setDefaultButton(bt_cancel)
|
||||
msgbox.exec()
|
||||
response = msgbox.clickedButton()
|
||||
|
||||
if response == bt_ok:
|
||||
self.code_editor.moveCursor(QtGui.QTextCursor.MoveOperation.Start)
|
||||
self.code_editor.find(str(text_to_be_found), flags)
|
||||
|
||||
def handleReplaceGCode(self):
|
||||
|
||||
|
||||
@@ -626,10 +626,13 @@ class IntEntry(FCLineEdit):
|
||||
|
||||
|
||||
class FCEntry(FCLineEdit):
|
||||
def __init__(self, decimals=None, alignment=None, border_color=None, parent=None):
|
||||
def __init__(self, decimals=None, alignment=None, border_color=None, parent=None, keep_focus=False):
|
||||
super(FCEntry, self).__init__(parent)
|
||||
self.readyToEdit = True
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
self._keep_focus = keep_focus
|
||||
if self._keep_focus is False:
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
|
||||
self.decimals = decimals if decimals is not None else 4
|
||||
|
||||
if border_color:
|
||||
@@ -644,6 +647,25 @@ class FCEntry(FCLineEdit):
|
||||
align_val = QtCore.Qt.AlignmentFlag.AlignLeft
|
||||
self.setAlignment(align_val)
|
||||
|
||||
@property
|
||||
def keep_focus(self):
|
||||
return self._keep_focus
|
||||
|
||||
@keep_focus.setter
|
||||
def keep_focus(self, val):
|
||||
self._keep_focus = val
|
||||
if val is True:
|
||||
try:
|
||||
self.editingFinished.disconnect(self.on_edit_finished)
|
||||
except (AttributeError, TypeError):
|
||||
pass
|
||||
self.editingFinished.connect(self.on_edit_finished)
|
||||
else:
|
||||
try:
|
||||
self.editingFinished.disconnect(self.on_edit_finished)
|
||||
except (AttributeError, TypeError):
|
||||
pass
|
||||
|
||||
def on_edit_finished(self):
|
||||
self.clearFocus()
|
||||
|
||||
|
||||
@@ -793,6 +793,9 @@ class CNCJobObject(FlatCAMObj, CNCjob):
|
||||
self.gcode_editor_tab.entryReplace.hide()
|
||||
self.gcode_editor_tab.code_editor.setReadOnly(True)
|
||||
|
||||
# make sure that the Find entry keeps the focus on the line
|
||||
self.gcode_editor_tab.entryFind.keep_focus = False
|
||||
|
||||
self.app.inform.emit('[success] %s...' % _('Loaded Machine Code into Code Editor'))
|
||||
|
||||
def on_update_source_file(self):
|
||||
|
||||
Reference in New Issue
Block a user