Skip to content

Commit

Permalink
Merge pull request #3645 from Russ4262/BaseGeomList_resize
Browse files Browse the repository at this point in the history
[Path] Resize the Base Geometry list dynamically
  • Loading branch information
sliptonic committed Jun 29, 2020
2 parents aeb989a + 65f7e24 commit 8a85d0b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Mod/Path/PathScripts/PathOpGui.py
Expand Up @@ -481,6 +481,7 @@ def setFields(self, obj):
item.setData(self.DataObjectSub, sub)
self.form.baseList.addItem(item)
self.form.baseList.blockSignals(False)
self.resizeBaseList()

def itemActivated(self):
FreeCADGui.Selection.clearSelection()
Expand Down Expand Up @@ -566,6 +567,7 @@ def deleteBase(self):
self.setDirty()
self.updateBase()
self.updatePanelVisibility('Operation', self.obj)
self.resizeBaseList()

def updateBase(self):
newlist = []
Expand All @@ -586,6 +588,7 @@ def clearBase(self):
self.obj.Base = []
self.setDirty()
self.updatePanelVisibility('Operation', self.obj)
self.resizeBaseList()

def importBaseGeometry(self):
opLabel = str(self.form.geometryImportList.currentText())
Expand Down Expand Up @@ -615,6 +618,15 @@ def updateSelection(self, obj, sel):
else:
self.form.addBase.setEnabled(False)

def resizeBaseList(self):
# Set base geometry list window to resize based on contents
# Code reference:
# https://stackoverflow.com/questions/6337589/qlistwidget-adjust-size-to-content
qList = self.form.baseList
# qList.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
col = qList.width() # 300
row = (qList.count() + qList.frameWidth()) * 15
qList.setFixedSize(col, row)

class TaskPanelBaseLocationPage(TaskPanelPage):
'''Page controller for base locations. Uses PathGetPoint.'''
Expand Down

0 comments on commit 8a85d0b

Please sign in to comment.