mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 07:48:59 +08:00
Fix Profile (application-)menu and add separators to profiles dropdown
CURA-1585
This commit is contained in:
parent
03914674c7
commit
a2def606c6
@ -226,7 +226,26 @@ UM.MainWindow
|
||||
Instantiator
|
||||
{
|
||||
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
|
||||
|
||||
Loader {
|
||||
@ -239,13 +258,13 @@ UM.MainWindow
|
||||
{
|
||||
//Insert a separator between readonly and custom profiles
|
||||
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);
|
||||
separatorIndex = index;
|
||||
}
|
||||
}
|
||||
//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:
|
||||
{
|
||||
@ -269,20 +288,10 @@ UM.MainWindow
|
||||
{
|
||||
id: item
|
||||
text: model_data ? model_data.name : ""
|
||||
checkable: true;
|
||||
checked: model_data ? model_data.active : false;
|
||||
exclusiveGroup: profileMenuGroup;
|
||||
onTriggered:
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
checkable: true
|
||||
checked: Cura.MachineManager.activeQualityId == model_data.id
|
||||
exclusiveGroup: profileMenuGroup
|
||||
onTriggered: Cura.MachineManager.setActiveQuality(model_data.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,13 +88,13 @@ Item{
|
||||
{
|
||||
//Insert a separator between readonly and custom profiles
|
||||
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);
|
||||
separatorIndex = index;
|
||||
}
|
||||
}
|
||||
//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:
|
||||
{
|
||||
@ -117,20 +117,10 @@ Item{
|
||||
{
|
||||
id: item
|
||||
text: model_data ? model_data.name : ""
|
||||
checkable: true;
|
||||
checkable: true
|
||||
checked: Cura.MachineManager.activeQualityId == model_data.id
|
||||
exclusiveGroup: profileSelectionMenuGroup;
|
||||
onTriggered:
|
||||
{
|
||||
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);
|
||||
}*/
|
||||
}
|
||||
onTriggered: Cura.MachineManager.setActiveQuality(model_data.id)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user