Improved expansion behavior

Contributes to CURA-5682

- Active material is now expanded by default when opening the manager

- Expanded and collapsed sections are saved to preferences

- Sections are now highlighted when collapsed and having a selected material inside

- Bug with losing focus between fields is not yet fixed
This commit is contained in:
Ian Paschal 2018-09-05 17:16:06 +02:00
parent f1d2d7ed36
commit 9e56d6d29f
7 changed files with 119 additions and 34 deletions

View file

@ -13,14 +13,24 @@ import Cura 1.0 as Cura
Rectangle
{
id: brand_section
property var expanded: base.collapsed_brands.indexOf(model.name) > -1
property var expanded: base.expanded_brands.indexOf(model.name) > -1
property var types_model: model.material_types
height: childrenRect.height
width: parent.width
Rectangle
{
id: brand_header_background
color: UM.Theme.getColor("favorites_header_bar")
color:
{
if(!expanded && model.name == base.current_brand)
{
return UM.Theme.getColor("favorites_row_selected")
}
else
{
return UM.Theme.getColor("favorites_header_bar")
}
}
anchors.fill: brand_header
}
Row
@ -69,19 +79,20 @@ Rectangle
anchors.fill: brand_header
onPressed:
{
const i = base.collapsed_brands.indexOf(model.name)
const i = base.expanded_brands.indexOf(model.name)
if (i > -1)
{
// Remove it
base.collapsed_brands.splice(i, 1)
base.expanded_brands.splice(i, 1)
brand_section.expanded = false
}
else
{
// Add it
base.collapsed_brands.push(model.name)
base.expanded_brands.push(model.name)
brand_section.expanded = true
}
UM.Preferences.setValue("cura/expanded_brands", base.expanded_brands.join(";"));
}
}
Column
@ -97,4 +108,12 @@ Rectangle
delegate: MaterialsTypeSection {}
}
}
Connections {
target: UM.Preferences
onPreferenceChanged:
{
expanded = base.expanded_brands.indexOf(model.name) > -1
}
}
}