Преглед изворни кода

- reverted changes in Tools regarding the toggle effect - now they work as expected

Marius Stanciu пре 6 година
родитељ
комит
090a3ff8f8

+ 2 - 13
FlatCAMTool.py

@@ -71,9 +71,9 @@ class FlatCAMTool(QtWidgets.QWidget):
         if separator is True:
             pos.addSeparator()
 
-        self.menuAction.triggered.connect(lambda: self.run(toggle=True))
+        self.menuAction.triggered.connect(self.run)
 
-    def run(self, toggle=True):
+    def run(self):
 
         if self.app.tool_tab_locked is True:
             return
@@ -86,17 +86,6 @@ class FlatCAMTool(QtWidgets.QWidget):
         # Switch notebook to tool page
         self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
 
-        if toggle:
-            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
-            if self.app.ui.splitter.sizes()[0] == 0:
-                self.app.ui.splitter.setSizes([1, 1])
-            else:
-                try:
-                    if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
-                        self.app.ui.splitter.setSizes([0, 1])
-                except AttributeError:
-                    pass
-
         # Set the tool name as the widget object name
         self.app.ui.tool_scroll_area.widget().setObjectName(self.toolName)
 

+ 1 - 1
README.md

@@ -20,7 +20,7 @@ CAD program, and create G-Code for Isolation routing.
 - another changes to the final_save() function
 - some strings were left outside the translation formatting - fixed
 - finished the replacement of '_' symbols throughout the app which conflicted with the _() function used by the i18n
-
+- reverted changes in Tools regarding the toggle effect - now they work as expected
 
 10.03.2019
 

+ 9 - 2
flatcamTools/ToolCalculators.py

@@ -235,11 +235,18 @@ class ToolCalculator(FlatCAMTool):
 
         self.calculate_plate_button.clicked.connect(self.on_calculate_eplate)
 
-
     def run(self, toggle=True):
         self.app.report_usage("ToolCalculators()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
 
         self.set_tool_ui()
 

+ 9 - 1
flatcamTools/ToolCutOut.py

@@ -282,7 +282,15 @@ class CutOut(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolCutOut()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, "Cutout Tool")

+ 9 - 1
flatcamTools/ToolDblSided.py

@@ -272,7 +272,15 @@ class DblSidedTool(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("Tool2Sided()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, _("2-Sided Tool"))

+ 9 - 1
flatcamTools/ToolFilm.py

@@ -183,7 +183,15 @@ class Film(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolFilm()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
 
         self.set_tool_ui()
 

+ 9 - 1
flatcamTools/ToolImage.py

@@ -150,7 +150,15 @@ class ToolImage(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolImage()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, _("Image Tool"))

+ 1 - 1
flatcamTools/ToolNonCopperClear.py

@@ -262,7 +262,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
     def run(self, toggle=True):
         self.app.report_usage("ToolNonCopperClear()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.build_ui()

+ 9 - 1
flatcamTools/ToolPaint.py

@@ -320,7 +320,15 @@ class ToolPaint(FlatCAMTool, Gerber):
     def run(self, toggle=True):
         self.app.report_usage("ToolPaint()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, _("Paint Tool"))

+ 9 - 1
flatcamTools/ToolPanelize.py

@@ -216,7 +216,15 @@ class Panelize(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolPanelize()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, "Panel. Tool")

+ 10 - 1
flatcamTools/ToolProperties.py

@@ -69,9 +69,18 @@ class Properties(FlatCAMTool):
 
         if self.app.tool_tab_locked is True:
             return
+
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
-        FlatCAMTool.run(self, toggle=toggle)
         self.properties()
 
     def install(self, icon=None, separator=None, **kwargs):

+ 9 - 1
flatcamTools/ToolSolderPaste.py

@@ -429,7 +429,15 @@ class SolderPaste(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolSolderPaste()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
         self.build_ui()
 

+ 9 - 1
flatcamTools/ToolTransform.py

@@ -378,7 +378,15 @@ class ToolTransform(FlatCAMTool):
     def run(self, toggle=True):
         self.app.report_usage("ToolTransform()")
 
-        FlatCAMTool.run(self, toggle=toggle)
+        if toggle:
+            # if the splitter is hidden, display it, else hide it but only if the current widget is the same
+            if self.app.ui.splitter.sizes()[0] == 0:
+                self.app.ui.splitter.setSizes([1, 1])
+            else:
+                if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
+                    self.app.ui.splitter.setSizes([0, 1])
+
+        FlatCAMTool.run(self)
         self.set_tool_ui()
 
         self.app.ui.notebook.setTabText(2, _("Transform Tool"))