Przeglądaj źródła

- modified the method that detects which tab was closed in the Plot Area so it will no longer depend on it's translated text but on it's objectName set on the QTab creation

Marius Stanciu 5 lat temu
rodzic
commit
2ca6e2e3f1
3 zmienionych plików z 14 dodań i 14 usunięć
  1. 1 0
      CHANGELOG.md
  2. 10 11
      FlatCAMApp.py
  3. 3 3
      flatcamGUI/GUIElements.py

+ 1 - 0
CHANGELOG.md

@@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta
 - minor bugs fixed (not so visible)
 - minor bugs fixed (not so visible)
 - promoted some methods to be static
 - promoted some methods to be static
 - set the default layout on first run to the 'minimal' value
 - set the default layout on first run to the 'minimal' value
+- modified the method that detects which tab was closed in the Plot Area so it will no longer depend on it's translated text but on it's objectName set on the QTab creation
 
 
 28.04.2020
 28.04.2020
 
 

+ 10 - 11
FlatCAMApp.py

@@ -3474,6 +3474,7 @@ class App(QtCore.QObject):
 
 
         # BookDialog(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui).exec_()
         # BookDialog(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui).exec_()
         self.book_dialog_tab = BookmarkManager(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui)
         self.book_dialog_tab = BookmarkManager(app=self, storage=self.defaults["global_bookmarks"], parent=self.ui)
+        self.book_dialog_tab.setObjectName("bookmarks_tab")
 
 
         # add the tab if it was closed
         # add the tab if it was closed
         self.ui.plot_tab_area.addTab(self.book_dialog_tab, _("Bookmarks Manager"))
         self.ui.plot_tab_area.addTab(self.book_dialog_tab, _("Bookmarks Manager"))
@@ -6013,19 +6014,17 @@ class App(QtCore.QObject):
         else:
         else:
             self.inform.emit('[ERROR_NOTCL] %s' % _("Adding tool from DB is not allowed for this object."))
             self.inform.emit('[ERROR_NOTCL] %s' % _("Adding tool from DB is not allowed for this object."))
 
 
-    def on_plot_area_tab_closed(self, title):
+    def on_plot_area_tab_closed(self, tab_obj_name):
         """
         """
-        Executed whenever a tab is closed in the Plot Area.
+        Executed whenever a QTab is closed in the Plot Area.
 
 
-        :param title: The name of the tab that was closed.
+        :param title: The objectName of the Tab that was closed. This objectName is assigned on Tab creation
         :return:
         :return:
         """
         """
-        # FIXME: doing this based on translated title doesn't seem very robust.
 
 
-        if title == _("Preferences"):
+        if tab_obj_name == "preferences_tab":
             self.preferencesUiManager.on_close_preferences_tab()
             self.preferencesUiManager.on_close_preferences_tab()
-
-        if title == _("Tools Database"):
+        elif tab_obj_name == "database_tab":
             # disconnect the signals from the table widget in tab
             # disconnect the signals from the table widget in tab
             self.tools_db_tab.ui_disconnect()
             self.tools_db_tab.ui_disconnect()
 
 
@@ -6051,13 +6050,13 @@ class App(QtCore.QObject):
                     self.inform.emit('')
                     self.inform.emit('')
                     return
                     return
             self.tools_db_tab.deleteLater()
             self.tools_db_tab.deleteLater()
-
-        if title == _("Code Editor"):
+        elif tab_obj_name == "text_editor_tab":
             self.toggle_codeeditor = False
             self.toggle_codeeditor = False
-
-        if title == _("Bookmarks Manager"):
+        elif tab_obj_name == "bookmarks_tab":
             self.book_dialog_tab.rebuild_actions()
             self.book_dialog_tab.rebuild_actions()
             self.book_dialog_tab.deleteLater()
             self.book_dialog_tab.deleteLater()
+        else:
+            return
 
 
     def on_plotarea_tab_closed(self, tab_idx):
     def on_plotarea_tab_closed(self, tab_idx):
         """
         """

+ 3 - 3
flatcamGUI/GUIElements.py

@@ -2088,9 +2088,9 @@ class FCDetachableTab2(FCDetachableTab):
         :param currentIndex:
         :param currentIndex:
         :return:
         :return:
         """
         """
-        idx = self.currentIndex()
-
-        self.tab_closed_signal.emit(self.tabText(idx))
+        # idx = self.currentIndex()
+        self.tab_name = self.widget(currentIndex).objectName()
+        self.tab_closed_signal.emit(self.tab_name)
 
 
         self.removeTab(currentIndex)
         self.removeTab(currentIndex)