From 820c06fe034822f2011a62832ee46dd2c600637e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 2 Feb 2025 19:27:30 +0100 Subject: [PATCH] Gui: Fix DlgPreferencesImp::minimumDialogWidth() to return a reasonable width The current implementation always returns a width that is too small so that a scrollbar is shown. Especially on the General page this is unfortunate as some important controls are truncated or completely hidden. Another problem of this implementation is that when loading a not yet loaded workbench in the 'Available workbenches' page then the computed size will be by far too high leading to a dialog that all the sudden covers most of the screen. Solution: The correct width is the sum of: width of the tree view + width of the biggest page + spacing of the layout This fixes both of the above problems. --- src/Gui/Dialogs/DlgPreferencesImp.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/Gui/Dialogs/DlgPreferencesImp.cpp b/src/Gui/Dialogs/DlgPreferencesImp.cpp index d451d534e1..d5b539994e 100644 --- a/src/Gui/Dialogs/DlgPreferencesImp.cpp +++ b/src/Gui/Dialogs/DlgPreferencesImp.cpp @@ -365,18 +365,9 @@ int DlgPreferencesImp::minimumDialogWidth(int pageWidth) const { // this is additional safety spacing to ensure that everything fits with scrollbar etc. const auto additionalMargin = style()->pixelMetric(QStyle::PM_ScrollBarExtent) + 8; - - QSize size = ui->groupWidgetStack->sizeHint(); - int diff = pageWidth - size.width(); - int dw = width(); - - if (diff > 0) { - const int offset = 2; - dw += diff + offset; - } - - return dw + additionalMargin; + QSize tree = ui->groupsTreeView->sizeHint(); + return pageWidth + tree.width() + additionalMargin; } void DlgPreferencesImp::updatePageDependentWidgets() @@ -908,7 +899,7 @@ void DlgPreferencesImp::onStackWidgetChange(int index) ui->groupsTreeView->expand(parentItem->index()); parentItem->setExpanded(wasExpanded); } - + ui->groupsTreeView->selectionModel()->select(currentIndex, QItemSelectionModel::ClearAndSelect); }