From a11488322b0b91d0d72b8623f8a3d74bae1856d7 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 19 Dec 2016 13:49:04 +0530 Subject: [PATCH] Do not layout hidden widgets --- src/calibre/gui2/widgets2.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py index 73193e05c5..61d0f2f0d9 100644 --- a/src/calibre/gui2/widgets2.py +++ b/src/calibre/gui2/widgets2.py @@ -381,6 +381,8 @@ class FlowLayout(QLayout): # {{{ gmap = {} for item in self.items: isz, wid = item.sizeHint(), item.widget() + if isz.isEmpty() or (wid is not None and not wid.isVisible()): + continue hs, vs = layout_spacing(wid), layout_spacing(wid, False) next_x = x + isz.width() + hs @@ -402,10 +404,10 @@ class FlowLayout(QLayout): # {{{ if apply_geometry: for line_height, items in lines: for item, item_height in items: - x, y, isz = gmap[item] + x, wy, isz = gmap[item] if item_height < line_height: - y += (line_height - item_height) // 2 - item.setGeometry(QRect(QPoint(x, y), isz)) + wy += (line_height - item_height) // 2 + item.setGeometry(QRect(QPoint(x, wy), isz)) return y + line_height - rect.y() + bottom