mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Make the popup in the printer selector resizable depending on the
contents. Also there is a maximum height that will fit 9 printers. Contributes to CURA-5942.
This commit is contained in:
parent
67dc415b58
commit
a3bcdaf3b6
3 changed files with 89 additions and 70 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Layouts 1.1
|
import QtQuick.Layouts 1.1
|
||||||
import QtQuick.Controls 1.4
|
import QtQuick.Controls 1.4
|
||||||
|
|
|
@ -82,87 +82,24 @@ Cura.ExpandableComponent
|
||||||
{
|
{
|
||||||
id: popup
|
id: popup
|
||||||
width: UM.Theme.getSize("machine_selector_widget_content").width
|
width: UM.Theme.getSize("machine_selector_widget_content").width
|
||||||
height: UM.Theme.getSize("machine_selector_widget_content").height
|
|
||||||
|
|
||||||
ScrollView
|
ScrollView
|
||||||
{
|
{
|
||||||
id: scroll
|
id: scroll
|
||||||
width: parent.width
|
width: parent.width
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.bottom: separator.top
|
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
Column
|
MachineSelectorList
|
||||||
{
|
{
|
||||||
id: column
|
|
||||||
|
|
||||||
// Can't use parent.width since the parent is the flickable component and not the ScrollView
|
// Can't use parent.width since the parent is the flickable component and not the ScrollView
|
||||||
width: scroll.width - 2 * UM.Theme.getSize("default_lining").width
|
width: scroll.width - 2 * UM.Theme.getSize("default_lining").width
|
||||||
x: UM.Theme.getSize("default_lining").width
|
x: UM.Theme.getSize("default_lining").width
|
||||||
|
property real maximumHeight: UM.Theme.getSize("machine_selector_widget_content").height - buttonRow.height
|
||||||
|
|
||||||
Label
|
onHeightChanged:
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Network connected printers")
|
scroll.height = Math.min(height, maximumHeight)
|
||||||
visible: networkedPrintersModel.items.length > 0
|
popup.height = scroll.height + buttonRow.height
|
||||||
leftPadding: UM.Theme.getSize("default_margin").width
|
|
||||||
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
font: UM.Theme.getFont("medium")
|
|
||||||
color: UM.Theme.getColor("text_medium")
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater
|
|
||||||
{
|
|
||||||
id: networkedPrinters
|
|
||||||
|
|
||||||
model: UM.ContainerStacksModel
|
|
||||||
{
|
|
||||||
id: networkedPrintersModel
|
|
||||||
filter: {"type": "machine", "um_network_key": "*", "hidden": "False"}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: MachineSelectorButton
|
|
||||||
{
|
|
||||||
text: model.metadata["connect_group_name"]
|
|
||||||
checked: Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
|
|
||||||
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
|
||||||
|
|
||||||
Connections
|
|
||||||
{
|
|
||||||
target: Cura.MachineManager
|
|
||||||
onActiveMachineNetworkGroupNameChanged: checked = Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Label
|
|
||||||
{
|
|
||||||
text: catalog.i18nc("@label", "Preset printers")
|
|
||||||
visible: virtualPrintersModel.items.length > 0
|
|
||||||
leftPadding: UM.Theme.getSize("default_margin").width
|
|
||||||
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
|
|
||||||
renderType: Text.NativeRendering
|
|
||||||
font: UM.Theme.getFont("medium")
|
|
||||||
color: UM.Theme.getColor("text_medium")
|
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
}
|
|
||||||
|
|
||||||
Repeater
|
|
||||||
{
|
|
||||||
id: virtualPrinters
|
|
||||||
|
|
||||||
model: UM.ContainerStacksModel
|
|
||||||
{
|
|
||||||
id: virtualPrintersModel
|
|
||||||
filter: {"type": "machine", "um_network_key": null}
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: MachineSelectorButton
|
|
||||||
{
|
|
||||||
text: model.name
|
|
||||||
checked: Cura.MachineManager.activeMachineId == model.id
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +108,7 @@ Cura.ExpandableComponent
|
||||||
{
|
{
|
||||||
id: separator
|
id: separator
|
||||||
|
|
||||||
anchors.bottom: buttonRow.top
|
anchors.top: scroll.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: UM.Theme.getSize("default_lining").height
|
height: UM.Theme.getSize("default_lining").height
|
||||||
color: UM.Theme.getColor("lining")
|
color: UM.Theme.getColor("lining")
|
||||||
|
@ -181,7 +118,8 @@ Cura.ExpandableComponent
|
||||||
{
|
{
|
||||||
id: buttonRow
|
id: buttonRow
|
||||||
|
|
||||||
anchors.bottom: parent.bottom
|
// The separator is inside the buttonRow. This is to avoid some weird behaviours with the scroll bar.
|
||||||
|
anchors.top: separator.top
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
padding: UM.Theme.getSize("default_margin").width
|
padding: UM.Theme.getSize("default_margin").width
|
||||||
spacing: UM.Theme.getSize("default_margin").width
|
spacing: UM.Theme.getSize("default_margin").width
|
||||||
|
|
78
resources/qml/PrinterSelector/MachineSelectorList.qml
Normal file
78
resources/qml/PrinterSelector/MachineSelectorList.qml
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
// Copyright (c) 2018 Ultimaker B.V.
|
||||||
|
// Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
|
import QtQuick 2.7
|
||||||
|
import QtQuick.Controls 2.3
|
||||||
|
|
||||||
|
import UM 1.2 as UM
|
||||||
|
import Cura 1.0 as Cura
|
||||||
|
|
||||||
|
Column
|
||||||
|
{
|
||||||
|
id: machineSelectorList
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@label", "Network connected printers")
|
||||||
|
visible: networkedPrintersModel.items.length > 0
|
||||||
|
leftPadding: UM.Theme.getSize("default_margin").width
|
||||||
|
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
font: UM.Theme.getFont("medium")
|
||||||
|
color: UM.Theme.getColor("text_medium")
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater
|
||||||
|
{
|
||||||
|
id: networkedPrinters
|
||||||
|
|
||||||
|
model: UM.ContainerStacksModel
|
||||||
|
{
|
||||||
|
id: networkedPrintersModel
|
||||||
|
filter: {"type": "machine", "um_network_key": "*", "hidden": "False"}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: MachineSelectorButton
|
||||||
|
{
|
||||||
|
text: model.metadata["connect_group_name"]
|
||||||
|
checked: Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
|
||||||
|
outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: Cura.MachineManager
|
||||||
|
onActiveMachineNetworkGroupNameChanged: checked = Cura.MachineManager.activeMachineNetworkGroupName == model.metadata["connect_group_name"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@label", "Preset printers")
|
||||||
|
visible: virtualPrintersModel.items.length > 0
|
||||||
|
leftPadding: UM.Theme.getSize("default_margin").width
|
||||||
|
height: visible ? contentHeight + 2 * UM.Theme.getSize("default_margin").height : 0
|
||||||
|
renderType: Text.NativeRendering
|
||||||
|
font: UM.Theme.getFont("medium")
|
||||||
|
color: UM.Theme.getColor("text_medium")
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
|
Repeater
|
||||||
|
{
|
||||||
|
id: virtualPrinters
|
||||||
|
|
||||||
|
model: UM.ContainerStacksModel
|
||||||
|
{
|
||||||
|
id: virtualPrintersModel
|
||||||
|
filter: {"type": "machine", "um_network_key": null}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate: MachineSelectorButton
|
||||||
|
{
|
||||||
|
text: model.name
|
||||||
|
checked: Cura.MachineManager.activeMachineId == model.id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue