From 2ca6e2e3f17f0e55859ee3252978bc4922a33e19 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 29 Apr 2020 10:48:47 +0300 Subject: [PATCH] - 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 --- CHANGELOG.md | 1 + FlatCAMApp.py | 21 ++++++++++----------- flatcamGUI/GUIElements.py | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4e0328..f48fab82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta - minor bugs fixed (not so visible) - promoted some methods to be static - 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 diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 624de538..5188af31 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -3474,6 +3474,7 @@ class App(QtCore.QObject): # 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.setObjectName("bookmarks_tab") # add the tab if it was closed self.ui.plot_tab_area.addTab(self.book_dialog_tab, _("Bookmarks Manager")) @@ -6013,19 +6014,17 @@ class App(QtCore.QObject): else: 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: """ - # 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() - - if title == _("Tools Database"): + elif tab_obj_name == "database_tab": # disconnect the signals from the table widget in tab self.tools_db_tab.ui_disconnect() @@ -6051,13 +6050,13 @@ class App(QtCore.QObject): self.inform.emit('') return self.tools_db_tab.deleteLater() - - if title == _("Code Editor"): + elif tab_obj_name == "text_editor_tab": self.toggle_codeeditor = False - - if title == _("Bookmarks Manager"): + elif tab_obj_name == "bookmarks_tab": self.book_dialog_tab.rebuild_actions() self.book_dialog_tab.deleteLater() + else: + return def on_plotarea_tab_closed(self, tab_idx): """ diff --git a/flatcamGUI/GUIElements.py b/flatcamGUI/GUIElements.py index c43549ff..e550e98f 100644 --- a/flatcamGUI/GUIElements.py +++ b/flatcamGUI/GUIElements.py @@ -2088,9 +2088,9 @@ class FCDetachableTab2(FCDetachableTab): :param currentIndex: :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)