From cf7c6dc9c298244576ce932631294e362af90a09 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Fri, 27 Nov 2020 17:00:12 +0200 Subject: [PATCH] - some refactoring between app_Main class and MainGUI class - on tab close in Notebook the tool_shapes are deleted (shape markings used by some of the App Tools) therefore part fo the clean-up --- CHANGELOG.md | 2 ++ appGUI/MainGUI.py | 62 +++++++++++++++++++++++++++++++++++------------ app_Main.py | 43 ++++++++------------------------ 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20a9cb9d..d76b1253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ CHANGELOG for FlatCAM beta - in Geometry Object Properties UI - added the UI for Utilities and within Utilities added the Simplification UI - in Geometry Object Properties UI - finished the new feature Simplification and Vertex Points calculation which should greatly reduce the resulting GCode size - in Tool Isolation, for Polygon Selection method, added ability to select all/clear all polygons allowing thus negative selection (select all followed by deselection of the polygons you don't want isolated, e.g a ground plane) +- some refactoring between app_Main class and MainGUI class +- on tab close in Notebook the tool_shapes are deleted (shape markings used by some of the App Tools) therefore part fo the clean-up 26.11.2020 diff --git a/appGUI/MainGUI.py b/appGUI/MainGUI.py index 150a3035..375c65c2 100644 --- a/appGUI/MainGUI.py +++ b/appGUI/MainGUI.py @@ -2796,7 +2796,7 @@ class MainGUI(QtWidgets.QMainWindow): # Show shortcut list if key == QtCore.Qt.Key_F3 or key == 'F3': - self.app.on_shortcut_list() + self.on_shortcut_list() # Open Video Help if key == QtCore.Qt.Key_F4 or key == 'F4': @@ -2808,15 +2808,15 @@ class MainGUI(QtWidgets.QMainWindow): # Switch to Project Tab if key == QtCore.Qt.Key_1: - self.app.on_select_tab('project') + self.on_select_tab('project') # Switch to Selected Tab if key == QtCore.Qt.Key_2: - self.app.on_select_tab('properties') + self.on_select_tab('properties') # Switch to Tool Tab if key == QtCore.Qt.Key_3: - self.app.on_select_tab('tool') + self.on_select_tab('tool') # Delete from PyQt # It's meant to make a difference between delete objects and delete tools in @@ -3115,15 +3115,15 @@ class MainGUI(QtWidgets.QMainWindow): # Switch to Project Tab if key == QtCore.Qt.Key_1 or key == '1': - self.app.on_select_tab('project') + self.on_select_tab('project') # Switch to Selected Tab if key == QtCore.Qt.Key_2 or key == '2': - self.app.on_select_tab('selected') + self.on_select_tab('selected') # Switch to Tool Tab if key == QtCore.Qt.Key_3 or key == '3': - self.app.on_select_tab('tool') + self.on_select_tab('tool') # Grid Snap if key == QtCore.Qt.Key_G or key == 'G': @@ -3260,7 +3260,7 @@ class MainGUI(QtWidgets.QMainWindow): # Show Shortcut list if key == 'F3': - self.app.on_shortcut_list() + self.on_shortcut_list() elif self.app.call_source == 'grb_editor': # CTRL if modifiers == QtCore.Qt.ControlModifier: @@ -3350,19 +3350,19 @@ class MainGUI(QtWidgets.QMainWindow): # Switch to Project Tab if key == QtCore.Qt.Key_1 or key == '1': self.app.grb_editor.launched_from_shortcuts = True - self.app.on_select_tab('project') + self.on_select_tab('project') return # Switch to Selected Tab if key == QtCore.Qt.Key_2 or key == '2': self.app.grb_editor.launched_from_shortcuts = True - self.app.on_select_tab('selected') + self.on_select_tab('selected') return # Switch to Tool Tab if key == QtCore.Qt.Key_3 or key == '3': self.app.grb_editor.launched_from_shortcuts = True - self.app.on_select_tab('tool') + self.on_select_tab('tool') return # we do this so we can reuse the following keys while inside a Tool @@ -3493,7 +3493,7 @@ class MainGUI(QtWidgets.QMainWindow): # Show Shortcut list if key == QtCore.Qt.Key_F3 or key == 'F3': - self.app.on_shortcut_list() + self.on_shortcut_list() return elif self.app.call_source == 'exc_editor': # CTRL @@ -3573,19 +3573,19 @@ class MainGUI(QtWidgets.QMainWindow): # Switch to Project Tab if key == QtCore.Qt.Key_1 or key == '1': self.app.exc_editor.launched_from_shortcuts = True - self.app.on_select_tab('project') + self.on_select_tab('project') return # Switch to Selected Tab if key == QtCore.Qt.Key_2 or key == '2': self.app.exc_editor.launched_from_shortcuts = True - self.app.on_select_tab('selected') + self.on_select_tab('selected') return # Switch to Tool Tab if key == QtCore.Qt.Key_3 or key == '3': self.app.exc_editor.launched_from_shortcuts = True - self.app.on_select_tab('tool') + self.on_select_tab('tool') return # Grid Snap @@ -3625,7 +3625,7 @@ class MainGUI(QtWidgets.QMainWindow): # Show Shortcut list if key == QtCore.Qt.Key_F3 or key == 'F3': - self.app.on_shortcut_list() + self.on_shortcut_list() return # Propagate to tool @@ -3842,6 +3842,36 @@ class MainGUI(QtWidgets.QMainWindow): if key == QtCore.Qt.Key_J or key == 'J': self.app.on_jump_to() + def on_shortcut_list(self): + # add the tab if it was closed + self.plot_tab_area.addTab(self.shortcuts_tab, _("Key Shortcut List")) + + # delete the absolute and relative position and messages in the infobar + # self.ui.position_label.setText("") + # self.ui.rel_position_label.setText("") + # hide coordinates toolbars in the infobar while in DB + self.coords_toolbar.hide() + self.delta_coords_toolbar.hide() + + # Switch plot_area to preferences page + self.plot_tab_area.setCurrentWidget(self.shortcuts_tab) + # self.show() + + def on_select_tab(self, name): + # if the splitter is hidden, display it, else hide it but only if the current widget is the same + if self.splitter.sizes()[0] == 0: + self.splitter.setSizes([1, 1]) + else: + if self.notebook.currentWidget().objectName() == name + '_tab': + self.splitter.setSizes([0, 1]) + + if name == 'project': + self.notebook.setCurrentWidget(self.project_tab) + elif name == 'properties': + self.notebook.setCurrentWidget(self.properties_tab) + elif name == 'tool': + self.notebook.setCurrentWidget(self.tool_tab) + def createPopupMenu(self): menu = super().createPopupMenu() diff --git a/app_Main.py b/app_Main.py index 9496ae80..e8787ad8 100644 --- a/app_Main.py +++ b/app_Main.py @@ -1426,6 +1426,8 @@ class App(QtCore.QObject): # Notebook tab clicking self.ui.notebook.tabBarClicked.connect(self.on_properties_tab_click) + self.ui.notebook.callback_on_close = self.on_close_notebook_tab + # ########################################################################################################### # #################################### GUI PREFERENCES SIGNALS ############################################## # ########################################################################################################### @@ -2134,7 +2136,7 @@ class App(QtCore.QObject): self.ui.menuhelp_exc_spec.triggered.connect(lambda: webbrowser.open(self.excellon_spec_url)) self.ui.menuhelp_gerber_spec.triggered.connect(lambda: webbrowser.open(self.gerber_spec_url)) self.ui.menuhelp_videohelp.triggered.connect(lambda: webbrowser.open(self.video_url)) - self.ui.menuhelp_shortcut_list.triggered.connect(self.on_shortcut_list) + self.ui.menuhelp_shortcut_list.triggered.connect(self.ui.on_shortcut_list) def connect_project_context_signals(self): self.ui.menuprojectenable.triggered.connect(self.on_enable_sel_plots) @@ -2783,6 +2785,9 @@ class App(QtCore.QObject): self.ui.plot_tab_area.setTabText(0, _("Plot Area")) self.ui.plot_tab_area.protectTab(0) + # restore the notebook tab close method to the app + self.ui.notebook.callback_on_close = self.on_close_notebook_tab + # make sure that we reenable the selection on Project Tab after returning from Editor Mode: self.ui.project_frame.setDisabled(False) @@ -4820,6 +4825,8 @@ class App(QtCore.QObject): obj_active.mark_shapes_storage.clear() obj_active.mark_shapes.clear(update=True) obj_active.mark_shapes.enabled = False + self.tool_shapes.clear(update=True) + elif obj_active.kind == 'cncjob': try: obj_active.text_col.enabled = False @@ -4841,7 +4848,6 @@ class App(QtCore.QObject): # if there are no longer objects delete also the exclusion areas shapes if not self.collection.get_list(): self.exc_areas.clear_shapes() - self.inform.emit('%s...' % _("Object(s) deleted")) else: self.inform.emit('[ERROR_NOTCL] %s %s' % (_("Failed."), _("No object is selected."))) else: @@ -6498,37 +6504,8 @@ class App(QtCore.QObject): else: self.inform.emit('[WARNING_NOTCL] %s...' % _("Delete Grid value cancelled")) - def on_shortcut_list(self): - self.defaults.report_usage("on_shortcut_list()") - - # add the tab if it was closed - self.ui.plot_tab_area.addTab(self.ui.shortcuts_tab, _("Key Shortcut List")) - - # delete the absolute and relative position and messages in the infobar - # self.ui.position_label.setText("") - # self.ui.rel_position_label.setText("") - # hide coordinates toolbars in the infobar while in DB - self.ui.coords_toolbar.hide() - self.ui.delta_coords_toolbar.hide() - - # Switch plot_area to preferences page - self.ui.plot_tab_area.setCurrentWidget(self.ui.shortcuts_tab) - # self.ui.show() - - def on_select_tab(self, name): - # if the splitter is hidden, display it, else hide it but only if the current widget is the same - if self.ui.splitter.sizes()[0] == 0: - self.ui.splitter.setSizes([1, 1]) - else: - if self.ui.notebook.currentWidget().objectName() == name + '_tab': - self.ui.splitter.setSizes([0, 1]) - - if name == 'project': - self.ui.notebook.setCurrentWidget(self.ui.project_tab) - elif name == 'properties': - self.ui.notebook.setCurrentWidget(self.ui.properties_tab) - elif name == 'tool': - self.ui.notebook.setCurrentWidget(self.ui.tool_tab) + def on_close_notebook_tab(self): + self.tool_shapes.clear(update=True) def on_copy_name(self): self.defaults.report_usage("on_copy_name()")