123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- // Copyright (c) 2018 Ultimaker B.V.
- // Uranium 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
- Item
- {
- id: materialList
- UM.I18nCatalog { id: catalog; name: "cura"; }
- Cura.BrandMaterialsModel { id: materialsModel }
- Cura.GenericMaterialsModel { id: genericMaterialsModel }
- width: materialScrollView.width - 20
- height: childrenRect.height
- Column
- {
- Rectangle
- {
- height: 23
- width: materialList.width
- Label
- {
- text: "Generic"
- }
- }
- Repeater
- {
- model: genericMaterialsModel
- delegate: Rectangle
- {
- height: 23
- width: materialList.width
- color: "green"
- Label
- {
- text: model.name
- }
- }
- }
- Repeater
- {
- id: brand_list
- model: materialsModel
- delegate: Rectangle
- {
- id: brand_section
- property var expanded: true
- property var types_model: model.materials
- height: childrenRect.height
- width: parent.width
- Rectangle
- {
- id: brand_header_background
- color: "grey"
- anchors.fill: brand_header
- }
- Row
- {
- id: brand_header
- width: parent.width
- Label
- {
- id: brand_name
- text: model.name
- height: 24
- width: parent.width - 24
- verticalAlignment: Text.AlignVCenter
- leftPadding: 4
- }
- Button
- {
- text: ""
- implicitWidth: 24
- implicitHeight: 24
- UM.RecolorImage {
- anchors
- {
- verticalCenter: parent.verticalCenter
- horizontalCenter: parent.horizontalCenter
- }
- width: UM.Theme.getSize("standard_arrow").width
- height: UM.Theme.getSize("standard_arrow").height
- sourceSize.width: width
- sourceSize.height: height
- color: "black"
- source: brand_section.expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
- }
- style: ButtonStyle
- {
- background: Rectangle
- {
- anchors.fill: parent
- color: "transparent"
- }
- }
- }
- }
- MouseArea
- {
- anchors.fill: brand_header
- onPressed:
- {
- brand_section.expanded = !brand_section.expanded
- }
- }
- Column
- {
- anchors.top: brand_header.bottom
- width: parent.width - leftPadding
- anchors.left: parent.left
- leftPadding: 8
- height: brand_section.expanded ? childrenRect.height : 0
- visible: brand_section.expanded
- Repeater
- {
- model: types_model
- delegate: Rectangle
- {
- id: material_type_section
- property var expanded: true
- property var colors_model: model.colors
- height: childrenRect.height
- width: parent.width
- Rectangle
- {
- id: material_type_header_background
- color: "grey"
- anchors.bottom: material_type_header.bottom
- height: 1
- width: parent.width
- }
- Row
- {
- id: material_type_header
- width: parent.width
- Label
- {
- text: model.name
- height: 24
- width: parent.width - 24
- id: material_type_name
- verticalAlignment: Text.AlignVCenter
- }
- Button
- {
- text: ""
- implicitWidth: 24
- implicitHeight: 24
- UM.RecolorImage {
- anchors
- {
- verticalCenter: parent.verticalCenter
- horizontalCenter: parent.horizontalCenter
- }
- width: UM.Theme.getSize("standard_arrow").width
- height: UM.Theme.getSize("standard_arrow").height
- sourceSize.width: width
- sourceSize.height: height
- color: "black"
- source: material_type_section.expanded ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_left")
- }
- style: ButtonStyle
- {
- background: Rectangle
- {
- anchors.fill: parent
- color: "transparent"
- }
- }
- }
- }
- MouseArea
- {
- anchors.fill: material_type_header
- onPressed:
- {
- material_type_section.expanded = !material_type_section.expanded
- }
- }
- Column
- {
- height: material_type_section.expanded ? childrenRect.height : 0
- visible: material_type_section.expanded
- width: parent.width - leftPadding
- anchors.top: material_type_header.bottom
- leftPadding: 8
- anchors.left: parent.left
- Repeater
- {
- model: colors_model
- delegate: Rectangle
- {
- height: 24
- width: parent.width
- // color: "green"
- Row
- {
- height: parent.height
- width: parent.width
- Rectangle
- {
- id: swatch
- color: model.color_code
- border.width: 1
- border.color: "black"
- width: 14
- height: 14
- anchors.verticalCenter: parent.verticalCenter
- }
- Label
- {
- text: model.name
- verticalAlignment: Text.AlignVCenter
- height: 24
- anchors.left: swatch.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.leftMargin: 4
- }
- MouseArea
- {
- anchors.fill: parent
- onClicked:
- {
- print(model.guid)
- }
- }
- Button
- {
- text: "+"
- implicitWidth: 24
- implicitHeight: 24
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- onClicked:
- {
- if (model.is_favorite) {
- base.materialManager.removeFavorite(model.root_material_id)
- model.is_favorite = false
- return
- }
- base.materialManager.addFavorite(model.root_material_id)
- model.is_favorite = true
- return
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
|