From c7ee522c05ce3ff1e369471ac44da1d77644e7cc Mon Sep 17 00:00:00 2001 From: David Redondo Date: Tue, 9 Jun 2020 13:03:53 +0200 Subject: [PATCH] Prevent delegates and scrollbar overlapping in combobox popups Attached scrollbar is positioned inside the ListView, use a ScrollView instead --- org.kde.desktop/ComboBox.qml | 37 +++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/org.kde.desktop/ComboBox.qml b/org.kde.desktop/ComboBox.qml index c54958e..9d68855 100644 --- a/org.kde.desktop/ComboBox.qml +++ b/org.kde.desktop/ComboBox.qml @@ -32,7 +32,7 @@ T.ComboBox { rightPadding: controlRoot.editable && !controlRoot.mirrored ? 24 : padding delegate: ItemDelegate { - width: controlRoot.popup.width + width: listView.width text: controlRoot.textRole ? (Array.isArray(controlRoot.model) ? modelData[controlRoot.textRole] : model[controlRoot.textRole]) : modelData highlighted: mouseArea.pressed ? listView.currentIndex == index : controlRoot.highlightedIndex == index property bool separatorVisible: false @@ -205,22 +205,25 @@ T.ComboBox { // like ApplicationWindow, which we don't want. Controls.Overlay.modal: Item { } - contentItem: ListView { - id: listView - - // this causes us to load at least one delegate - // this is essential in guessing the contentHeight - // which is needed to initially resize the popup - cacheBuffer: 1 - - implicitHeight: contentHeight - model: controlRoot.delegateModel - delegate: controlRoot.delegate - currentIndex: controlRoot.highlightedIndex - highlightRangeMode: ListView.ApplyRange - highlightMoveDuration: 0 - boundsBehavior: Flickable.StopAtBounds - T.ScrollBar.vertical: Controls.ScrollBar { } + contentItem: ScrollView { + background: Rectangle {} + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ListView { + id: listView + + // this causes us to load at least one delegate + // this is essential in guessing the contentHeight + // which is needed to initially resize the popup + cacheBuffer: 1 + + implicitHeight: contentHeight + model: controlRoot.delegateModel + delegate: controlRoot.delegate + currentIndex: controlRoot.highlightedIndex + highlightRangeMode: ListView.ApplyRange + highlightMoveDuration: 0 + boundsBehavior: Flickable.StopAtBounds + } } background: Kirigami.ShadowedRectangle { anchors { -- GitLab