diff --git a/kdevplatform/sublime/ideallayout.cpp b/kdevplatform/sublime/ideallayout.cpp --- a/kdevplatform/sublime/ideallayout.cpp +++ b/kdevplatform/sublime/ideallayout.cpp @@ -202,9 +202,10 @@ return x + currentLineWidth + r; } - const bool shrink = rect.height() < sizeHint().height(); + bool shrink = rect.height() < sizeHint().height(); - const int maximumHeight = rect.height() / _items.size(); + // space left per button after removing available space for buttonSpacing + const int maximumHeight = (rect.height() - buttonSpacing * (_items.size() - 1)) / _items.size(); int shrinkedHeight = -1; if (shrink) { @@ -218,9 +219,13 @@ return acc; }); - Q_ASSERT(_items.size() != smallItemCount); // should be true since rect.width != sizeHint.width - // evenly distribute surplus height over large items - shrinkedHeight = maximumHeight + surplus / (_items.size() - smallItemCount); + if (_items.size() != smallItemCount) { + // evenly distribute surplus height over large items + shrinkedHeight = maximumHeight + surplus / (_items.size() - smallItemCount); + } else { + // only small items, no shrinkage needed + shrink = false; + } } for (QLayoutItem* item : _items) { @@ -260,9 +265,10 @@ return y + currentLineHeight + b; } - const bool shrink = rect.width() < sizeHint().width(); + bool shrink = rect.width() < sizeHint().width(); - const int maximumWidth = rect.width() / _items.size(); + // space left per button after removing available space for buttonSpacing + const int maximumWidth = (rect.width() - buttonSpacing * (_items.size() - 1)) / _items.size(); int shrinkedWidth = -1; if (shrink) { @@ -276,9 +282,12 @@ return acc; }); - Q_ASSERT(_items.size() != smallItemCount); // should be true since rect.width != sizeHint.width - // evenly distribute surplus width on the large items - shrinkedWidth = maximumWidth + surplus / (_items.size() - smallItemCount); + if (_items.size() != smallItemCount) { + // evenly distribute surplus width on the large items + shrinkedWidth = maximumWidth + surplus / (_items.size() - smallItemCount); + } else { + shrink = false; + } } for (QLayoutItem* item : _items) {