Просмотр исходного кода

- the context menu for the Tabs in notebook and PlotTabArea is launched now on right mouse click on tabs themselves

Marius Stanciu 6 лет назад
Родитель
Сommit
9b9f99d824
2 измененных файлов с 28 добавлено и 9 удалено
  1. 24 8
      FlatCAMApp.py
  2. 4 1
      README.md

+ 24 - 8
FlatCAMApp.py

@@ -1978,14 +1978,13 @@ class App(QtCore.QObject):
         # ToolBar signals
         # ToolBar signals
         self.connect_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
         # 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
         # Context Menu
         self.ui.popmenu_disable.triggered.connect(lambda: self.toggle_plots(self.collection.get_selected()))
         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.
         # This will write the setting to the platform specific storage.
         del settings
         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.ui.notebook.set_detachable(val=checked)
         self.defaults["global_tabs_detachable"] = checked
         self.defaults["global_tabs_detachable"] = checked
 
 
         self.ui.plot_tab_area.set_detachable(val=checked)
         self.ui.plot_tab_area.set_detachable(val=checked)
         self.defaults["global_tabs_detachable"] = 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):
     def on_deselect_all(self):
         self.collection.set_all_inactive()
         self.collection.set_all_inactive()
         self.delete_selection_shape()
         self.delete_selection_shape()

+ 4 - 1
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
 18.10.2019
 
 
 - fixed a small bug in BETA status change
 - 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
 - started to work to a new tool: Calibrate Excellon Tool
 - solved the issue #329
 - solved the issue #329
 
 
-
 18.10.2019
 18.10.2019
 
 
 - finished the update on the Google translated Spanish translation.
 - finished the update on the Google translated Spanish translation.