From 1f65c9c05fc98de64dd1e28cf913506f52dfa99c Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 9 Dec 2020 23:12:49 +0200 Subject: [PATCH] - in all Object UI's fixed the Properties section columns resize to content on expansion/collapse of the items --- CHANGELOG.md | 3 ++- appObjects/FlatCAMCNCJob.py | 6 ++++++ appObjects/FlatCAMExcellon.py | 7 +++++++ appObjects/FlatCAMGeometry.py | 7 ++++++- appObjects/FlatCAMGerber.py | 6 ++++++ appObjects/FlatCAMObj.py | 3 +++ 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 617d6156..cace4801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,8 @@ CHANGELOG for FlatCAM beta - fixed the on_delete() method in the App class; sometime it will delete all files that have similar names - made sure that on creation of new objects the adding of the names to the auto-complete list is done properly - Drilling Tool - remade the 'Beginner/Advanced' Mode -- Milling Tool - fixed the ever-growing list of preproessors +- Milling Tool - fixed the ever-growing list of preprocessor's +- in all Object UI's fixed the Properties section columns resize to content on expansion/collapse of the items 8.12.2020 diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index 3ceafe90..4c020ff0 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -597,6 +597,8 @@ class CNCJobObject(FlatCAMObj, CNCjob): # Properties self.ui.properties_button.toggled.connect(self.on_properties) self.calculations_finished.connect(self.update_area_chull) + self.ui.treeWidget.itemExpanded.connect(self.on_properties_expanded) + self.ui.treeWidget.itemCollapsed.connect(self.on_properties_expanded) # Include CNC Job Snippets changed self.ui.snippets_cb.toggled.connect(self.on_update_source_file) @@ -739,6 +741,10 @@ class CNCJobObject(FlatCAMObj, CNCjob): # make sure that the FCTree widget columns are resized to content self.ui.treeWidget.resize_sig.emit() + def on_properties_expanded(self): + for col in range(self.treeWidget.columnCount()): + self.ui.treeWidget.resizeColumnToContents(col) + def on_add_al_probepoints(self): # create the solid_geo diff --git a/appObjects/FlatCAMExcellon.py b/appObjects/FlatCAMExcellon.py index 7cdf93c6..70466073 100644 --- a/appObjects/FlatCAMExcellon.py +++ b/appObjects/FlatCAMExcellon.py @@ -178,6 +178,8 @@ class ExcellonObject(FlatCAMObj, Excellon): # Properties self.ui.properties_button.toggled.connect(self.on_properties) self.calculations_finished.connect(self.update_area_chull) + self.ui.treeWidget.itemExpanded.connect(self.on_properties_expanded) + self.ui.treeWidget.itemCollapsed.connect(self.on_properties_expanded) self.ui.drill_button.clicked.connect(lambda: self.app.drilling_tool.run(toggle=True)) self.ui.milling_button.clicked.connect(self.on_milling_button_clicked) @@ -626,10 +628,15 @@ class ExcellonObject(FlatCAMObj, Excellon): self.ui.treeWidget.clear() self.add_properties_items(obj=self, treeWidget=self.ui.treeWidget) + self.ui.treeWidget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.MinimumExpanding) # make sure that the FCTree widget columns are resized to content self.ui.treeWidget.resize_sig.emit() + def on_properties_expanded(self): + for col in range(self.treeWidget.columnCount()): + self.ui.treeWidget.resizeColumnToContents(col) + def on_milling_button_clicked(self): self.app.milling_tool.run(toggle=True) self.app.milling_tool.ui.target_radio.set_value('exc') diff --git a/appObjects/FlatCAMGeometry.py b/appObjects/FlatCAMGeometry.py index 5b89fa9b..9baa932d 100644 --- a/appObjects/FlatCAMGeometry.py +++ b/appObjects/FlatCAMGeometry.py @@ -663,6 +663,8 @@ class GeometryObject(FlatCAMObj, Geometry): # Properties self.ui.properties_button.toggled.connect(self.on_properties) self.calculations_finished.connect(self.update_area_chull) + self.ui.treeWidget.itemExpanded.connect(self.on_properties_expanded) + self.ui.treeWidget.itemCollapsed.connect(self.on_properties_expanded) # # Buttons Signals # self.ui.generate_cnc_button.clicked.connect(self.on_generatecnc_button_click) @@ -709,11 +711,14 @@ class GeometryObject(FlatCAMObj, Geometry): self.ui.treeWidget.clear() self.add_properties_items(obj=self, treeWidget=self.ui.treeWidget) - self.ui.treeWidget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.MinimumExpanding) # make sure that the FCTree widget columns are resized to content self.ui.treeWidget.resize_sig.emit() + def on_properties_expanded(self): + for col in range(self.treeWidget.columnCount()): + self.ui.treeWidget.resizeColumnToContents(col) + def on_milling_button_clicked(self): self.app.milling_tool.run(toggle=True) self.app.milling_tool.ui.target_radio.set_value('geo') diff --git a/appObjects/FlatCAMGerber.py b/appObjects/FlatCAMGerber.py index 844133f2..2c29219e 100644 --- a/appObjects/FlatCAMGerber.py +++ b/appObjects/FlatCAMGerber.py @@ -151,6 +151,8 @@ class GerberObject(FlatCAMObj, Gerber): # Properties self.ui.properties_button.toggled.connect(self.on_properties) self.calculations_finished.connect(self.update_area_chull) + self.ui.treeWidget.itemExpanded.connect(self.on_properties_expanded) + self.ui.treeWidget.itemCollapsed.connect(self.on_properties_expanded) # Tools self.ui.iso_button.clicked.connect(lambda: self.app.isolation_tool.run(toggle=True)) @@ -367,6 +369,10 @@ class GerberObject(FlatCAMObj, Gerber): # make sure that the FCTree widget columns are resized to content self.ui.treeWidget.resize_sig.emit() + def on_properties_expanded(self): + for col in range(self.treeWidget.columnCount()): + self.ui.treeWidget.resizeColumnToContents(col) + def on_generate_buffer(self): self.app.inform.emit('[WARNING_NOTCL] %s...' % _("Buffering solid geometry")) diff --git a/appObjects/FlatCAMObj.py b/appObjects/FlatCAMObj.py index 0ce96dd3..0a248e06 100644 --- a/appObjects/FlatCAMObj.py +++ b/appObjects/FlatCAMObj.py @@ -908,6 +908,9 @@ class FlatCAMObj(QtCore.QObject): self.treeWidget.addChild( location, ['%s:' % _('Copper Area'), '%.*f %s' % (self.decimals, copper_area, 'in2')], True) + for col in range(self.treeWidget.columnCount()): + self.ui.treeWidget.resizeColumnToContents(col) + @staticmethod def poly2rings(poly): return [poly.exterior] + [interior for interior in poly.interiors]