Use Controls2 ListView instead of ScrollView for print job list

No need for a ScrollView in Controls 2. And specialise the scroll bar.
Be sure to also align the right side of the contents with the scroll bar though.

Contributes to issue CURA-8686.
This commit is contained in:
Ghostkeeper 2022-01-18 17:27:51 +01:00
parent f808f5f545
commit 85d0749f5f
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -1,8 +1,8 @@
// Copyright (c) 2019 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.2 import QtQuick 2.2
import QtQuick.Controls 1.4 import QtQuick.Controls 2.15
import UM 1.5 as UM import UM 1.5 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
@ -22,7 +22,7 @@ Item
id: queuedLabel id: queuedLabel
anchors anchors
{ {
left: queuedPrintJobs.left left: printJobList.left
top: parent.top top: parent.top
} }
font: UM.Theme.getFont("large") font: UM.Theme.getFont("large")
@ -34,7 +34,7 @@ Item
id: manageQueueLabel id: manageQueueLabel
anchors anchors
{ {
right: queuedPrintJobs.right right: printJobList.right
verticalCenter: queuedLabel.verticalCenter verticalCenter: queuedLabel.verticalCenter
} }
height: 18 * screenScaleFactor // TODO: Theme! height: 18 * screenScaleFactor // TODO: Theme!
@ -78,7 +78,7 @@ Item
id: printJobQueueHeadings id: printJobQueueHeadings
anchors anchors
{ {
left: queuedPrintJobs.left left: printJobList.left
leftMargin: UM.Theme.getSize("narrow_margin").width leftMargin: UM.Theme.getSize("narrow_margin").width
top: queuedLabel.bottom top: queuedLabel.bottom
topMargin: 24 * screenScaleFactor // TODO: Theme! topMargin: 24 * screenScaleFactor // TODO: Theme!
@ -121,41 +121,42 @@ Item
} }
} }
ScrollView ListView
{ {
id: queuedPrintJobs id: printJobList
anchors anchors
{ {
bottom: parent.bottom bottom: parent.bottom
horizontalCenter: parent.horizontalCenter horizontalCenter: parent.horizontalCenter
top: printJobQueueHeadings.bottom top: printJobQueueHeadings.bottom
topMargin: 12 * screenScaleFactor // TODO: Theme! topMargin: UM.Theme.getSize("default_margin").width
} }
style: UM.Theme.styles.scrollview
width: parent.width width: parent.width
ListView ScrollBar.vertical: UM.ScrollBar
{ {
id: printJobList id: printJobScrollBar
anchors.fill: parent }
delegate: MonitorPrintJobCard spacing: UM.Theme.getSize("narrow_margin").width
clip: true
delegate: MonitorPrintJobCard
{
anchors
{ {
anchors left: parent.left
{ right: parent.right
left: parent.left rightMargin: printJobScrollBar.width
right: parent.right
}
printJob: modelData
} }
model: printJob: modelData
}
model:
{
if (OutputDevice.receivedData)
{ {
if (OutputDevice.receivedData) return OutputDevice.queuedPrintJobs
{
return OutputDevice.queuedPrintJobs
}
return [null, null]
} }
spacing: 6 // TODO: Theme! return [null, null]
} }
} }
} }