- some refactoring

- working on Milling Tool and Drilling Tool: made sure that the plugin UI is initialized only when the plugin (Tool) is run in order to avoid errors like (wrapped C++ objects was deleted)
This commit is contained in:
Marius Stanciu
2021-01-29 02:08:34 +02:00
committed by Marius
parent 6c3a99d876
commit 04649622eb
54 changed files with 581 additions and 561 deletions

View File

@@ -45,7 +45,7 @@ class Distance(AppTool):
# ######################### Tool GUI ##########################################
# #############################################################################
self.ui = DistUI(layout=self.layout, app=self.app)
self.toolName = self.ui.toolName
self.pluginName = self.ui.pluginName
# store here the first click and second click of the measurement process
self.points = []
@@ -94,7 +94,7 @@ class Distance(AppTool):
self.tool_done = False
if self.app.tool_tab_locked is True:
if self.app.plugin_tab_locked is True:
return
# if the splitter is hidden, display it
@@ -115,25 +115,25 @@ class Distance(AppTool):
# if the Tool Tab is hidden display it, else hide it but only if the objectName is the same
found_idx = None
for idx in range(self.app.ui.notebook.count()):
if self.app.ui.notebook.widget(idx).objectName() == "tool_tab":
if self.app.ui.notebook.widget(idx).objectName() == "plugin_tab":
found_idx = idx
break
# show the Tab
if not found_idx:
self.app.ui.notebook.addTab(self.app.ui.tool_tab, _("Plugin"))
self.app.ui.notebook.addTab(self.app.ui.plugin_tab, _("Plugin"))
# focus on Tool Tab
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
self.app.ui.notebook.setTabText(2, _("Distance"))
# Remove anything else in the appGUI
self.app.ui.tool_scroll_area.takeWidget()
self.app.ui.plugin_scroll_area.takeWidget()
# Put ourselves in the appGUI
self.app.ui.tool_scroll_area.setWidget(self)
self.app.ui.plugin_scroll_area.setWidget(self)
# Switch notebook to tool page
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
self.app.ui.notebook.setCurrentWidget(self.app.ui.plugin_tab)
self.units = self.app.defaults['units'].lower()
self.app.command_active = "Distance"
@@ -554,7 +554,7 @@ class Distance(AppTool):
class DistUI:
toolName = _("Distance")
pluginName = _("Distance")
def __init__(self, layout, app):
self.app = app
@@ -563,7 +563,7 @@ class DistUI:
self.units = self.app.defaults['units'].lower()
# ## Title
title_label = FCLabel("<font size=4><b>%s</b></font><br>" % self.toolName)
title_label = FCLabel("<font size=4><b>%s</b></font><br>" % self.pluginName)
self.layout.addWidget(title_label)
# ## Form Layout