From cc65bc821368ae935fd0d005d4b4b9d3fbb55b20 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Wed, 18 Sep 2019 17:05:00 +0200 Subject: [PATCH] Fix scrollbar for object selector --- resources/qml/Cura.qml | 1 - resources/qml/ObjectSelector.qml | 65 +++++++++++++------------------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 4c143dcf0b..828d8854dd 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -447,7 +447,6 @@ UM.MainWindow target: Cura.Actions.addProfile onTriggered: { - preferences.show(); preferences.setPage(4); // Create a new profile after a very short delay so the preference page has time to initiate diff --git a/resources/qml/ObjectSelector.qml b/resources/qml/ObjectSelector.qml index 9bf0e18809..6757863e1c 100644 --- a/resources/qml/ObjectSelector.qml +++ b/resources/qml/ObjectSelector.qml @@ -78,7 +78,7 @@ Item id: contents width: parent.width visible: objectSelector.opened - height: visible ? scroll.height : 0 + height: visible ? listView.height : 0 color: UM.Theme.getColor("main_background") border.width: UM.Theme.getSize("default_lining").width border.color: UM.Theme.getColor("lining") @@ -87,50 +87,39 @@ Item anchors.bottom: parent.bottom - ScrollView + ListView { - id: scroll - width: parent.width + id: listView clip: true - padding: UM.Theme.getSize("default_lining").width - - contentItem: ListView + anchors { - id: listView + left: parent.left + right: parent.right + margins: UM.Theme.getSize("default_lining").width + } - // Can't use parent.width since the parent is the flickable component and not the ScrollView - width: scroll.width - scroll.leftPadding - scroll.rightPadding - property real maximumHeight: UM.Theme.getSize("objects_menu_size").height + ScrollBar.vertical: ScrollBar + { + hoverEnabled: true + } - // We use an extra property here, since we only want to to be informed about the content size changes. - onContentHeightChanged: + property real maximumHeight: UM.Theme.getSize("objects_menu_size").height + + height: Math.min(contentHeight, maximumHeight) + + model: Cura.ObjectsModel {} + + delegate: ObjectItemButton + { + id: modelButton + Binding { - // It can sometimes happen that (due to animations / updates) the contentHeight is -1. - // This can cause a bunch of updates to trigger oneother, leading to a weird loop. - if(contentHeight >= 0) - { - scroll.height = Math.min(contentHeight, maximumHeight) + scroll.topPadding + scroll.bottomPadding - } - } - - Component.onCompleted: - { - scroll.height = Math.min(contentHeight, maximumHeight) + scroll.topPadding + scroll.bottomPadding - } - model: Cura.ObjectsModel {} - - delegate: ObjectItemButton - { - id: modelButton - Binding - { - target: modelButton - property: "checked" - value: model.selected - } - text: model.name - width: listView.width + target: modelButton + property: "checked" + value: model.selected } + text: model.name + width: listView.width } } }