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.
This commit is contained in:
wmayer
2025-02-02 19:27:30 +01:00
committed by Ladislav Michl
parent 1926c1f1b9
commit 820c06fe03

View File

@@ -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);
}