RibbonTabBar: Fix the fold bug of TabBar.
Fix the problem that the TabBar does not fold when clicking the corresponding button after sliding to the specified interface.
This commit is contained in:
parent
b17ad7f434
commit
eb9d4bed5f
|
@ -219,14 +219,14 @@ Item{
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
for (let i=0,sign=0; i < stack.contentData.length; i++)
|
for (let i=0,sign=0; i < stack.contentData.length; i++)
|
||||||
{
|
{
|
||||||
var item = stack.contentData[i]
|
let item = stack.contentData[i]
|
||||||
if(item instanceof RibbonTabPage){
|
if(item instanceof RibbonTabPage){
|
||||||
let btn = ribbonTabButton.createObject(bar,{text:qsTr(item.title),index:i})
|
let btn = ribbonTabButton.createObject(bar,{text:qsTr(item.title),index:sign})
|
||||||
if (sign===0)
|
if (sign===0)
|
||||||
{
|
{
|
||||||
btn.checked = true
|
btn.checked = true
|
||||||
sign++
|
|
||||||
}
|
}
|
||||||
|
sign++
|
||||||
btn.need_fold.connect(hide_stack)
|
btn.need_fold.connect(hide_stack)
|
||||||
root.foldedChanged.connect(function(){btn.setFolded(folded)})
|
root.foldedChanged.connect(function(){btn.setFolded(folded)})
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,10 +68,28 @@ TabButton {
|
||||||
}
|
}
|
||||||
width: implicitWidth + 15
|
width: implicitWidth + 15
|
||||||
height: implicitHeight + 6
|
height: implicitHeight + 6
|
||||||
|
Timer{
|
||||||
|
id: timer
|
||||||
|
property bool first_run: true
|
||||||
|
interval: 200
|
||||||
|
triggeredOnStart: false
|
||||||
|
onTriggered: need_fold(checked&&!folded, index)
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
|
timer.running = false
|
||||||
need_fold(checked&&!folded, index)
|
need_fold(checked&&!folded, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onCheckedChanged: {
|
||||||
|
if (checked&&!(timer.first_run&&index===0))
|
||||||
|
{
|
||||||
|
timer.start()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
timer.first_run = false
|
||||||
|
}
|
||||||
|
|
||||||
function setFolded(value)
|
function setFolded(value)
|
||||||
{
|
{
|
||||||
folded = value
|
folded = value
|
||||||
|
|
Loading…
Reference in New Issue