mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-13 09:47:50 -06:00
Remove extra ScrollView and customise ListView instead
Contributes to issue CURA-8686.
This commit is contained in:
parent
5b76cf5689
commit
f1db69a36a
1 changed files with 67 additions and 80 deletions
|
@ -1,4 +1,4 @@
|
||||||
// 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.10
|
import QtQuick 2.10
|
||||||
|
@ -17,7 +17,7 @@ Item
|
||||||
id: base
|
id: base
|
||||||
height: networkPrinterInfo.height + controlsRectangle.height
|
height: networkPrinterInfo.height + controlsRectangle.height
|
||||||
|
|
||||||
property alias maxItemCountAtOnce: networkPrinterScrollView.maxItemCountAtOnce
|
property alias maxItemCountAtOnce: networkPrinterListView.maxItemCountAtOnce
|
||||||
property var currentItem: (networkPrinterListView.currentIndex >= 0)
|
property var currentItem: (networkPrinterListView.currentIndex >= 0)
|
||||||
? networkPrinterListView.model[networkPrinterListView.currentIndex]
|
? networkPrinterListView.model[networkPrinterListView.currentIndex]
|
||||||
: null
|
: null
|
||||||
|
@ -29,7 +29,7 @@ Item
|
||||||
Item
|
Item
|
||||||
{
|
{
|
||||||
id: networkPrinterInfo
|
id: networkPrinterInfo
|
||||||
height: networkPrinterScrollView.visible ? networkPrinterScrollView.height : noPrinterLabel.height
|
height: networkPrinterListView.visible ? networkPrinterListView.height : noPrinterLabel.height
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
@ -44,35 +44,37 @@ Item
|
||||||
visible: networkPrinterListView.count == 0 // Do not show if there are discovered devices.
|
visible: networkPrinterListView.count == 0 // Do not show if there are discovered devices.
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollView
|
|
||||||
{
|
|
||||||
id: networkPrinterScrollView
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.right: parent.right
|
|
||||||
|
|
||||||
ScrollBar.horizontal.policy: ScrollBar.AsNeeded
|
|
||||||
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
|
||||||
|
|
||||||
property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll.
|
|
||||||
height: Math.min(contentHeight, (maxItemCountAtOnce * UM.Theme.getSize("action_button").height) - UM.Theme.getSize("default_margin").height)
|
|
||||||
|
|
||||||
visible: networkPrinterListView.count > 0
|
|
||||||
|
|
||||||
clip: true
|
|
||||||
|
|
||||||
ListView
|
ListView
|
||||||
{
|
{
|
||||||
id: networkPrinterListView
|
id: networkPrinterListView
|
||||||
anchors.fill: parent
|
anchors.top: parent.top
|
||||||
|
anchors.left: parent.left
|
||||||
|
anchors.right: parent.right
|
||||||
|
height: Math.min(contentHeight, (maxItemCountAtOnce * UM.Theme.getSize("action_button").height) - UM.Theme.getSize("default_margin").height)
|
||||||
|
|
||||||
|
ScrollBar.vertical: UM.ScrollBar
|
||||||
|
{
|
||||||
|
id: networkPrinterScrollBar
|
||||||
|
}
|
||||||
|
clip: true
|
||||||
|
property int maxItemCountAtOnce: 8 // show at max 8 items at once, otherwise you need to scroll.
|
||||||
|
visible: networkPrinterListView.count > 0
|
||||||
|
|
||||||
model: contentLoader.enabled ? CuraApplication.getDiscoveredPrintersModel().discoveredPrinters: undefined
|
model: contentLoader.enabled ? CuraApplication.getDiscoveredPrintersModel().discoveredPrinters: undefined
|
||||||
|
cacheBuffer: 1000000 // Set a large cache to effectively just cache every list item.
|
||||||
|
|
||||||
section.property: "modelData.sectionName"
|
section.property: "modelData.sectionName"
|
||||||
section.criteria: ViewSection.FullString
|
section.criteria: ViewSection.FullString
|
||||||
section.delegate: sectionHeading
|
section.delegate: UM.Label
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
{
|
||||||
flickDeceleration: 20000 // To prevent the flicking behavior.
|
anchors.left: parent.left
|
||||||
cacheBuffer: 1000000 // Set a large cache to effectively just cache every list item.
|
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||||
|
anchors.right: networkPrinterScrollBar.left
|
||||||
|
anchors.rightMargin: UM.Theme.getSize("default_margin").width
|
||||||
|
height: UM.Theme.getSize("setting_control").height
|
||||||
|
text: section
|
||||||
|
color: UM.Theme.getColor("small_button_text")
|
||||||
|
}
|
||||||
|
|
||||||
Component.onCompleted:
|
Component.onCompleted:
|
||||||
{
|
{
|
||||||
|
@ -100,25 +102,11 @@ Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component
|
|
||||||
{
|
|
||||||
id: sectionHeading
|
|
||||||
|
|
||||||
UM.Label
|
|
||||||
{
|
|
||||||
anchors.left: parent.left
|
|
||||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
|
||||||
height: UM.Theme.getSize("setting_control").height
|
|
||||||
text: section
|
|
||||||
color: UM.Theme.getColor("small_button_text")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: Cura.MachineSelectorButton
|
delegate: Cura.MachineSelectorButton
|
||||||
{
|
{
|
||||||
text: modelData.device.name
|
text: modelData.device.name
|
||||||
|
|
||||||
width: networkPrinterListView.width
|
width: networkPrinterListView.width - networkPrinterScrollBar.width
|
||||||
outputDevice: modelData.device
|
outputDevice: modelData.device
|
||||||
|
|
||||||
enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup
|
enabled: !modelData.isUnknownMachineType && modelData.isHostOfGroup
|
||||||
|
@ -137,11 +125,10 @@ Item
|
||||||
}
|
}
|
||||||
|
|
||||||
checkable: false
|
checkable: false
|
||||||
selected: ListView.view.currentIndex == model.index
|
selected: networkPrinterListView.currentIndex == model.index
|
||||||
onClicked:
|
onClicked:
|
||||||
{
|
{
|
||||||
ListView.view.currentIndex = index
|
networkPrinterListView.currentIndex = index
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue