Fix weird scrolling behavior in room list

You may have noticed that the room list acts a bit... odd. You usually
can't scroll all the way down with a scrollwheel, it just
stops. It's possible to continue a little bit more with the scrollbar.
And sometimes the scrollbar doesn't know how big it's actually supposed
to be, commonly occuring when switching from a large room list to a
smaller one.

I narrowed it down the same usual problem with views in QtQuick:
variable sized delegates! Using GammaRay I figured out that for the
delegates currently in use they're slightly different: 46 pixels for
regular room delegates, 42 pixels for section headers and the "Find your
Friends" button was also different.

*Technically* TableView (and by extension TreeView) is supposed to allow
variable-sized delegates, and we should be able to advertise that with
rowHeightProvider. I tried a bunch of different solutions and none of
them worked reliably, so I took the usual sledgehammer approach of
making all of the delegates the same size.

This fixes all of the obvious bugs with the room list I could see, with
the one visual downside of making the section headers slightly taller.
But since I spent some time improving the tap targets, this is only a
visual change and not a functional one.

I also made sure to test it in compact mode, and everything shrinks as
expected.
This commit is contained in:
Joshua Goins
2026-02-12 20:03:05 -05:00
parent 11f8407ef7
commit d47a4eb0de
2 changed files with 26 additions and 9 deletions

View File

@@ -6,8 +6,11 @@ import QtQuick.Controls as QQC2
import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.kirigamiaddons.delegates as Delegates
QQC2.ItemDelegate {
import org.kde.neochat
Delegates.RoundedItemDelegate {
id: root
required property TreeView treeView
@@ -36,29 +39,31 @@ QQC2.ItemDelegate {
Keys.onSpacePressed: root.treeView.toggleExpanded(row)
contentItem: Item {
implicitWidth: layout.implicitWidth
implicitHeight: layout.implicitHeight
implicitHeight: Math.max(layout.implicitHeight, Kirigami.Units.gridUnit + (NeoChatConfig.compactRoomList ? 0 : Kirigami.Units.largeSpacing * 2))
RowLayout {
id: layout
width: root.contentItem.width
anchors.fill: parent
spacing: 0
Kirigami.ListSectionHeader {
Layout.fillWidth: true
visible: !root.collapsed
horizontalPadding: 0
topPadding: 0
bottomPadding: 0
text: root.collapsed ? "" : root.displayName
onClicked: root.treeView.toggleExpanded(row)
onClicked: root.treeView.toggleExpanded(root.row)
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
}
QQC2.ToolButton {
id: collapseButton
Layout.alignment: Qt.AlignHCenter
Layout.alignment: Qt.AlignCenter
icon {
name: root.expanded ? "go-up" : "go-down"