another Kirigami patch

Dirk Hohndel dirk at hohndel.org
Sat Apr 2 22:56:37 UTC 2016


This one is not directly related to the feedback that I had already
collected, so instead of constantly replying to myself, I'll start a new
email.

If a page in a PageRow updates it title but the page object in the page
stack doesn't change, Kirigami doesn't notice and happily shows the now
outdated bread crumbs in the title. I couldn't figure out a way for
the ApplicationHeader to notice that one of the titles has changed, so I
turned this around and offered the app a way to tell Kirigami that a title
had changed.

/D

>From 5ea925f7349b20524a372cd8a0ddabf73b26d13a Mon Sep 17 00:00:00 2001
From: Dirk Hohndel <dirk at hohndel.org>
Date: Sat, 2 Apr 2016 17:47:30 -0500
Subject: [PATCH 4/4] Allow the application to notify Kirigami about changed
 title

Simply calling header.updateBreadCrumbs() makes sure that the bread crumbs
in the title are correct.

Signed-off-by: Dirk Hohndel <dirk at hohndel.org>
---
 src/qml/ApplicationHeader.qml | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/src/qml/ApplicationHeader.qml b/src/qml/ApplicationHeader.qml
index 458de58..2047048 100644
--- a/src/qml/ApplicationHeader.qml
+++ b/src/qml/ApplicationHeader.qml
@@ -65,6 +65,24 @@ Rectangle {
     property QtObject __appWindow: applicationWindow();
     parent: __appWindow.contentItem;
 
+    function updateBreadCrumbs() {
+        var i = 0;
+        for (; i < __appWindow.pageStack.contentChildren.length; ++i) {
+            if (i >= model.count || __appWindow.pageStack.contentChildren[i].title
+                != model.get(i).title) {
+                break;
+            }
+        }
+
+        while (model.count > i && model.count > 0) {
+            model.remove(model.count - 1);
+        }
+
+        for (var j = i; j < __appWindow.pageStack.contentChildren.length; ++j) {
+            model.append({"title": __appWindow.pageStack.contentChildren[j].title});
+        }
+    }
+
     transform: Translate {
         id: translateTransform
         y: __appWindow.controlsVisible ? 0 : -headerItem.height - shadow.height
@@ -112,21 +130,7 @@ Rectangle {
         }
 
         onContentChildrenChanged: {
-            var i = 0;
-            for (; i < __appWindow.pageStack.contentChildren.length; ++i) {
-                if (i >= model.count || __appWindow.pageStack.contentChildren[i].title 
-                    != model.get(i).title) {
-                    break;
-                }
-            }
-
-            while (model.count > i && model.count > 0) {
-                model.remove(model.count - 1);
-            }
-
-            for (var j = i; j < __appWindow.pageStack.contentChildren.length; ++j) {
-                model.append({"title": __appWindow.pageStack.contentChildren[j].title});
-            }
+            updateBreadCrumbs()
         }
     }
 
-- 
2.6.4 (Apple Git-63)




More information about the Plasma-devel mailing list