From 1af4ec047433e9c2313836651f24a49c7405ca7e Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 25 Nov 2020 02:56:10 +0200 Subject: [PATCH] - changed how the Editor toolbar button works; added a background for the 'Exit Editor' toolbar button when in Editor --- CHANGELOG.md | 1 + appEditors/AppExcEditor.py | 6 +++-- appEditors/AppGeoEditor.py | 6 +++-- appEditors/AppGerberEditor.py | 6 +++-- appGUI/MainGUI.py | 43 +++++++++++++++++++++++++++-------- app_Main.py | 15 ++++++------ 6 files changed, 53 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 033eef83..fe249f03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ CHANGELOG for FlatCAM beta - added a way to keep compatibility with old projects - some small fixes in the Geo Editor such that the Tool Tab is no longer shown on Editor Exit if it was used by an Editor sub-tool - removed the Notebook hide action when using the Esc key in the Geometry Editor +- changed how the Editor toolbar button works; added a background for the 'Exit Editor' toolbar button when in Editor 21.11.2020 diff --git a/appEditors/AppExcEditor.py b/appEditors/AppExcEditor.py index 627dc2aa..54e006a5 100644 --- a/appEditors/AppExcEditor.py +++ b/appEditors/AppExcEditor.py @@ -2493,7 +2493,8 @@ class AppExcEditor(QtCore.QObject): self.app.ui.exc_editor_menu.setDisabled(False) self.app.ui.exc_editor_menu.menuAction().setVisible(True) - self.app.ui.update_obj_btn.setEnabled(True) + self.app.ui.editor_exit_btn_ret_action.setVisible(True) + self.app.ui.editor_start_btn.setVisible(False) self.app.ui.e_editor_cmenu.setEnabled(True) self.app.ui.exc_edit_toolbar.setDisabled(False) @@ -2546,7 +2547,8 @@ class AppExcEditor(QtCore.QObject): self.app.ui.exc_editor_menu.setDisabled(True) self.app.ui.exc_editor_menu.menuAction().setVisible(False) - self.app.ui.update_obj_btn.setEnabled(False) + self.app.ui.editor_exit_btn_ret_action.setVisible(False) + self.app.ui.editor_start_btn.setVisible(True) self.app.ui.popmenu_disable.setVisible(True) self.app.ui.cmenu_newmenu.menuAction().setVisible(True) diff --git a/appEditors/AppGeoEditor.py b/appEditors/AppGeoEditor.py index 2e81afa0..edd961c2 100644 --- a/appEditors/AppGeoEditor.py +++ b/appEditors/AppGeoEditor.py @@ -3726,7 +3726,8 @@ class AppGeoEditor(QtCore.QObject): self.app.ui.geo_editor_menu.setDisabled(False) self.app.ui.geo_editor_menu.menuAction().setVisible(True) - self.app.ui.update_obj_btn.setEnabled(True) + self.app.ui.editor_exit_btn_ret_action.setVisible(True) + self.app.ui.editor_start_btn.setVisible(False) self.app.ui.g_editor_cmenu.setEnabled(True) self.app.ui.geo_edit_toolbar.setDisabled(False) @@ -3787,7 +3788,8 @@ class AppGeoEditor(QtCore.QObject): self.app.ui.geo_editor_menu.setDisabled(True) self.app.ui.geo_editor_menu.menuAction().setVisible(False) - self.app.ui.update_obj_btn.setEnabled(False) + self.app.ui.editor_exit_btn_ret_action.setVisible(False) + self.app.ui.editor_start_btn.setVisible(True) self.app.ui.g_editor_cmenu.setEnabled(False) self.app.ui.e_editor_cmenu.setEnabled(False) diff --git a/appEditors/AppGerberEditor.py b/appEditors/AppGerberEditor.py index 210038b8..5c3f35aa 100644 --- a/appEditors/AppGerberEditor.py +++ b/appEditors/AppGerberEditor.py @@ -3570,7 +3570,8 @@ class AppGerberEditor(QtCore.QObject): self.app.ui.grb_editor_menu.setDisabled(False) self.app.ui.grb_editor_menu.menuAction().setVisible(True) - self.app.ui.update_obj_btn.setEnabled(True) + self.app.ui.editor_exit_btn_ret_action.setVisible(True) + self.app.ui.editor_start_btn.setVisible(False) self.app.ui.grb_editor_cmenu.setEnabled(True) self.app.ui.grb_edit_toolbar.setDisabled(False) @@ -3623,7 +3624,8 @@ class AppGerberEditor(QtCore.QObject): self.app.ui.grb_editor_menu.setDisabled(True) self.app.ui.grb_editor_menu.menuAction().setVisible(False) - self.app.ui.update_obj_btn.setEnabled(False) + self.app.ui.editor_exit_btn_ret_action.setVisible(False) + self.app.ui.editor_start_btn.setVisible(True) # adjust the visibility of some of the canvas context menu self.app.ui.popmenu_edit.setVisible(True) diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index e8d77f14..bbc48434 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -49,6 +49,7 @@ class MainGUI(QtWidgets.QMainWindow): geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate') final_save = QtCore.pyqtSignal(name='saveBeforeExit') + # https://www.w3.org/TR/SVG11/types.html#ColorKeywords def __init__(self, app): super(MainGUI, self).__init__() @@ -982,11 +983,22 @@ class MainGUI(QtWidgets.QMainWindow): # ######################################################################## # ########################## Edit Toolbar# ############################### # ######################################################################## - self.editgeo_btn = self.toolbaredit.addAction( + self.editor_start_btn = self.toolbaredit.addAction( QtGui.QIcon(self.app.resource_location + '/edit_file32.png'), _("Editor")) - self.update_obj_btn = self.toolbaredit.addAction( - QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'), _("Save Object and close the Editor") - ) + self.editor_exit_btn = QtWidgets.QToolButton() + + # https://www.w3.org/TR/SVG11/types.html#ColorKeywords + self.editor_exit_btn.setStyleSheet(""" + QToolButton + { + color: black; + background-color: tomato; + } + """) + self.editor_exit_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png')) + self.editor_exit_btn.setToolTip(_("Exit from Editor.")) + # in order to hide it we hide the returned action + self.editor_exit_btn_ret_action = self.toolbaredit.addWidget(self.editor_exit_btn) self.toolbaredit.addSeparator() self.copy_btn = self.toolbaredit.addAction( @@ -1787,7 +1799,8 @@ class MainGUI(QtWidgets.QMainWindow): # ######################################################################## self.grid_snap_btn.setCheckable(True) self.corner_snap_btn.setCheckable(True) - self.update_obj_btn.setEnabled(False) + self.editor_exit_btn_ret_action.setVisible(False) + # start with GRID activated self.grid_snap_btn.trigger() @@ -2170,12 +2183,22 @@ class MainGUI(QtWidgets.QMainWindow): # ######################################################################## # ######################### Edit Toolbar ################################# # ######################################################################## - self.editgeo_btn = self.toolbaredit.addAction( + self.editor_start_btn = self.toolbaredit.addAction( QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor")) - self.update_obj_btn = self.toolbaredit.addAction( - QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'), - _("Save Object and close the Editor") - ) + self.editor_exit_btn = QtWidgets.QToolButton() + + # https://www.w3.org/TR/SVG11/types.html#ColorKeywords + self.editor_exit_btn.setStyleSheet(""" + QToolButton + { + color: black; + background-color: tomato; + } + """) + self.editor_exit_btn.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png')) + self.editor_exit_btn.setToolTip(_("Exit from Editor.")) + # in order to hide it we hide the returned action + self.editor_exit_btn_ret_action = self.toolbaredit.addWidget(self.editor_exit_btn) self.toolbaredit.addSeparator() self.copy_btn = self.toolbaredit.addAction( diff --git a/app_Main.py b/app_Main.py index f577593e..c0f5f444 100644 --- a/app_Main.py +++ b/app_Main.py @@ -2225,8 +2225,8 @@ class App(QtCore.QObject): self.ui.zoom_out_btn.triggered.connect(lambda: self.plotcanvas.zoom(1.5)) # Edit Toolbar Signals - self.ui.editgeo_btn.triggered.connect(self.object2editor) - self.ui.update_obj_btn.triggered.connect(lambda: self.editor2object()) + self.ui.editor_start_btn.triggered.connect(self.object2editor) + self.ui.editor_exit_btn.clicked.connect(lambda: self.editor2object()) self.ui.copy_btn.triggered.connect(self.on_copy_command) self.ui.delete_btn.triggered.connect(self.on_delete) @@ -2411,15 +2411,14 @@ class App(QtCore.QObject): edited_object = self.collection.get_active() - if isinstance(edited_object, GerberObject) or isinstance(edited_object, GeometryObject) or \ - isinstance(edited_object, ExcellonObject) or isinstance(edited_object, CNCJobObject): + if edited_object and edited_object.kind in ['cncjob', 'excellon', 'geometry', 'gerber']: pass else: self.inform.emit('[WARNING_NOTCL] %s' % _("Select a Geometry, Gerber, Excellon or CNCJob Object to edit.")) self.ui.menuobjects.setDisabled(False) return - if isinstance(edited_object, GeometryObject): + if edited_object.kind == 'geometry': # store the Geometry Editor Toolbar visibility before entering in the Editor self.geo_editor.toolbar_old_state = True if self.ui.geo_edit_toolbar.isVisible() else False @@ -2462,7 +2461,7 @@ class App(QtCore.QObject): # set call source to the Editor we go into self.call_source = 'geo_editor' - elif isinstance(edited_object, ExcellonObject): + elif edited_object.kind == 'excellon': # store the Excellon Editor Toolbar visibility before entering in the Editor self.exc_editor.toolbar_old_state = True if self.ui.exc_edit_toolbar.isVisible() else False @@ -2473,7 +2472,7 @@ class App(QtCore.QObject): # set call source to the Editor we go into self.call_source = 'exc_editor' - elif isinstance(edited_object, GerberObject): + elif edited_object.kind == 'gerber': # store the Gerber Editor Toolbar visibility before entering in the Editor self.grb_editor.toolbar_old_state = True if self.ui.grb_edit_toolbar.isVisible() else False @@ -2487,7 +2486,7 @@ class App(QtCore.QObject): # reset the following variables so the UI is built again after edit edited_object.ui_build = False - elif isinstance(edited_object, CNCJobObject): + elif edited_object.kind == 'cncjob': if self.ui.splitter.sizes()[0] == 0: self.ui.splitter.setSizes([1, 1])