Merge pull request #4986 from Ultimaker/CURA-6028_preview_stage_doesnt_switch

Cura 6028 preview stage doesnt switch
This commit is contained in:
Diego Prado Gesto 2018-12-13 16:47:22 +01:00 committed by GitHub
commit d435f21193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 11 deletions

View File

@ -54,16 +54,23 @@ Item
{ {
text: model.name.toUpperCase() text: model.name.toUpperCase()
checkable: true checkable: true
checked: model.active checked: model.id == UM.Controller.activeStage.stageId
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
exclusiveGroup: mainWindowHeaderMenuGroup exclusiveGroup: mainWindowHeaderMenuGroup
style: UM.Theme.styles.main_window_header_tab style: UM.Theme.styles.main_window_header_tab
height: UM.Theme.getSize("main_window_header_button").height height: UM.Theme.getSize("main_window_header_button").height
onClicked: UM.Controller.setActiveStage(model.id)
iconSource: model.stage.iconSource iconSource: model.stage.iconSource
property color overlayColor: "transparent" property color overlayColor: "transparent"
property string overlayIconSource: "" property string overlayIconSource: ""
// This is a trick to assure the activeStage is correctly changed. It doesn't work propertly if done in the onClicked (see CURA-6028)
MouseArea
{
anchors.fill: parent
onClicked: UM.Controller.setActiveStage(model.id)
}
} }
} }

View File

@ -39,6 +39,7 @@ Item
{ {
target: Cura.QualityProfilesDropDownMenuModel target: Cura.QualityProfilesDropDownMenuModel
onItemsChanged: qualityModel.update() onItemsChanged: qualityModel.update()
onDataChanged: qualityModel.update()
} }
Connections { Connections {

View File

@ -14,24 +14,28 @@ Cura.ExpandablePopup
contentPadding: UM.Theme.getSize("default_lining").width contentPadding: UM.Theme.getSize("default_lining").width
contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft contentAlignment: Cura.ExpandablePopup.ContentAlignment.AlignLeft
property var viewModel: UM.ViewModel { } property var viewModel: UM.ViewModel
{
onDataChanged: updateActiveView()
}
property var activeView: property var activeView: null
function updateActiveView()
{ {
for (var i = 0; i < viewModel.count; i++) for (var index in viewModel.items)
{ {
if (viewModel.items[i].active) if (viewModel.items[index].active)
{ {
return viewModel.items[i] activeView = viewModel.items[index]
return
} }
} }
return null activeView = null
} }
Component.onCompleted: Component.onCompleted:
{ {
// Nothing was active, so just return the first one (the list is sorted by priority, so the most
// important one should be returned)
if (activeView == null) if (activeView == null)
{ {
UM.Controller.setActiveView(viewModel.getItem(0).id) UM.Controller.setActiveView(viewModel.getItem(0).id)