Fix Profile (application-)menu and add separators to profiles dropdown

CURA-1585
This commit is contained in:
fieldOfView 2016-06-06 17:10:56 +02:00
parent 03914674c7
commit a2def606c6
2 changed files with 30 additions and 31 deletions

View File

@ -226,7 +226,26 @@ UM.MainWindow
Instantiator Instantiator
{ {
id: profileMenuInstantiator id: profileMenuInstantiator
// model: UM.ProfilesModel {} model: UM.InstanceContainersModel
{
filter:
{
var result = { "type": "quality" };
if(Cura.MachineManager.filterQualityByMachine)
{
result.definition = Cura.MachineManager.activeDefinitionId;
if(Cura.MachineManager.hasMaterials)
{
result.material = Cura.MachineManager.activeMaterialId;
}
}
else
{
result.definition = "fdmprinter"
}
return result
}
}
property int separatorIndex: -1 property int separatorIndex: -1
Loader { Loader {
@ -239,13 +258,13 @@ UM.MainWindow
{ {
//Insert a separator between readonly and custom profiles //Insert a separator between readonly and custom profiles
if(separatorIndex < 0 && index > 0) { if(separatorIndex < 0 && index > 0) {
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) { if(model.getItem(index-1).metadata.read_only != model.getItem(index).metadata.read_only) {
profileMenu.insertSeparator(index); profileMenu.insertSeparator(index);
separatorIndex = index; separatorIndex = index;
} }
} }
//Because of the separator, custom profiles move one index lower //Because of the separator, custom profiles move one index lower
profileMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item); profileMenu.insertItem((model.getItem(index).metadata.read_only) ? index : index + 1, object.item);
} }
onObjectRemoved: onObjectRemoved:
{ {
@ -269,20 +288,10 @@ UM.MainWindow
{ {
id: item id: item
text: model_data ? model_data.name : "" text: model_data ? model_data.name : ""
checkable: true; checkable: true
checked: model_data ? model_data.active : false; checked: Cura.MachineManager.activeQualityId == model_data.id
exclusiveGroup: profileMenuGroup; exclusiveGroup: profileMenuGroup
onTriggered: onTriggered: Cura.MachineManager.setActiveQuality(model_data.id)
{
UM.MachineManager.setActiveProfile(model_data.name);
if (!model_data.active) {
//Selecting a profile was canceled; undo menu selection
profileMenuInstantiator.model.setProperty(model_index, "active", false);
var activeProfileName = UM.MachineManager.activeProfile;
var activeProfileIndex = profileMenuInstantiator.model.find("name", activeProfileName);
profileMenuInstantiator.model.setProperty(activeProfileIndex, "active", true);
}
}
} }
} }

View File

@ -88,13 +88,13 @@ Item{
{ {
//Insert a separator between readonly and custom profiles //Insert a separator between readonly and custom profiles
if(separatorIndex < 0 && index > 0) { if(separatorIndex < 0 && index > 0) {
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) { if(model.getItem(index-1).metadata.read_only != model.getItem(index).metadata.read_only) {
profileSelectionMenu.insertSeparator(index); profileSelectionMenu.insertSeparator(index);
separatorIndex = index; separatorIndex = index;
} }
} }
//Because of the separator, custom profiles move one index lower //Because of the separator, custom profiles move one index lower
profileSelectionMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item); profileSelectionMenu.insertItem((model.getItem(index).metadata.read_only) ? index : index + 1, object.item);
} }
onObjectRemoved: onObjectRemoved:
{ {
@ -117,20 +117,10 @@ Item{
{ {
id: item id: item
text: model_data ? model_data.name : "" text: model_data ? model_data.name : ""
checkable: true; checkable: true
checked: Cura.MachineManager.activeQualityId == model_data.id checked: Cura.MachineManager.activeQualityId == model_data.id
exclusiveGroup: profileSelectionMenuGroup; exclusiveGroup: profileSelectionMenuGroup;
onTriggered: onTriggered: Cura.MachineManager.setActiveQuality(model_data.id)
{
Cura.MachineManager.setActiveQuality(model_data.id);
/*if (!model_data.active) {
//Selecting a profile was canceled; undo menu selection
profileSelectionInstantiator.model.setProperty(model_index, "active", false);
var activeProfileName = UM.MachineManager.activeProfile;
var activeProfileIndex = profileSelectionInstantiator.model.find("name", activeProfileName);
profileSelectionInstantiator.model.setProperty(activeProfileIndex, "active", true);
}*/
}
} }
} }