Cura/resources/qml/Preferences/Materials/MaterialsBrandSection.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 bb20e3307f.

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

This reverts commit 70e4e9640e.

Revert "Revert "Fix typo in icon name""

This reverts commit 38ce22ba7c.

Revert "Revert "Add list for deprecated icons""

This reverts commit 119a957e7f.

Revert "Revert "Add Function icon""

This reverts commit 760726cf0b.

Revert "Revert "Switch out inherit icon""

This reverts commit 26afff6093.

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

This reverts commit 6483db3d47.

Revert "Fix incorrect icons"

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

147 lines
4.1 KiB
QML

// Copyright (c) 2019 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
import QtQuick.Dialogs 1.2
import UM 1.2 as UM
import Cura 1.0 as Cura
// An expandable list of materials. Includes both the header (this file) and the items (brandMaterialList)
Item
{
id: brand_section
property var sectionName: ""
property var elementsModel // This can be a MaterialTypesModel or GenericMaterialsModel or FavoriteMaterialsModel
property var hasMaterialTypes: true // It indicates wheather it has material types or not
property var expanded: materialList.expandedBrands.indexOf(sectionName) > -1
height: childrenRect.height
width: parent.width
Rectangle
{
id: brand_header_background
color:
{
if(!expanded && sectionName == materialList.currentBrand)
{
return UM.Theme.getColor("favorites_row_selected")
}
else
{
return UM.Theme.getColor("favorites_header_bar")
}
}
anchors.fill: brand_header
}
Row
{
id: brand_header
width: parent.width
Label
{
id: brand_name
text: sectionName
height: UM.Theme.getSize("favorites_row").height
width: parent.width - UM.Theme.getSize("favorites_button").width
verticalAlignment: Text.AlignVCenter
leftPadding: (UM.Theme.getSize("default_margin").width / 2) | 0
}
Item
{
implicitWidth: UM.Theme.getSize("favorites_button").width
implicitHeight: UM.Theme.getSize("favorites_button").height
UM.RecolorImage
{
anchors
{
verticalCenter: parent.verticalCenter
horizontalCenter: parent.horizontalCenter
}
width: UM.Theme.getSize("standard_arrow").width
height: UM.Theme.getSize("standard_arrow").height
color: "black"
source: brand_section.expanded ? UM.Theme.getIcon("ChevronSingleDown") : UM.Theme.getIcon("ChevronSingleLeft")
}
}
}
MouseArea
{
anchors.fill: brand_header
onPressed:
{
const i = materialList.expandedBrands.indexOf(sectionName)
if (i > -1)
{
// Remove it
materialList.expandedBrands.splice(i, 1)
brand_section.expanded = false
}
else
{
// Add it
materialList.expandedBrands.push(sectionName)
brand_section.expanded = true
}
UM.Preferences.setValue("cura/expanded_brands", materialList.expandedBrands.join(";"));
}
}
Column
{
id: brandMaterialList
anchors.top: brand_header.bottom
width: parent.width
anchors.left: parent ? parent.left : undefined
height: brand_section.expanded ? childrenRect.height : 0
visible: brand_section.expanded
Repeater
{
model: elementsModel
delegate: Loader
{
id: loader
width: parent ? parent.width : 0
property var element: model
sourceComponent: hasMaterialTypes ? materialsTypeSection : materialSlot
}
}
}
Component
{
id: materialsTypeSection
MaterialsTypeSection
{
materialType: element
}
}
Component
{
id: materialSlot
MaterialsSlot
{
material: element
}
}
Connections
{
target: UM.Preferences
function onPreferenceChanged(preference)
{
if (preference !== "cura/expanded_types" && preference !== "cura/expanded_brands")
{
return;
}
expanded = materialList.expandedBrands.indexOf(sectionName) > -1
}
}
}