RibbonTabPage: Fix containerItem read empty issue.

This commit is contained in:
Mentalflow 2025-05-29 15:36:40 +08:00
parent 8d6dea6c5d
commit 3af821668e
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
4 changed files with 44 additions and 36 deletions

View File

@ -47,17 +47,15 @@ RibbonTabBar {
property var pushButtonLayout
onContainerItemUpdated: {
if(getItem(0)){
sliderLayout = getItem(0).sliderLayout
sliderWithBtn = getItem(0).sliderWithBtn
sliderWithoutBtn = getItem(0).sliderWithoutBtn
switchLayout = getItem(1).switchLayout
btnWithColorAndGrabberText = getItem(1).btnWithColorAndGrabberText
checkBoxLayout = getItem(2).checkBoxLayout
buttonLayout = getItem(3).buttonLayout
btnWithoutBgAndLabel = getItem(3).btnWithoutBgAndLabel
pushButtonLayout = getItem(4).pushButtonLayout
}
basic_page.sliderLayout = getItem(0).sliderLayout
basic_page.sliderWithBtn = getItem(0).sliderWithBtn
basic_page.sliderWithoutBtn = getItem(0).sliderWithoutBtn
basic_page.switchLayout = getItem(1).switchLayout
basic_page.btnWithColorAndGrabberText = getItem(1).btnWithColorAndGrabberText
basic_page.checkBoxLayout = getItem(2).checkBoxLayout
basic_page.buttonLayout = getItem(3).buttonLayout
basic_page.btnWithoutBgAndLabel = getItem(3).btnWithoutBgAndLabel
basic_page.pushButtonLayout = getItem(4).pushButtonLayout
}
RibbonTabGroup{
@ -333,10 +331,8 @@ RibbonTabBar {
property var lineEditWithIcon
onContainerItemUpdated: {
if(getItem(0)){
lineEditLayout = getItem(0).lineEditLayout
lineEditWithIcon = getItem(0).lineEditWithIcon
}
lineEditLayout = getItem(0).lineEditLayout
lineEditWithIcon = getItem(0).lineEditWithIcon
}
RibbonTabGroup{
@ -507,8 +503,7 @@ RibbonTabBar {
title: qsTr("Progress")
property var progressbarSlider
onContainerItemUpdated:{
if(getItem(0))
progressbarSlider = getItem(0).progressbarSlider
progress_page.progressbarSlider = getItem(0).progressbarSlider
}
RibbonTabGroup{
width: progressbar_slider.width + 30

View File

@ -47,17 +47,15 @@ RibbonTabBar {
property var pushButtonLayout
onContainerItemUpdated: {
if(getItem(0)){
sliderLayout = getItem(0).sliderLayout
sliderWithBtn = getItem(0).sliderWithBtn
sliderWithoutBtn = getItem(0).sliderWithoutBtn
switchLayout = getItem(1).switchLayout
btnWithColorAndGrabberText = getItem(1).btnWithColorAndGrabberText
checkBoxLayout = getItem(2).checkBoxLayout
buttonLayout = getItem(3).buttonLayout
btnWithoutBgAndLabel = getItem(3).btnWithoutBgAndLabel
pushButtonLayout = getItem(4).pushButtonLayout
}
basic_page.sliderLayout = getItem(0).sliderLayout
basic_page.sliderWithBtn = getItem(0).sliderWithBtn
basic_page.sliderWithoutBtn = getItem(0).sliderWithoutBtn
basic_page.switchLayout = getItem(1).switchLayout
basic_page.btnWithColorAndGrabberText = getItem(1).btnWithColorAndGrabberText
basic_page.checkBoxLayout = getItem(2).checkBoxLayout
basic_page.buttonLayout = getItem(3).buttonLayout
basic_page.btnWithoutBgAndLabel = getItem(3).btnWithoutBgAndLabel
basic_page.pushButtonLayout = getItem(4).pushButtonLayout
}
RibbonTabGroup{
@ -333,10 +331,8 @@ RibbonTabBar {
property var lineEditWithIcon
onContainerItemUpdated: {
if(getItem(0)){
lineEditLayout = getItem(0).lineEditLayout
lineEditWithIcon = getItem(0).lineEditWithIcon
}
lineEditLayout = getItem(0).lineEditLayout
lineEditWithIcon = getItem(0).lineEditWithIcon
}
RibbonTabGroup{
@ -507,8 +503,7 @@ RibbonTabBar {
title: QT_TRANSLATE_NOOP("RibbonTabBar", "Progress")
property var progressbarSlider
onContainerItemUpdated:{
if(getItem(0))
progressbarSlider = getItem(0).progressbarSlider
progress_page.progressbarSlider = getItem(0).progressbarSlider
}
RibbonTabGroup{
width: progressbar_slider.width + 30

View File

@ -28,6 +28,7 @@ Item {
active: control.needActive
anchors.fill: parent
asynchronous: true
property int loadedItem: 0
sourceComponent: Flickable{
id: view
property alias containerItem: container
@ -49,11 +50,19 @@ Item {
Layout.fillHeight: true
active: control.needActive
sourceComponent: control.delegateList[modelData.index].content
onLoaded: main_loader.loadedItem++
}
}
}
}
onLoaded: containerItemUpdated()
Timer{
running: main_loader.loadedItem === control.delegateCount && main_loader.loadedItem !==0
interval: 1
onTriggered: {
main_loader.loadedItem = 0
containerItemUpdated()
}
}
}
function getItem( index ){

View File

@ -28,6 +28,7 @@ Item {
active: control.needActive
anchors.fill: parent
asynchronous: true
property int loadedItem: 0
sourceComponent: Flickable{
id: view
property alias containerItem: container
@ -49,11 +50,19 @@ Item {
Layout.fillHeight: true
active: control.needActive
sourceComponent: control.delegateList[modelData.index].content
onLoaded: main_loader.loadedItem++
}
}
}
}
onLoaded: containerItemUpdated()
Timer{
running: main_loader.loadedItem === control.delegateCount && main_loader.loadedItem !==0
interval: 1
onTriggered: {
main_loader.loadedItem = 0
containerItemUpdated()
}
}
}
function getItem( index ){