ColumnView: don't set visible to false on remove
When we set the visibility of the item we removed, the item could still be on the screen, thus lead to unnecessary re-drawing.
ColumnView
is used by PageRow
internally, if we call pop
on PageRow
, the current Page's visible
will be set to false. If the popped page is a fairly complicate page, for example a ScrollablePage with a large ListView
, the UI will freeze for seconds.
Ideally, the visibility should be set to false when it won't trigger re-drawing. But I've yet to find where the place is.
Reproducible example:
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami
import org.kde.kcm 1.2 as KCM
Kirigami.ApplicationWindow {
id: root
pageStack.initialPage: rootPage
KCM.ScrollViewKCM {
visible: false
id: rootPage
view: ListView {
model: ["page1", "page2"]
delegate: Kirigami.BasicListItem {
highlighted: false
hoverEnabled: false
text: modelData
reserveSpaceForSubtitle: true
trailing: Item {
implicitWidth: changeButton.implicitWidth
QQC2.Button {
id: changeButton
anchors.centerIn: parent
text: "goto page"
onClicked: {
if (modelData === "page1") {
root.pageStack.push(page1);
} else {
root.pageStack.push(page2);
}
}
}
}
}
}
KCM.ScrollViewKCM {
id: page1
title: "page1"
}
KCM.ScrollViewKCM {
id: page2
title: "page2"
header: QQC2.Button {
text: "back"
onClicked: root.pageStack.pop()
}
view: ListView {
id: localeListView
clip: true
model: 1000
delegate: Kirigami.BasicListItem {
icon: "system-reboot"
}
}
}
}
}
Without this patch, go to page2, click back
will freeze the UI for a sec, after apply this patch, the page pops instantly.
Edited by Ghost User