diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ce067a9..d9d3916d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,13 @@ CHANGELOG for FlatCAM beta ================================================= +18.07.2020 + +- added some icons in the Code Editor +- replaced some icons in the app +- in Code Editor, when changing text, the Save Code button will change color (text and icon) to red and after save it will revert the color to the default one +- in Code Editor some methods rework + 16.07.2020 - added a new method for GCode generation for Geometry objects diff --git a/appEditors/AppTextEditor.py b/appEditors/AppTextEditor.py index 69222671..e9726c98 100644 --- a/appEditors/AppTextEditor.py +++ b/appEditors/AppTextEditor.py @@ -72,13 +72,17 @@ class AppTextEditor(QtWidgets.QWidget): self.code_editor.setPlainText(text) self.buttonPreview = QtWidgets.QPushButton(_('Print Preview')) + self.buttonPreview.setIcon(QtGui.QIcon(self.app.resource_location + '/preview32.png')) self.buttonPreview.setToolTip(_("Open a OS standard Preview Print window.")) self.buttonPreview.setMinimumWidth(100) self.buttonPrint = QtWidgets.QPushButton(_('Print Code')) + self.buttonPrint.setIcon(QtGui.QIcon(self.app.resource_location + '/printer32.png')) self.buttonPrint.setToolTip(_("Open a OS standard Print window.")) + self.buttonPrint.setMinimumWidth(100) self.buttonFind = QtWidgets.QPushButton(_('Find in Code')) + self.buttonFind.setIcon(QtGui.QIcon(self.app.resource_location + '/find32.png')) self.buttonFind.setToolTip(_("Will search and highlight in yellow the string in the Find box.")) self.buttonFind.setMinimumWidth(100) @@ -86,6 +90,7 @@ class AppTextEditor(QtWidgets.QWidget): self.entryFind.setToolTip(_("Find box. Enter here the strings to be searched in the text.")) self.buttonReplace = QtWidgets.QPushButton(_('Replace With')) + self.buttonReplace.setIcon(QtGui.QIcon(self.app.resource_location + '/replace32.png')) self.buttonReplace.setToolTip(_("Will replace the string from the Find box with the one in the Replace box.")) self.buttonReplace.setMinimumWidth(100) @@ -97,17 +102,23 @@ class AppTextEditor(QtWidgets.QWidget): "with the text in the 'Replace' box..")) self.button_copy_all = QtWidgets.QPushButton(_('Copy All')) + self.button_copy_all.setIcon(QtGui.QIcon(self.app.resource_location + '/copy_file32.png')) self.button_copy_all.setToolTip(_("Will copy all the text in the Code Editor to the clipboard.")) self.button_copy_all.setMinimumWidth(100) self.buttonOpen = QtWidgets.QPushButton(_('Open Code')) + self.buttonOpen.setIcon(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png')) self.buttonOpen.setToolTip(_("Will open a text file in the editor.")) + self.buttonOpen.setMinimumWidth(100) self.buttonSave = QtWidgets.QPushButton(_('Save Code')) + self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) self.buttonSave.setToolTip(_("Will save the text in the editor into a file.")) + self.buttonSave.setMinimumWidth(100) self.buttonRun = QtWidgets.QPushButton(_('Run Code')) self.buttonRun.setToolTip(_("Will run the TCL commands found in the text file, one by one.")) + self.buttonRun.setMinimumWidth(100) self.buttonRun.hide() @@ -169,7 +180,26 @@ class AppTextEditor(QtWidgets.QWidget): # enable = not self.ui.code_editor.document().isEmpty() # self.ui.buttonPrint.setEnabled(enable) # self.ui.buttonPreview.setEnabled(enable) - pass + + self.buttonSave.setStyleSheet("QPushButton {color: red;}") + self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as_red.png')) + + def load_text(self, text, move_to_start=False, move_to_end=False, clear_text=True, as_html=False): + self.code_editor.textChanged.disconnect() + if clear_text: + # first clear previous text in text editor (if any) + self.code_editor.clear() + + self.code_editor.setReadOnly(False) + if as_html is False: + self.code_editor.setPlainText(text) + else: + self.code_editor.setHtml(text) + if move_to_start: + self.code_editor.moveCursor(QtGui.QTextCursor.Start) + elif move_to_end: + self.code_editor.moveCursor(QtGui.QTextCursor.End) + self.code_editor.textChanged.connect(self.handleTextChanged) def handleOpen(self, filt=None): self.app.defaults.report_usage("handleOpen()") @@ -268,6 +298,8 @@ class AppTextEditor(QtWidgets.QWidget): with open(filename, 'w') as f: for line in my_gcode: f.write(line) + self.buttonSave.setStyleSheet("") + self.buttonSave.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) except FileNotFoundError: self.app.inform.emit('[WARNING] %s' % _("No such file or directory")) return diff --git a/appGUI/ObjectUI.py b/appGUI/ObjectUI.py index bb0ff722..a823be15 100644 --- a/appGUI/ObjectUI.py +++ b/appGUI/ObjectUI.py @@ -2028,14 +2028,13 @@ class CNCObjectUI(ObjectUI): # GO Button self.export_gcode_button = QtWidgets.QPushButton(_('Save CNC Code')) + self.export_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) self.export_gcode_button.setToolTip( _("Opens dialog to save G-Code\n" "file.") ) - # h_lay.addWidget(self.modify_gcode_button) h_lay.addWidget(self.export_gcode_button) - # self.custom_box.addWidget(self.export_gcode_button) class ScriptObjectUI(ObjectUI): diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 34d36fbe..c434b056 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -579,10 +579,6 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.app.ui.position_label.setText("") self.app.ui.rel_position_label.setText("") - # first clear previous text in text editor (if any) - self.gcode_editor_tab.code_editor.clear() - self.gcode_editor_tab.code_editor.setReadOnly(False) - self.gcode_editor_tab.code_editor.completer_enable = False self.gcode_editor_tab.buttonRun.hide() @@ -592,20 +588,12 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.gcode_editor_tab.t_frame.hide() # then append the text from GCode to the text editor try: - self.gcode_editor_tab.code_editor.setPlainText(self.app.gcode_edited.getvalue()) - # for line in self.app.gcode_edited: - # QtWidgets.QApplication.processEvents() - # - # proc_line = str(line).strip('\n') - # self.gcode_editor_tab.code_editor.append(proc_line) + self.gcode_editor_tab.load_text(self.app.gcode_edited.getvalue(), move_to_start=True, clear_text=True) except Exception as e: log.debug('FlatCAMCNNJob.on_edit_code_click() -->%s' % str(e)) self.app.inform.emit('[ERROR] %s %s' % ('FlatCAMCNNJob.on_edit_code_click() -->', str(e))) return - self.gcode_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.Start) - - self.gcode_editor_tab.handleTextChanged() self.gcode_editor_tab.t_frame.show() self.app.proc_container.view.set_idle() diff --git a/appObjects/FlatCAMDocument.py b/appObjects/FlatCAMDocument.py index e278e9c3..2ff84a98 100644 --- a/appObjects/FlatCAMDocument.py +++ b/appObjects/FlatCAMDocument.py @@ -84,10 +84,6 @@ class DocumentObject(FlatCAMObj): self.document_editor_tab.code_editor.setStyleSheet(stylesheet) - # first clear previous text in text editor (if any) - self.document_editor_tab.code_editor.clear() - self.document_editor_tab.code_editor.setReadOnly(self._read_only) - self.document_editor_tab.buttonRun.hide() self.ui.autocomplete_cb.set_value(self.app.defaults['document_autocompleter']) @@ -138,14 +134,16 @@ class DocumentObject(FlatCAMObj): self.ui.font_size_cb.setCurrentIndex(int(self.app.defaults['document_font_size'])) - self.document_editor_tab.handleTextChanged() + # self.document_editor_tab.handleTextChanged() self.ser_attrs = ['options', 'kind', 'source_file'] if Qt.mightBeRichText(self.source_file): - self.document_editor_tab.code_editor.setHtml(self.source_file) + # self.document_editor_tab.code_editor.setHtml(self.source_file) + self.document_editor_tab.load_text(self.source_file, move_to_start=True, clear_text=True, as_html=True) else: - for line in self.source_file.splitlines(): - self.document_editor_tab.code_editor.append(line) + # for line in self.source_file.splitlines(): + # self.document_editor_tab.code_editor.append(line) + self.document_editor_tab.load_text(self.source_file, move_to_start=True, clear_text=True, as_html=False) self.build_ui() diff --git a/appObjects/FlatCAMScript.py b/appObjects/FlatCAMScript.py index cb0afbd6..1eb4b8ac 100644 --- a/appObjects/FlatCAMScript.py +++ b/appObjects/FlatCAMScript.py @@ -135,14 +135,11 @@ class ScriptObject(FlatCAMObj): self.script_editor_tab.t_frame.hide() try: - self.script_editor_tab.code_editor.setPlainText(self.source_file) - # for line in self.source_file.splitlines(): - # QtWidgets.QApplication.processEvents() - # self.script_editor_tab.code_editor.append(line) + # self.script_editor_tab.code_editor.setPlainText(self.source_file) + self.script_editor_tab.load_text(self.source_file, move_to_end=True) except Exception as e: log.debug("ScriptObject.set_ui() --> %s" % str(e)) - self.script_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.End) self.script_editor_tab.t_frame.show() self.app.proc_container.view.set_idle() diff --git a/appTools/ToolCalibration.py b/appTools/ToolCalibration.py index 3bece057..a868d48e 100644 --- a/appTools/ToolCalibration.py +++ b/appTools/ToolCalibration.py @@ -1072,10 +1072,6 @@ class ToolCalibration(AppTool): self.app.ui.position_label.setText("") self.app.ui.rel_position_label.setText("") - # first clear previous text in text editor (if any) - self.gcode_editor_tab.code_editor.clear() - self.gcode_editor_tab.code_editor.setReadOnly(False) - self.gcode_editor_tab.code_editor.completer_enable = False self.gcode_editor_tab.buttonRun.hide() @@ -1085,13 +1081,11 @@ class ToolCalibration(AppTool): self.gcode_editor_tab.t_frame.hide() # then append the text from GCode to the text editor try: - self.gcode_editor_tab.code_editor.setPlainText(gcode) + self.gcode_editor_tab.load_text(gcode, move_to_start=True, clear_text=True) except Exception as e: self.app.inform.emit('[ERROR] %s %s' % ('ERROR -->', str(e))) return - self.gcode_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.Start) - self.gcode_editor_tab.t_frame.show() self.app.proc_container.view.set_idle() diff --git a/appTools/ToolIsolation.py b/appTools/ToolIsolation.py index b49c00ea..1ca9ae49 100644 --- a/appTools/ToolIsolation.py +++ b/appTools/ToolIsolation.py @@ -3269,7 +3269,8 @@ class IsoUI: separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) self.grid3.addWidget(separator_line, 39, 0, 1, 2) - self.generate_iso_button = QtWidgets.QPushButton("%s" % _("Generate Isolation Geometry")) + self.generate_iso_button = QtWidgets.QPushButton("%s" % _("Generate Geometry")) + self.generate_iso_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png')) self.generate_iso_button.setStyleSheet(""" QPushButton { diff --git a/appTools/ToolNCC.py b/appTools/ToolNCC.py index abe1748a..1b13aa41 100644 --- a/appTools/ToolNCC.py +++ b/appTools/ToolNCC.py @@ -4214,6 +4214,7 @@ class NccUI: self.grid3.addWidget(separator_line, 32, 0, 1, 2) self.generate_ncc_button = QtWidgets.QPushButton(_('Generate Geometry')) + self.generate_ncc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png')) self.generate_ncc_button.setToolTip( _("Create the Geometry Object\n" "for non-copper routing.") diff --git a/appTools/ToolPaint.py b/appTools/ToolPaint.py index a3c5d991..5f420bce 100644 --- a/appTools/ToolPaint.py +++ b/appTools/ToolPaint.py @@ -3241,6 +3241,7 @@ class PaintUI: # GO Button self.generate_paint_button = QtWidgets.QPushButton(_('Generate Geometry')) + self.generate_paint_button.setIcon(QtGui.QIcon(self.app.resource_location + '/geometry32.png')) self.generate_paint_button.setToolTip( _("Create a Geometry Object which paints the polygons.") ) diff --git a/appTools/ToolSolderPaste.py b/appTools/ToolSolderPaste.py index f226205c..e0565ba7 100644 --- a/appTools/ToolSolderPaste.py +++ b/appTools/ToolSolderPaste.py @@ -1019,19 +1019,15 @@ class SolderPaste(AppTool): return try: - for line in lines: - proc_line = str(line).strip('\n') - self.text_editor_tab.code_editor.append(proc_line) + # for line in lines: + # proc_line = str(line).strip('\n') + # self.text_editor_tab.code_editor.append(proc_line) + self.text_editor_tab.load_text(lines, move_to_start=True) except Exception as e: log.debug('ToolSolderPaste.on_view_gcode() -->%s' % str(e)) self.app.inform.emit('[ERROR] %s --> %s' % ('ToolSolderPaste.on_view_gcode()', str(e))) return - self.text_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.Start) - - self.text_editor_tab.handleTextChanged() - # self.app.ui.show() - def on_save_gcode(self): """ Save solderpaste dispensing GCode to a file on HDD. diff --git a/app_Main.py b/app_Main.py index bf717936..086320df 100644 --- a/app_Main.py +++ b/app_Main.py @@ -7668,9 +7668,6 @@ class App(QtCore.QObject): self.ui.coords_toolbar.hide() self.ui.delta_coords_toolbar.hide() - # first clear previous text in text editor (if any) - self.text_editor_tab.code_editor.clear() - self.text_editor_tab.code_editor.setReadOnly(False) self.toggle_codeeditor = True self.text_editor_tab.code_editor.completer_enable = False self.text_editor_tab.buttonRun.hide() @@ -7722,10 +7719,6 @@ class App(QtCore.QObject): self.ui.coords_toolbar.hide() self.ui.delta_coords_toolbar.hide() - # first clear previous text in text editor (if any) - self.source_editor_tab.code_editor.clear() - self.source_editor_tab.code_editor.setReadOnly(False) - self.source_editor_tab.code_editor.completer_enable = False self.source_editor_tab.buttonRun.hide() @@ -7767,20 +7760,13 @@ class App(QtCore.QObject): self.source_editor_tab.t_frame.hide() try: - self.source_editor_tab.code_editor.setPlainText(file.getvalue()) - # for line in file: - # QtWidgets.QApplication.processEvents() - # proc_line = str(line).strip('\n') - # self.source_editor_tab.code_editor.append(proc_line) + self.source_editor_tab.load_text(file.getvalue(), clear_text=True, move_to_start=True) except Exception as e: log.debug('App.on_view_source() -->%s' % str(e)) self.inform.emit('[ERROR] %s: %s' % (_('Failed to load the source code for the selected object'), str(e))) return - self.source_editor_tab.handleTextChanged() self.source_editor_tab.t_frame.show() - - self.source_editor_tab.code_editor.moveCursor(QtGui.QTextCursor.Start) self.proc_container.view.set_idle() # self.ui.show() @@ -9205,7 +9191,7 @@ class App(QtCore.QObject): if f.open(QtCore.QIODevice.ReadOnly): stream = QtCore.QTextStream(f) code_edited = stream.readAll() - self.text_editor_tab.code_editor.setPlainText(code_edited) + self.text_editor_tab.load_text(code_edited, clear_text=True, move_to_start=True) f.close() except IOError: App.log.error("Failed to open config file: %s" % filename) diff --git a/assets/resources/dark_resources/find32.png b/assets/resources/dark_resources/find32.png new file mode 100644 index 00000000..e58a3ee4 Binary files /dev/null and b/assets/resources/dark_resources/find32.png differ diff --git a/assets/resources/dark_resources/geometry16.png b/assets/resources/dark_resources/geometry16.png index 14bdbe82..18e744e3 100644 Binary files a/assets/resources/dark_resources/geometry16.png and b/assets/resources/dark_resources/geometry16.png differ diff --git a/assets/resources/dark_resources/geometry32.png b/assets/resources/dark_resources/geometry32.png index 647bf48e..cb093430 100644 Binary files a/assets/resources/dark_resources/geometry32.png and b/assets/resources/dark_resources/geometry32.png differ diff --git a/assets/resources/dark_resources/preview32.png b/assets/resources/dark_resources/preview32.png new file mode 100644 index 00000000..27b6bcd4 Binary files /dev/null and b/assets/resources/dark_resources/preview32.png differ diff --git a/assets/resources/dark_resources/printer16.png b/assets/resources/dark_resources/printer16.png index e93dcc88..7a5a2b9a 100644 Binary files a/assets/resources/dark_resources/printer16.png and b/assets/resources/dark_resources/printer16.png differ diff --git a/assets/resources/dark_resources/printer32.png b/assets/resources/dark_resources/printer32.png index b72a7695..183bec8e 100644 Binary files a/assets/resources/dark_resources/printer32.png and b/assets/resources/dark_resources/printer32.png differ diff --git a/assets/resources/dark_resources/replace32.png b/assets/resources/dark_resources/replace32.png new file mode 100644 index 00000000..803cd7c3 Binary files /dev/null and b/assets/resources/dark_resources/replace32.png differ diff --git a/assets/resources/dark_resources/save_as.png b/assets/resources/dark_resources/save_as.png index 2d3ae02b..1b209539 100644 Binary files a/assets/resources/dark_resources/save_as.png and b/assets/resources/dark_resources/save_as.png differ diff --git a/assets/resources/find32.png b/assets/resources/find32.png new file mode 100644 index 00000000..4869bfbd Binary files /dev/null and b/assets/resources/find32.png differ diff --git a/assets/resources/geometry16.png b/assets/resources/geometry16.png index ceb53909..38ad8ea2 100644 Binary files a/assets/resources/geometry16.png and b/assets/resources/geometry16.png differ diff --git a/assets/resources/geometry32.png b/assets/resources/geometry32.png index 1cb534df..0915772b 100644 Binary files a/assets/resources/geometry32.png and b/assets/resources/geometry32.png differ diff --git a/assets/resources/preview32.png b/assets/resources/preview32.png new file mode 100644 index 00000000..0f98ddb6 Binary files /dev/null and b/assets/resources/preview32.png differ diff --git a/assets/resources/printer16.png b/assets/resources/printer16.png index 1b98d2fb..2277b0ad 100644 Binary files a/assets/resources/printer16.png and b/assets/resources/printer16.png differ diff --git a/assets/resources/printer32.png b/assets/resources/printer32.png index c6f314e5..3c4a942e 100644 Binary files a/assets/resources/printer32.png and b/assets/resources/printer32.png differ diff --git a/assets/resources/replace32.png b/assets/resources/replace32.png new file mode 100644 index 00000000..60d8870e Binary files /dev/null and b/assets/resources/replace32.png differ diff --git a/assets/resources/save_as.png b/assets/resources/save_as.png index a8aa51c7..d80ebcf9 100644 Binary files a/assets/resources/save_as.png and b/assets/resources/save_as.png differ diff --git a/assets/resources/save_as_red.png b/assets/resources/save_as_red.png new file mode 100644 index 00000000..50155428 Binary files /dev/null and b/assets/resources/save_as_red.png differ