D15450: Sublime: Fix window growing larger by making tool view buttons shrinkable

René J.V. Bertin noreply at phabricator.kde.org
Tue Sep 18 13:08:16 BST 2018


rjvbb added a comment.


  No, I haven't pushed a fix, but I have one which seems to work just fine. Feel free to clean it up as you see fit (I see an accidental indentation change) and push it yourself.
  
    diff --git kdevplatform/sublime/ideallayout.cpp kdevplatform/sublime/ideallayout.cpp
    index 8bc43479197dfb1b018b780c116034c3f1fc7e69..5976a2c5b31aef60b9f7e49ea5560330a0531cba 100644
    --- kdevplatform/sublime/ideallayout.cpp
    +++ kdevplatform/sublime/ideallayout.cpp
    @@ -202,12 +202,12 @@ int IdealButtonBarLayout::doVerticalLayout(const QRect &rect, bool updateGeometr
             return x + currentLineWidth + r;
         }
     
    -    const bool shrink = rect.height() < sizeHint().height();
    +    bool shrink = rect.height() < sizeHint().height();
     
         const int maximumHeight = rect.height() / _items.size();
         int shrinkedHeight = -1;
     
    -    if (shrink) {
    +    if (shrink ) {
             int smallItemCount = 0;
             const int surplus = std::accumulate(_items.begin(), _items.end(), 0, [maximumHeight, &smallItemCount](int acc, QLayoutItem* item) {
                 const int itemHeight = item->sizeHint().height();
    @@ -218,9 +218,13 @@ int IdealButtonBarLayout::doVerticalLayout(const QRect &rect, bool updateGeometr
                 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,7 +264,7 @@ int IdealButtonBarLayout::doHorizontalLayout(const QRect &rect, bool updateGeome
             return y + currentLineHeight + b;
         }
     
    -    const bool shrink = rect.width() < sizeHint().width();
    +    bool shrink = rect.width() < sizeHint().width();
     
         const int maximumWidth = rect.width() / _items.size();
         int shrinkedWidth = -1;
    @@ -276,9 +280,12 @@ int IdealButtonBarLayout::doHorizontalLayout(const QRect &rect, bool updateGeome
                 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 height over large items
    +           shrinkedWidth = maximumWidth + surplus / (_items.size() - smallItemCount);
    +        } else {
    +           shrink = false;
    +        }
         }
     
         for (QLayoutItem* item : _items) {

REPOSITORY
  R32 KDevelop

REVISION DETAIL
  https://phabricator.kde.org/D15450

To: amhndu, #kdevelop, kossebau
Cc: rjvbb, kossebau, kdevelop-devel, antismap, iodelay, vbspam, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20180918/d1a6677c/attachment-0001.html>


More information about the KDevelop-devel mailing list