Commit 81222c5f authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Add a page option to allow preloading a page

For certain pages, it is useful to be able to load the page as soon as
possible so graphs can already start collecting data. This adds an
option to the page configuration that specifies when to load a page -
either on demand on during startup. By default pages will still be
loaded on demand.

BUG: 440402
parent 5f0ee578
Pipeline #172238 passed with stage
in 1 minute and 43 seconds
......@@ -209,6 +209,7 @@ Kirigami.ScrollablePage {
margin = page.pageData.margin
pageData = page.pageData
actionsFace = page.pageData.actionsFace ? page.pageData.actionsFace : ""
loadType = page.pageData.loadType ? page.pageData.loadType : "ondemand"
}
onAccepted: {
......@@ -216,6 +217,7 @@ Kirigami.ScrollablePage {
pageData.icon = iconName
pageData.margin = margin
pageData.actionsFace = actionsFace
pageData.loadType = loadType
}
}
}
......@@ -253,7 +255,7 @@ Kirigami.ScrollablePage {
onStatusChanged: {
if (status == Loader.Loading) {
loadOverlay.opacity = 1
if (!edit) {
if (!edit && applicationWindow().pageStack.columnView.containsItem(page)) {
// Pop any pages that might have been opened during editing
applicationWindow().pageStack.pop(page)
}
......
......@@ -22,4 +22,10 @@ Kirigami.PagePoolAction {
initialProperties: {
"pageData": action.pageData
}
Component.onCompleted: {
if (pageData.loadType == "onstart") {
pagePool.loadPageWithProperties(page, initialProperties)
}
}
}
......@@ -26,6 +26,8 @@ Dialog {
property string actionsFace: "dummy" //Can't leave it empty, otherwise it doesn't update when it's initially set to an empty string
property alias pageData: facesModel.pageData
property string loadType: "ondemand"
modal: true
parent: Overlay.overlay
focus: true
......@@ -131,6 +133,26 @@ Dialog {
}
}
}
ComboBox {
Kirigami.FormData.label: i18nc("@label:listbox", "Load this page:")
textRole: "key"
currentIndex: {
for (var i in model) {
if (model[i].value == dialog.loadType) {
return i
}
}
}
model: [
{ value: "ondemand", key: i18nc("@item:inlistbox", "When needed") },
{ value: "onstart", key: i18nc("@item:inlistbox", "During application startup") }
]
onActivated: dialog.loadType = model[index].value
}
}
Kirigami.Separator { anchors { left: parent.left; right: parent.right; bottom: parent.bottom } }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment