RibbonTabPage: Use asynchronous load to improve RibbonTabBar's performance.
This commit is contained in:
parent
0e8c1fd2f5
commit
4793747c83
|
@ -4,12 +4,33 @@ import QtQuick.Layouts 1.11
|
|||
import RibbonUI 1.1
|
||||
|
||||
Item {
|
||||
id: control
|
||||
property int delegateCount: 0
|
||||
property string title
|
||||
default property alias content: container.data
|
||||
required default property Component content
|
||||
property bool needActive: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
|
||||
property var delegateList: []
|
||||
|
||||
readonly property var contentItem: main_loader.item.containerItem
|
||||
|
||||
signal containerItemUpdated()
|
||||
clip: true
|
||||
Flickable{
|
||||
id: view
|
||||
|
||||
onContentChanged: {
|
||||
delegateList.push({
|
||||
"content": content,
|
||||
"index": control.delegateCount++
|
||||
})
|
||||
}
|
||||
|
||||
Loader{
|
||||
id: main_loader
|
||||
active: control.needActive
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
sourceComponent: Flickable{
|
||||
id: view
|
||||
property alias containerItem: container
|
||||
ScrollIndicator.horizontal: RibbonScrollIndicator{
|
||||
anchors.bottom: view.bottom
|
||||
anchors.horizontalCenter: view.horizontalCenter
|
||||
|
@ -20,6 +41,23 @@ Item {
|
|||
id: container
|
||||
spacing: 0
|
||||
height: parent.height
|
||||
Repeater{
|
||||
model: control.delegateList
|
||||
Loader{
|
||||
required property var modelData
|
||||
width: item.width
|
||||
Layout.fillHeight: true
|
||||
active: control.needActive
|
||||
sourceComponent: control.delegateList[modelData.index].content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onLoaded: containerItemUpdated()
|
||||
}
|
||||
|
||||
function getItem( index : int ){
|
||||
return contentItem.children[index].item
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import RibbonUI
|
||||
|
||||
|
|
|
@ -4,12 +4,33 @@ import QtQuick.Layouts
|
|||
import RibbonUI
|
||||
|
||||
Item {
|
||||
id: control
|
||||
property int delegateCount: 0
|
||||
property string title
|
||||
default property alias content: container.data
|
||||
required default property Component content
|
||||
property bool needActive: SwipeView.isCurrentItem || SwipeView.isNextItem || SwipeView.isPreviousItem
|
||||
property var delegateList: []
|
||||
|
||||
readonly property var contentItem: main_loader.item.containerItem
|
||||
|
||||
signal containerItemUpdated()
|
||||
clip: true
|
||||
Flickable{
|
||||
id: view
|
||||
|
||||
onContentChanged: {
|
||||
delegateList.push({
|
||||
"content": content,
|
||||
"index": control.delegateCount++
|
||||
})
|
||||
}
|
||||
|
||||
Loader{
|
||||
id: main_loader
|
||||
active: control.needActive
|
||||
anchors.fill: parent
|
||||
asynchronous: true
|
||||
sourceComponent: Flickable{
|
||||
id: view
|
||||
property alias containerItem: container
|
||||
ScrollIndicator.horizontal: RibbonScrollIndicator{
|
||||
anchors.bottom: view.bottom
|
||||
anchors.horizontalCenter: view.horizontalCenter
|
||||
|
@ -20,6 +41,23 @@ Item {
|
|||
id: container
|
||||
spacing: 0
|
||||
height: parent.height
|
||||
Repeater{
|
||||
model: control.delegateList
|
||||
Loader{
|
||||
required property var modelData
|
||||
width: item.width
|
||||
Layout.fillHeight: true
|
||||
active: control.needActive
|
||||
sourceComponent: control.delegateList[modelData.index].content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onLoaded: containerItemUpdated()
|
||||
}
|
||||
|
||||
function getItem( index : int ){
|
||||
return contentItem.children[index].item
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue