From eb28d28ea2838d264ec303078d6c3ee3b6ccd711 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 3 Aug 2020 23:20:41 +0300 Subject: [PATCH] - GCode Editor - modified the UI --- CHANGELOG.md | 1 + appEditors/appGCodeEditor.py | 40 +++++++++++++++++------------------- appGUI/ObjectUI.py | 21 ++++++++++--------- appObjects/FlatCAMCNCJob.py | 7 +++++-- 4 files changed, 36 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96dd8a64..9f697a2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ CHANGELOG for FlatCAM beta - GCode Editor - GCode tool selection when clicking on tool in Tools table is working. The only issue is that the first tool gcode includes the start gcode which confuse the algorithm - GCode Editor - can not delete objects while in the Editor; can not close the Code Editor Tab except on Editor exit; activated the shortcut keys (for now only CTRL+S is working) - added a way to remember the old state of Tools toolbar before and after entering an Editor +- GCode Editor - modified the UI 2.08.2020 diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index d61ebbef..18d49084 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -709,50 +709,48 @@ class AppGCodeEditorUI: self.edit_box.addWidget(separator_line) # Prepend text to GCode - prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to CNC Code')) + prependlabel = QtWidgets.QLabel('%s 1:' % _('CNC Code Snippet')) prependlabel.setToolTip( - _("Type here any G-Code commands you would\n" - "like to add at the beginning of the G-Code file.") + _("Code snippet defined in Preferences.") ) self.edit_box.addWidget(prependlabel) self.prepend_text = FCTextArea() self.prepend_text.setPlaceholderText( _("Type here any G-Code commands you would\n" - "like to add at the beginning of the G-Code file.") + "like to insert at the cursor location.") ) self.edit_box.addWidget(self.prepend_text) + # Insert Button + self.update_gcode_button = FCButton(_('Insert Code')) + # self.update_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) + self.update_gcode_button.setToolTip( + _("Insert the code above at the cursor location.") + ) + self.edit_box.addWidget(self.update_gcode_button) + # Append text to GCode - appendlabel = QtWidgets.QLabel('%s:' % _('Append to CNC Code')) + appendlabel = QtWidgets.QLabel('%s 2:' % _('CNC Code Snippet')) appendlabel.setToolTip( - _("Type here any G-Code commands you would\n" - "like to append to the generated file.\n" - "I.e.: M2 (End of program)") + _("Code snippet defined in Preferences.") ) self.edit_box.addWidget(appendlabel) self.append_text = FCTextArea() self.append_text.setPlaceholderText( _("Type here any G-Code commands you would\n" - "like to append to the generated file.\n" - "I.e.: M2 (End of program)") + "like to insert at the cursor location.") ) self.edit_box.addWidget(self.append_text) - h_lay = QtWidgets.QHBoxLayout() - h_lay.setAlignment(QtCore.Qt.AlignVCenter) - self.edit_box.addLayout(h_lay) - - # GO Button - self.update_gcode_button = FCButton(_('Update Code')) + # Insert Button + self.update_gcode_sec_button = FCButton(_('Insert Code')) # self.update_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) - self.update_gcode_button.setToolTip( - _("Update the Gcode in the Editor with the values\n" - "in the 'Prepend' and 'Append' text boxes.") + self.update_gcode_sec_button.setToolTip( + _("Insert the code above at the cursor location.") ) - - h_lay.addWidget(self.update_gcode_button) + self.edit_box.addWidget(self.update_gcode_sec_button) layout.addStretch() diff --git a/appGUI/ObjectUI.py b/appGUI/ObjectUI.py index 9e1ef56f..e3d75372 100644 --- a/appGUI/ObjectUI.py +++ b/appGUI/ObjectUI.py @@ -2025,16 +2025,16 @@ class CNCObjectUI(ObjectUI): # self.toolch_ois = OptionalInputSection(self.toolchange_cb, # [self.toolchangelabel, self.toolchange_text, self.tc_variable_combo]) # - h_lay = QtWidgets.QHBoxLayout() - h_lay.setAlignment(QtCore.Qt.AlignVCenter) - self.custom_box.addLayout(h_lay) + # h_lay = QtWidgets.QHBoxLayout() + # h_lay.setAlignment(QtCore.Qt.AlignVCenter) + # self.custom_box.addLayout(h_lay) - # # Edit GCode Button - # self.modify_gcode_button = QtWidgets.QPushButton(_('View CNC Code')) - # self.modify_gcode_button.setToolTip( - # _("Opens TAB to view/modify/print G-Code\n" - # "file.") - # ) + # Review GCode Button + self.review_gcode_button = QtWidgets.QPushButton(_('Review')) + self.review_gcode_button.setToolTip( + _("Review CNC Code.") + ) + self.custom_box.addWidget(self.review_gcode_button) # Save Button self.export_gcode_button = QtWidgets.QPushButton(_('Save CNC Code')) @@ -2044,7 +2044,8 @@ class CNCObjectUI(ObjectUI): "file.") ) - h_lay.addWidget(self.export_gcode_button) + self.custom_box.addWidget(self.export_gcode_button) + self.custom_box.addStretch() class ScriptObjectUI(ObjectUI): diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 9ddbcfbd..776f8aaf 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -451,7 +451,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click) self.ui.export_gcode_button.clicked.connect(self.on_exportgcode_button_click) - self.ui.editor_button.clicked.connect(self.on_edit_code_click) + self.ui.review_gcode_button.clicked.connect(self.on_edit_code_click) + self.ui.editor_button.clicked.connect(lambda: self.app.object2editor()) # self.ui.tc_variable_combo.currentIndexChanged[str].connect(self.on_cnc_custom_parameters) @@ -623,7 +624,9 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.gcode_editor_tab.t_frame.show() self.app.proc_container.view.set_idle() - self.gcode_editor_tab.buttonSave.clicked.connect(self.on_update_source_file) + self.gcode_editor_tab.buttonSave.hide() + self.gcode_editor_tab.buttonOpen.hide() + self.gcode_editor_tab.code_editor.setReadOnly(True) self.app.inform.emit('[success] %s...' % _('Loaded Machine Code into Code Editor'))