Add property initializer support to PagePool
ClosedPublic

Authored by masonm on Mar 31 2020, 6:10 PM.

Details

Summary

Currently PagePool allows pages to be pushed onto the stack but there
is no way to pass initialization properties to the newly-created
page. This change adds support for this, and also provides
asynchronous object creation to speed things up a bit.

Test Plan

After running the following main.qml the page stack will first
push a page with the default title "NO PROPERTIES" because it
invokes the no-property behavior. Afterward the same page gets
pushed on the stack but this time it sets the title to
"PROPERTIES" using the passed-in properties object.

// main.qml
Kirigami.ApplicationWindow {

id: window

Kirigami.PagePool {
  id: pool
}

Kirigami.PagePoolAction {
  id: noprops

  text: "Action with props"
  pagePool: pool
  pageStack: window.pageStack
  page: "qrc:/TestPage.qml?hasProps=" + false
}
Kirigami.PagePoolAction {
  id: props

  text: "Action with props"
  pagePool: pool
  pageStack: window.pageStack
  page: "qrc:/TestPage.qml?hasProps=" + true
  properties: { title: "PROPERTIES" }
}

Component.onCompleted: {
  noprops.trigger()
  props.trigger()
}

}

// TestPage.qml
Kirigami.Page {

title: "NO PROPERTIES"

}

Diff Detail

Repository
R169 Kirigami
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
masonm created this revision.Mar 31 2020, 6:10 PM
Restricted Application added a project: Kirigami. · View Herald TranscriptMar 31 2020, 6:10 PM
masonm requested review of this revision.Mar 31 2020, 6:10 PM
mart added a comment.Apr 1 2020, 8:11 AM

almost good, just two minor nitpicks

src/controls/PagePoolAction.qml
57

initialProperties

src/pagepool.cpp
160

put a comment that as soon we can depend from Qt 5.14 we should remove this incubator and use QQmlComponent::createWithInitialProperties instead

mart requested changes to this revision.Apr 1 2020, 9:31 AM
This revision now requires changes to proceed.Apr 1 2020, 9:31 AM
masonm updated this revision to Diff 79059.Apr 1 2020, 3:11 PM
  • Rename variable and add comment
mart accepted this revision.Apr 1 2020, 3:41 PM
This revision is now accepted and ready to land.Apr 1 2020, 3:41 PM
This revision was automatically updated to reflect the committed changes.