mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-01 00:04:27 +08:00

For that I needed to get rid of the IconLabel component, since in this case the color of the icon and the text is the same (and it makes sense)
176 lines
5.7 KiB
QML
176 lines
5.7 KiB
QML
// 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
|
|
|
|
Cura.ExpandableComponent
|
|
{
|
|
id: machineSelector
|
|
|
|
property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
|
|
property bool isPrinterConnected: Cura.MachineManager.printerConnected
|
|
property var outputDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
|
|
|
|
popupPadding: UM.Theme.getSize("default_lining").width
|
|
popupAlignment: Cura.ExpandableComponent.PopupAlignment.AlignLeft
|
|
iconSource: expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
|
|
|
|
UM.I18nCatalog
|
|
{
|
|
id: catalog
|
|
name: "cura"
|
|
}
|
|
|
|
headerItem: Item
|
|
{
|
|
implicitHeight: icon.height
|
|
|
|
UM.RecolorImage
|
|
{
|
|
id: icon
|
|
|
|
anchors.left: parent.left
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
source:
|
|
{
|
|
if (isNetworkPrinter)
|
|
{
|
|
if (machineSelector.outputDevice != null && machineSelector.outputDevice.clusterSize > 1)
|
|
{
|
|
return UM.Theme.getIcon("printer_group")
|
|
}
|
|
return UM.Theme.getIcon("printer_single")
|
|
}
|
|
return ""
|
|
}
|
|
width: UM.Theme.getSize("machine_selector_icon").width
|
|
height: width
|
|
|
|
color: UM.Theme.getColor("machine_selector_printer_icon")
|
|
visible: source != ""
|
|
}
|
|
|
|
Label
|
|
{
|
|
id: label
|
|
anchors.left: icon.visible ? icon.right : parent.left
|
|
anchors.right: parent.right
|
|
anchors.leftMargin: UM.Theme.getSize("thin_margin").width
|
|
anchors.verticalCenter: icon.verticalCenter
|
|
text: isNetworkPrinter ? Cura.MachineManager.activeMachineNetworkGroupName : Cura.MachineManager.activeMachineName
|
|
elide: Text.ElideRight
|
|
color: UM.Theme.getColor("text")
|
|
font: UM.Theme.getFont("medium")
|
|
renderType: Text.NativeRendering
|
|
}
|
|
|
|
UM.RecolorImage
|
|
{
|
|
anchors
|
|
{
|
|
bottom: parent.bottom
|
|
left: parent.left
|
|
leftMargin: UM.Theme.getSize("thick_margin").width
|
|
}
|
|
|
|
source: UM.Theme.getIcon("printer_connected")
|
|
width: UM.Theme.getSize("printer_status_icon").width
|
|
height: UM.Theme.getSize("printer_status_icon").height
|
|
|
|
color: UM.Theme.getColor("primary")
|
|
visible: isNetworkPrinter && isPrinterConnected
|
|
|
|
// Make a themable circle in the background so we can change it in other themes
|
|
Rectangle
|
|
{
|
|
id: iconBackground
|
|
anchors.centerIn: parent
|
|
// Make it a bit bigger so there is an outline
|
|
width: parent.width + 2 * UM.Theme.getSize("default_lining").width
|
|
height: parent.height + 2 * UM.Theme.getSize("default_lining").height
|
|
radius: Math.round(width / 2)
|
|
color: UM.Theme.getColor("main_background")
|
|
z: parent.z - 1
|
|
}
|
|
}
|
|
}
|
|
|
|
popupItem: Item
|
|
{
|
|
id: popup
|
|
width: UM.Theme.getSize("machine_selector_widget_content").width
|
|
|
|
ScrollView
|
|
{
|
|
id: scroll
|
|
width: parent.width
|
|
clip: true
|
|
leftPadding: UM.Theme.getSize("default_lining").width
|
|
rightPadding: UM.Theme.getSize("default_lining").width
|
|
|
|
MachineSelectorList
|
|
{
|
|
// 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("machine_selector_widget_content").height - buttonRow.height
|
|
|
|
onHeightChanged:
|
|
{
|
|
scroll.height = Math.min(height, maximumHeight)
|
|
popup.height = scroll.height + buttonRow.height
|
|
}
|
|
}
|
|
}
|
|
|
|
Rectangle
|
|
{
|
|
id: separator
|
|
|
|
anchors.top: scroll.bottom
|
|
width: parent.width
|
|
height: UM.Theme.getSize("default_lining").height
|
|
color: UM.Theme.getColor("lining")
|
|
}
|
|
|
|
Row
|
|
{
|
|
id: buttonRow
|
|
|
|
// 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
|
|
padding: UM.Theme.getSize("default_margin").width
|
|
spacing: UM.Theme.getSize("default_margin").width
|
|
|
|
Cura.SecondaryButton
|
|
{
|
|
leftPadding: UM.Theme.getSize("default_margin").width
|
|
rightPadding: UM.Theme.getSize("default_margin").width
|
|
text: catalog.i18nc("@button", "Add printer")
|
|
onClicked:
|
|
{
|
|
togglePopup()
|
|
Cura.Actions.addMachine.trigger()
|
|
}
|
|
}
|
|
|
|
Cura.SecondaryButton
|
|
{
|
|
leftPadding: UM.Theme.getSize("default_margin").width
|
|
rightPadding: UM.Theme.getSize("default_margin").width
|
|
text: catalog.i18nc("@button", "Manage printers")
|
|
onClicked:
|
|
{
|
|
togglePopup()
|
|
Cura.Actions.configureMachines.trigger()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|