[RFC-PATCH] Don't show empty pages on the right

Dirk Hohndel dirk at hohndel.org
Fri Mar 4 18:09:45 UTC 2016


When building Subsurface-mobile against Qt 5.6.0 RC we are observing an
odd problem with Kirigami: if the window is wide enough to show more than
one page (e.g., a device in landscape mode), the page stack always shows
the "top" page on the left edge and empty space to the right of it.

With earlier Qt versions the effect was much more reasonable: as many
pages from the top were shown as were needed to fill the screen, so in
landscape mode with enough space for two pages, the top two pages would be
shown.

I couldn't figure out what change triggered this, but throwing some debug
prints around I quickly noticed that the scrollToLevel() function is
written to move that level of the stack to the left edge of the screen.
That matches the description of this function and matches what is
happening, but I think that isn't what we want.

The patch below seems to fix the problem, but I'm not sure it's the right
patch... Marco, Sebastian, comments?

Did I break intended behavior of this function? Or is this function indeed
wrong and just happened to do the right thing in earlier versions of Qt
because of undocumented behavior in earlier Qt versions?

/D

>From b2aabd82bfb55695ab1d8ebe013abd3a1fb665b3 Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <dirk at hohndel.org>
Date: Fri, 4 Mar 2016 09:55:46 -0800
Subject: [RFC-PATCH] Don't show empty pages on the right

We want to show as many of our pages as possible, so if we scroll to a page on
the stack make sure that we don't show empty pages on the right just because we
show that page on the left edge.

This issue only has come up with Qt 5.6.0 RC so I wonder if I'm fixing a
symptom instead of the actual problem as with earlier Qt versions scrolling did
the right thing.

Signed-off-by: Dirk Hohndel <dirk at hohndel.org>
---
 components/mobilecomponents/qml/PageRow.qml | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/components/mobilecomponents/qml/PageRow.qml b/components/mobilecomponents/qml/PageRow.qml
index cf371ad..9a92644 100644
--- a/components/mobilecomponents/qml/PageRow.qml
+++ b/components/mobilecomponents/qml/PageRow.qml
@@ -131,11 +131,12 @@ Item {
         if (root.width <= width) {
             //return
         }
+        var pagesShown = Math.floor(width / columnWidth)
 
         if (level <= 0) {
             scrollAnimation.to = 0;
-        } else if (level >= depth) {
-            scrollAnimation.to = Engine.pageStack[depth - 1].x;
+        } else if (level > depth - pagesShown) {
+            scrollAnimation.to = Engine.pageStack[depth - pagesShown].x;
         } else {
             scrollAnimation.to = Engine.pageStack[level-1].x + Engine.pageStack[level-1].page.width ;
         }
-- 
2.5.4 (Apple Git-61)



More information about the Plasma-devel mailing list