Cura/resources/qml/Menus/ConfigurationMenu/ConfigurationItem.qml
Ghostkeeper 0a75c772ed
Unrevert new icon set for all of Cura's interface
We created a new set of icons for Cura. These icons had to be reverted though because they weren't working out in the interface for the last release yet.
This unreverts them, basically adding them back hoping that we'll get them fixed in time for the next release.

Contributes to issue CURA-8342.

Revert "Revert "Fix merge conflict""

This reverts commit bb20e3307f43edc1ff53cb154d2351ddfe39e158.

Revert "Revert "Merge pull request #9716 from Ultimaker/CURA-8010_new_icons""

This reverts commit 70e4e9640e561e18a12870f30c905203ce8ccee7.

Revert "Revert "Fix typo in icon name""

This reverts commit 38ce22ba7c3f40b971bc6e1e0a8e776ca9d51512.

Revert "Revert "Add list for deprecated icons""

This reverts commit 119a957e7f978dbf1ddbcb3b0005bf38e8fed943.

Revert "Revert "Add Function icon""

This reverts commit 760726cf0bb953bb1b0fc277b448f419d4bd2544.

Revert "Revert "Switch out inherit icon""

This reverts commit 26afff609381e2004d194c280f504b6226859bd3.

Revert "Revert "Merge branch 'CURA-8205_Introduce_new_icons_in_Cura' of github.com:Ultimaker/Cura""

This reverts commit 6483db3d47ee052c1a966cdee3af7190577a5769.

Revert "Fix incorrect icons"

This reverts commit 02a4ade2a50a943ff36fd4895bdc9261cf2133eb.
2021-06-28 17:16:56 +02:00

242 lines
8.2 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.0
import UM 1.2 as UM
import Cura 1.0 as Cura
Button
{
id: configurationItem
property var configuration: null
hoverEnabled: isValidMaterial
property bool isValidMaterial:
{
if (configuration === null)
{
return false
}
var extruderConfigurations = configuration.extruderConfigurations
for (var index in extruderConfigurations)
{
var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : ""
if (name == "" || name == "Unknown")
{
return false
}
}
return true
}
background: Rectangle
{
color: parent.hovered ? UM.Theme.getColor("action_button_hovered") : UM.Theme.getColor("action_button")
border.color: parent.checked ? UM.Theme.getColor("primary") : UM.Theme.getColor("lining")
border.width: UM.Theme.getSize("default_lining").width
radius: UM.Theme.getSize("default_radius").width
}
contentItem: Column
{
id: contentColumn
width: parent.width
padding: UM.Theme.getSize("default_margin").width
spacing: UM.Theme.getSize("narrow_margin").height
Row
{
id: extruderRow
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("default_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("wide_margin").width
}
height: childrenRect.height
spacing: UM.Theme.getSize("default_margin").width
Repeater
{
id: repeater
model: configuration !== null ? configuration.extruderConfigurations: null
width: parent.width
delegate: PrintCoreConfiguration
{
width: Math.round(parent.width / (configuration !== null ? configuration.extruderConfigurations.length : 1))
printCoreConfiguration: modelData
visible: configurationItem.isValidMaterial
}
}
// Unknown material
Item
{
id: unknownMaterial
height: unknownMaterialMessage.height + UM.Theme.getSize("thin_margin").width / 2
width: parent.width
anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("thin_margin").width / 2
visible: !configurationItem.isValidMaterial
UM.RecolorImage
{
id: icon
anchors.verticalCenter: unknownMaterialMessage.verticalCenter
source: UM.Theme.getIcon("Warning")
color: UM.Theme.getColor("warning")
width: UM.Theme.getSize("section_icon").width
height: width
}
Label
{
id: unknownMaterialMessage
text:
{
if (configuration === null)
{
return ""
}
var extruderConfigurations = configuration.extruderConfigurations
var unknownMaterials = []
for (var index in extruderConfigurations)
{
var name = extruderConfigurations[index].material ? extruderConfigurations[index].material.name : ""
if (name == "" || name == "Unknown")
{
var materialType = extruderConfigurations[index].material.type
if (extruderConfigurations[index].material.type == "")
{
materialType = "Unknown"
}
var brand = extruderConfigurations[index].material.brand
if (brand == "")
{
brand = "Unknown"
}
name = materialType + " (" + brand + ")"
unknownMaterials.push(name)
}
}
unknownMaterials = "<b>" + unknownMaterials + "</b>"
var draftResult = catalog.i18nc("@label", "This configuration is not available because %1 is not recognized. Please visit %2 to download the correct material profile.");
var result = draftResult.arg(unknownMaterials).arg("<a href=' '>" + catalog.i18nc("@label","Marketplace") + "</a> ")
return result
}
width: extruderRow.width
anchors.left: icon.right
anchors.right: unknownMaterial.right
anchors.leftMargin: UM.Theme.getSize("wide_margin").height
anchors.top: unknownMaterial.top
wrapMode: Text.WordWrap
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
verticalAlignment: Text.AlignVCenter
linkColor: UM.Theme.getColor("text_link")
onLinkActivated:
{
Cura.Actions.browsePackages.trigger()
}
}
MouseArea
{
anchors.fill: parent
cursorShape: unknownMaterialMessage.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
acceptedButtons: Qt.NoButton
}
}
}
//Buildplate row separator
Rectangle
{
id: separator
visible: buildplateInformation.visible
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("wide_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("wide_margin").width
}
height: visible ? Math.round(UM.Theme.getSize("default_lining").height / 2) : 0
color: UM.Theme.getColor("lining")
}
Item
{
id: buildplateInformation
anchors
{
left: parent.left
leftMargin: UM.Theme.getSize("wide_margin").width
right: parent.right
rightMargin: UM.Theme.getSize("wide_margin").width
}
height: childrenRect.height
visible: configuration !== null && configuration.buildplateConfiguration != "" && false //Buildplate is disabled as long as we have no printers that properly support buildplate swapping (so we can't test).
// Show the type of buildplate. The first letter is capitalized
Cura.IconWithText
{
id: buildplateLabel
source: UM.Theme.getIcon("buildplate")
text:
{
if (configuration === null)
{
return ""
}
return configuration.buildplateConfiguration.charAt(0).toUpperCase() + configuration.buildplateConfiguration.substr(1)
}
anchors.left: parent.left
}
}
}
Connections
{
target: Cura.MachineManager
function onCurrentConfigurationChanged()
{
configurationItem.checked = Cura.MachineManager.matchesConfiguration(configuration)
}
}
Component.onCompleted:
{
configurationItem.checked = Cura.MachineManager.matchesConfiguration(configuration)
}
onClicked:
{
if(isValidMaterial)
{
toggleContent()
Cura.MachineManager.applyRemoteConfiguration(configuration)
}
}
}