From 6640815c4dd867fbb7bd8a7a95e3ac45b7b89cec Mon Sep 17 00:00:00 2001 From: PaddleStroke Date: Tue, 25 Jun 2024 16:05:13 +0200 Subject: [PATCH] Assembly: Enable Insert Component taskbox to grow when more items are added. --- src/Mod/Assembly/CommandInsertLink.py | 21 +++++++++++++++++++ .../panels/TaskAssemblyInsertLink.ui | 13 +++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/Mod/Assembly/CommandInsertLink.py b/src/Mod/Assembly/CommandInsertLink.py index 75c403d569..08e4fe5ebd 100644 --- a/src/Mod/Assembly/CommandInsertLink.py +++ b/src/Mod/Assembly/CommandInsertLink.py @@ -207,6 +207,27 @@ class TaskAssemblyInsertLink(QtCore.QObject): process_objects(guiDoc.TreeRootObjects, docItem) self.form.partList.expandAll() + self.adjustTreeWidgetSize() + + def adjustTreeWidgetSize(self): + # Adjust the height of the part list based on item count + item_count = 1 + + def count_items(item): + nonlocal item_count + item_count += 1 + for i in range(item.childCount()): + count_items(item.child(i)) + + for i in range(self.form.partList.topLevelItemCount()): + count_items(self.form.partList.topLevelItem(i)) + + item_height = self.form.partList.sizeHintForRow(0) + total_height = item_count * item_height + max_height = 500 + + self.form.partList.setMinimumHeight(min(total_height, max_height)) + def onFilterChange(self): filter_str = self.form.filterPartList.text().strip().lower() diff --git a/src/Mod/Assembly/Gui/Resources/panels/TaskAssemblyInsertLink.ui b/src/Mod/Assembly/Gui/Resources/panels/TaskAssemblyInsertLink.ui index bc5953f6de..4c485ffc75 100644 --- a/src/Mod/Assembly/Gui/Resources/panels/TaskAssemblyInsertLink.ui +++ b/src/Mod/Assembly/Gui/Resources/panels/TaskAssemblyInsertLink.ui @@ -6,8 +6,8 @@ 0 0 - 376 - 387 + 200 + 200 @@ -22,7 +22,14 @@ - + + + + 0 + 0 + + +