Fix diagonal navigation — use viewport width for column count
FlowLayout.columns now reads the scroll area viewport width instead of its own width, which can be stale after appending posts or scrollbar visibility changes.
This commit is contained in:
parent
2be7206879
commit
6f684bb491
@ -258,7 +258,12 @@ class FlowLayout(QWidget):
|
|||||||
def columns(self) -> int:
|
def columns(self) -> int:
|
||||||
if not self._items:
|
if not self._items:
|
||||||
return 1
|
return 1
|
||||||
w = self.width() or 800
|
# Use parent viewport width if inside a QScrollArea
|
||||||
|
parent = self.parentWidget()
|
||||||
|
if parent and hasattr(parent, 'viewport'):
|
||||||
|
w = parent.viewport().width()
|
||||||
|
else:
|
||||||
|
w = self.width() or 800
|
||||||
return max(1, w // (THUMB_SIZE + THUMB_SPACING))
|
return max(1, w // (THUMB_SIZE + THUMB_SPACING))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user