From 090a3ff8f8af59c27234e452b49a192809ae355d Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 11 Mar 2019 22:58:27 +0200 Subject: [PATCH] - reverted changes in Tools regarding the toggle effect - now they work as expected --- FlatCAMTool.py | 15 ++------------- README.md | 2 +- flatcamTools/ToolCalculators.py | 11 +++++++++-- flatcamTools/ToolCutOut.py | 10 +++++++++- flatcamTools/ToolDblSided.py | 10 +++++++++- flatcamTools/ToolFilm.py | 10 +++++++++- flatcamTools/ToolImage.py | 10 +++++++++- flatcamTools/ToolNonCopperClear.py | 2 +- flatcamTools/ToolPaint.py | 10 +++++++++- flatcamTools/ToolPanelize.py | 10 +++++++++- flatcamTools/ToolProperties.py | 11 ++++++++++- flatcamTools/ToolSolderPaste.py | 10 +++++++++- flatcamTools/ToolTransform.py | 10 +++++++++- 13 files changed, 95 insertions(+), 26 deletions(-) diff --git a/FlatCAMTool.py b/FlatCAMTool.py index fab4f7ae..db313cac 100644 --- a/FlatCAMTool.py +++ b/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) diff --git a/README.md b/README.md index ebb54951..aa096d7b 100644 --- a/README.md +++ b/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 diff --git a/flatcamTools/ToolCalculators.py b/flatcamTools/ToolCalculators.py index a3b62be7..6a5a494f 100644 --- a/flatcamTools/ToolCalculators.py +++ b/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() diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 540b73b7..9af3b285 100644 --- a/flatcamTools/ToolCutOut.py +++ b/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") diff --git a/flatcamTools/ToolDblSided.py b/flatcamTools/ToolDblSided.py index 18c557b9..fa8486ed 100644 --- a/flatcamTools/ToolDblSided.py +++ b/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")) diff --git a/flatcamTools/ToolFilm.py b/flatcamTools/ToolFilm.py index 2cffa7b2..c01fcbbe 100644 --- a/flatcamTools/ToolFilm.py +++ b/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() diff --git a/flatcamTools/ToolImage.py b/flatcamTools/ToolImage.py index 48d0baba..09a209a0 100644 --- a/flatcamTools/ToolImage.py +++ b/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")) diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index b77a353b..d5b20819 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/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() diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index fcaaeda6..cab5e590 100644 --- a/flatcamTools/ToolPaint.py +++ b/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")) diff --git a/flatcamTools/ToolPanelize.py b/flatcamTools/ToolPanelize.py index 9d2004c3..34cef26f 100644 --- a/flatcamTools/ToolPanelize.py +++ b/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") diff --git a/flatcamTools/ToolProperties.py b/flatcamTools/ToolProperties.py index ef03d86f..979dc95d 100644 --- a/flatcamTools/ToolProperties.py +++ b/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): diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py index dce820d2..425d688b 100644 --- a/flatcamTools/ToolSolderPaste.py +++ b/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() diff --git a/flatcamTools/ToolTransform.py b/flatcamTools/ToolTransform.py index 624491f0..a94ad101 100644 --- a/flatcamTools/ToolTransform.py +++ b/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"))