From 9b9f99d8243833e5634da019e3628077334ced37 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 21 Oct 2019 01:05:04 +0300 Subject: [PATCH] - the context menu for the Tabs in notebook and PlotTabArea is launched now on right mouse click on tabs themselves --- FlatCAMApp.py | 32 ++++++++++++++++++++++++-------- README.md | 5 ++++- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 7d2f736c..9feb51d7 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1978,14 +1978,13 @@ class App(QtCore.QObject): # ToolBar signals self.connect_toolbar_signals() - # Notebook signals - # make the right click on the notebook tab connect to a function - self.ui.notebook.setupContextMenu() - self.ui.notebook.addContextMenu( - _("Detachable Tabs"), self.on_notebook_tab_rmb_click, - initial_checked=self.defaults["global_tabs_detachable"]) + # Notebook and Plot Tab Area signals + # make the right click on the notebook tab and plot tab area tab raise a menu + self.ui.notebook.tabBar.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.ui.plot_tab_area.tabBar.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + self.on_tab_setup_context_menu() # activate initial state - self.on_notebook_tab_rmb_click(self.defaults["global_tabs_detachable"]) + self.on_tab_rmb_click(self.defaults["global_tabs_detachable"]) # Context Menu self.ui.popmenu_disable.triggered.connect(lambda: self.toggle_plots(self.collection.get_selected())) @@ -6703,13 +6702,30 @@ class App(QtCore.QObject): # This will write the setting to the platform specific storage. del settings - def on_notebook_tab_rmb_click(self, checked): + def on_tab_rmb_click(self, checked): self.ui.notebook.set_detachable(val=checked) self.defaults["global_tabs_detachable"] = checked self.ui.plot_tab_area.set_detachable(val=checked) self.defaults["global_tabs_detachable"] = checked + def on_tab_setup_context_menu(self): + initial_checked = self.defaults["global_tabs_detachable"] + action_name = str(_("Detachable Tabs")) + action = QtWidgets.QAction(self) + action.setCheckable(True) + action.setText(action_name) + action.setChecked(initial_checked) + + self.ui.notebook.tabBar.addAction(action) + self.ui.plot_tab_area.tabBar.addAction(action) + + try: + action.triggered.disconnect() + except TypeError: + pass + action.triggered.connect(self.on_tab_rmb_click) + def on_deselect_all(self): self.collection.set_all_inactive() self.delete_selection_shape() diff --git a/README.md b/README.md index 7de4c118..b3484c16 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +21.10.2019 + +- the context menu for the Tabs in notebook and PlotTabArea is launched now on right mouse click on tabs themselves + 18.10.2019 - fixed a small bug in BETA status change @@ -17,7 +21,6 @@ CAD program, and create G-Code for Isolation routing. - started to work to a new tool: Calibrate Excellon Tool - solved the issue #329 - 18.10.2019 - finished the update on the Google translated Spanish translation.