Upgrade material list ScrollView to Controls2

Took some effort. This was a weird one. I had to manually set the contentHeight to the height of the contents. Perhaps the ScrollBar itself was messing with it?

Contributes to issue CURA-8686.
This commit is contained in:
Ghostkeeper 2022-01-18 19:01:22 +01:00
parent bb32f25b49
commit 52f5b91621
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -1,12 +1,13 @@
// Copyright (c) 2021 Ultimaker B.V. // Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher. // Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 1.4 import QtQuick.Controls 2.15
import QtQuick.Controls 1.4 as OldControls
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2 import QtQuick.Dialogs 1.2
import UM 1.2 as UM import UM 1.5 as UM
import Cura 1.5 as Cura import Cura 1.5 as Cura
Item Item
@ -102,7 +103,7 @@ Item
height: childrenRect.height height: childrenRect.height
// Activate button // Activate button
Button OldControls.Button
{ {
id: activateMenuButton id: activateMenuButton
text: catalog.i18nc("@action:button", "Activate") text: catalog.i18nc("@action:button", "Activate")
@ -120,7 +121,7 @@ Item
} }
// Create button // Create button
Button OldControls.Button
{ {
id: createMenuButton id: createMenuButton
text: catalog.i18nc("@action:button", "Create") text: catalog.i18nc("@action:button", "Create")
@ -135,7 +136,7 @@ Item
} }
// Duplicate button // Duplicate button
Button OldControls.Button
{ {
id: duplicateMenuButton id: duplicateMenuButton
text: catalog.i18nc("@action:button", "Duplicate"); text: catalog.i18nc("@action:button", "Duplicate");
@ -150,7 +151,7 @@ Item
} }
// Remove button // Remove button
Button OldControls.Button
{ {
id: removeMenuButton id: removeMenuButton
text: catalog.i18nc("@action:button", "Remove") text: catalog.i18nc("@action:button", "Remove")
@ -165,7 +166,7 @@ Item
} }
// Import button // Import button
Button OldControls.Button
{ {
id: importMenuButton id: importMenuButton
text: catalog.i18nc("@action:button", "Import") text: catalog.i18nc("@action:button", "Import")
@ -179,7 +180,7 @@ Item
} }
// Export button // Export button
Button OldControls.Button
{ {
id: exportMenuButton id: exportMenuButton
text: catalog.i18nc("@action:button", "Export") text: catalog.i18nc("@action:button", "Export")
@ -193,7 +194,7 @@ Item
} }
//Sync button. //Sync button.
Button OldControls.Button
{ {
id: syncMaterialsButton id: syncMaterialsButton
text: catalog.i18nc("@action:button Sending materials to printers", "Sync with Printers") text: catalog.i18nc("@action:button Sending materials to printers", "Sync with Printers")
@ -207,7 +208,8 @@ Item
} }
} }
Item { Item
{
id: contentsItem id: contentsItem
anchors anchors
{ {
@ -271,22 +273,26 @@ Item
bottom: parent.bottom bottom: parent.bottom
left: parent.left left: parent.left
} }
Rectangle
{
parent: viewport
anchors.fill: parent
color: palette.light
}
width: (parent.width * 0.4) | 0 width: (parent.width * 0.4) | 0
frameVisible: true
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff clip: true
ScrollBar.vertical: UM.ScrollBar
{
id: materialScrollBar
parent: materialScrollView
anchors
{
top: parent.top
right: parent.right
bottom: parent.bottom
}
}
contentHeight: materialListView.height //For some reason, this is not determined automatically with this ScrollView. Very weird!
MaterialsList MaterialsList
{ {
id: materialListView id: materialListView
width: materialScrollView.viewport.width width: materialScrollView.width - materialScrollBar.width
} }
} }