- solved the problem with not closing all the tabs in Plot Area when creating a New Project; the issue was that once a tab was removed the indexes are remade (when tab 0 is removed then tab 1 becomes tab 0 and so on)

This commit is contained in:
Marius Stanciu 2020-04-29 21:43:28 +03:00 committed by Marius
parent 1b0abc6798
commit 804b62af7f
5 changed files with 46 additions and 25 deletions

View File

@ -23,6 +23,7 @@ CHANGELOG for FlatCAM beta
- updated the Romanian translation
- fixed units conversion issue
- updated the units conversion method to convert all the convertible parameters in the Preferences
- solved the problem with not closing all the tabs in Plot Area when creating a New Project; the issue was that once a tab was removed the indexes are remade (when tab 0 is removed then tab 1 becomes tab 0 and so on)
28.04.2020

View File

@ -4586,7 +4586,7 @@ class App(QtCore.QObject):
self.ui.plot_tab_area.protectTab(0)
return
if name != 'plotarea':
if name != 'plotarea_tab':
self.ui.plot_tab_area.insertTab(0, self.ui.plot_tab, "Plot Area")
# remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
self.ui.plot_tab_area.protectTab(0)
@ -6098,17 +6098,17 @@ class App(QtCore.QObject):
else:
return
def on_plotarea_tab_closed(self, tab_idx):
"""
:param tab_idx: Index of the Tab from the plotarea that was closed
:return:
"""
widget = self.ui.plot_tab_area.widget(tab_idx)
if widget is not None:
widget.deleteLater()
self.ui.plot_tab_area.removeTab(tab_idx)
# def on_plotarea_tab_closed(self, tab_idx):
# """
#
# :param tab_idx: Index of the Tab from the plotarea that was closed
# :return:
# """
# widget = self.ui.plot_tab_area.widget(tab_idx)
#
# if widget is not None:
# widget.deleteLater()
# self.ui.plot_tab_area.removeTab(tab_idx)
def on_flipy(self):
"""
@ -7368,6 +7368,7 @@ class App(QtCore.QObject):
# Remove everything from memory
App.log.debug("on_file_new()")
# close any editor that might be open
if self.call_source != 'app':
self.editor2object(cleanup=True)
# ## EDITOR section
@ -7402,9 +7403,13 @@ class App(QtCore.QObject):
# tcl needs to be reinitialized, otherwise old shell variables etc remains
self.shell.init_tcl()
# delete any selection shape on canvas
self.delete_selection_shape()
# delete all FlatCAM objects
self.collection.delete_all()
# add in Selected tab an initial text that describe the flow of work in FlatCAm
self.setup_component_editor()
# Clear project filename
@ -7416,18 +7421,23 @@ class App(QtCore.QObject):
# Re-fresh project options
self.on_options_app2project()
# Init Tools
# Init FlatCAMTools
self.init_tools()
# Try to close all tabs in the PlotArea but only if the GUI is active (CLI is None)
if cli is None:
# Close any Tabs opened in the Plot Tab Area section
for index in range(self.ui.plot_tab_area.count()):
self.ui.plot_tab_area.closeTab(index)
# for whatever reason previous command does not close the last tab so I do it manually
self.ui.plot_tab_area.closeTab(0)
# we need to go in reverse because once we remove a tab then the index changes
# meaning that removing the first tab (idx = 0) then the tab at former idx = 1 will assume idx = 0
# and so on. Therefore the deletion should be done in reverse
wdg_count = self.ui.plot_tab_area.tabBar.count() - 1
for index in range(wdg_count, -1, -1):
try:
self.ui.plot_tab_area.closeTab(index)
except Exception as e:
log.debug("App.on_file_new() --> %s" % str(e))
# # And then add again the Plot Area
self.ui.plot_tab_area.addTab(self.ui.plot_tab, "Plot Area")
self.ui.plot_tab_area.insertTab(0, self.ui.plot_tab, "Plot Area")
self.ui.plot_tab_area.protectTab(0)
# take the focus of the Notebook on Project Tab.

View File

@ -17,7 +17,7 @@ if '_' not in builtins.__dict__:
class BookmarkManager(QtWidgets.QWidget):
mark_rows = QtCore.pyqtSignal()
# mark_rows = QtCore.pyqtSignal()
def __init__(self, app, storage, parent=None):
super(BookmarkManager, self).__init__(parent)
@ -119,9 +119,18 @@ class BookmarkManager(QtWidgets.QWidget):
self.link_entry.returnPressed.connect(self.on_add_entry)
# closebtn.clicked.connect(self.accept)
self.table_widget.drag_drop_sig.connect(self.mark_table_rows_for_actions)
self.ui_connect()
self.build_bm_ui()
def ui_connect(self):
self.table_widget.drag_drop_sig.connect(self.mark_table_rows_for_actions)
def ui_disconnect(self):
try:
self.table_widget.drag_drop_sig.connect(self.mark_table_rows_for_actions)
except (TypeError, AttributeError):
pass
def build_bm_ui(self):
self.table_widget.setRowCount(len(self.bm_dict))
@ -378,4 +387,5 @@ class BookmarkManager(QtWidgets.QWidget):
def closeEvent(self, QCloseEvent):
self.rebuild_actions()
self.ui_disconnect()
super().closeEvent(QCloseEvent)

View File

@ -1169,7 +1169,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.plot_tab_area.setTabsClosable(True)
self.plot_tab = QtWidgets.QWidget()
self.plot_tab.setObjectName("plotarea")
self.plot_tab.setObjectName("plotarea_tab")
self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
self.right_layout = QtWidgets.QVBoxLayout()

View File

@ -2076,7 +2076,7 @@ class FCDetachableTab(QtWidgets.QTabWidget):
class FCDetachableTab2(FCDetachableTab):
tab_closed_signal = QtCore.pyqtSignal(object)
tab_closed_signal = QtCore.pyqtSignal(object, int)
def __init__(self, protect=None, protect_by_name=None, parent=None):
super(FCDetachableTab2, self).__init__(protect=protect, protect_by_name=protect_by_name, parent=parent)
@ -2089,8 +2089,8 @@ class FCDetachableTab2(FCDetachableTab):
:return:
"""
# idx = self.currentIndex()
self.tab_name = self.widget(currentIndex).objectName()
self.tab_closed_signal.emit(self.tab_name)
tab_name = self.widget(currentIndex).objectName()
self.tab_closed_signal.emit(tab_name, currentIndex)
self.removeTab(currentIndex)