mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-24 23:23:57 -06:00
Show separator between readonly profiles and custom profiles in profiles menu and sidebar profiles dropdown
Contributes to CURA-855
This commit is contained in:
parent
48a181d0b5
commit
cdc9ece474
2 changed files with 58 additions and 20 deletions
|
@ -215,30 +215,50 @@ UM.MainWindow
|
|||
Instantiator
|
||||
{
|
||||
id: profileMenuInstantiator
|
||||
model: UM.ProfilesModel { }
|
||||
MenuItem {
|
||||
text: model.name;
|
||||
model: UM.ProfilesModel { addSeparators: true }
|
||||
Loader {
|
||||
property QtObject model_data: model
|
||||
property int model_index: index
|
||||
sourceComponent: model.separator ? profileMenuSeparatorDelegate : profileMenuItemDelegate
|
||||
}
|
||||
onObjectAdded: profileMenu.insertItem(index, object.item)
|
||||
onObjectRemoved: profileMenu.removeItem(object.item)
|
||||
}
|
||||
|
||||
ExclusiveGroup { id: profileMenuGroup; }
|
||||
|
||||
Component
|
||||
{
|
||||
id: profileMenuSeparatorDelegate
|
||||
MenuSeparator {
|
||||
id: item
|
||||
}
|
||||
}
|
||||
|
||||
Component
|
||||
{
|
||||
id: profileMenuItemDelegate
|
||||
MenuItem
|
||||
{
|
||||
id: item
|
||||
text: model_data.name
|
||||
checkable: true;
|
||||
checked: model.active;
|
||||
checked: model_data.active;
|
||||
exclusiveGroup: profileMenuGroup;
|
||||
onTriggered:
|
||||
{
|
||||
UM.MachineManager.setActiveProfile(model.name);
|
||||
if (!model.active) {
|
||||
UM.MachineManager.setActiveProfile(model_data.name);
|
||||
if (!model_data.active) {
|
||||
//Selecting a profile was canceled; undo menu selection
|
||||
profileMenuInstantiator.model.setProperty(index, "active", false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
onObjectAdded: profileMenu.insertItem(index, object)
|
||||
onObjectRemoved: profileMenu.removeItem(object)
|
||||
}
|
||||
|
||||
ExclusiveGroup { id: profileMenuGroup; }
|
||||
|
||||
MenuSeparator { }
|
||||
|
||||
MenuItem { action: actions.addProfile; }
|
||||
|
|
|
@ -51,29 +51,47 @@ Item{
|
|||
Instantiator
|
||||
{
|
||||
id: profileSelectionInstantiator
|
||||
model: UM.ProfilesModel { }
|
||||
model: UM.ProfilesModel { addSeparators: true }
|
||||
Loader {
|
||||
property QtObject model_data: model
|
||||
property int model_index: index
|
||||
sourceComponent: model.separator ? menuSeparatorDelegate : menuItemDelegate
|
||||
}
|
||||
onObjectAdded: profileSelectionMenu.insertItem(index, object.item)
|
||||
onObjectRemoved: profileSelectionMenu.removeItem(object.item)
|
||||
}
|
||||
ExclusiveGroup { id: profileSelectionMenuGroup; }
|
||||
Component
|
||||
{
|
||||
id: menuSeparatorDelegate
|
||||
MenuSeparator {
|
||||
id: item
|
||||
}
|
||||
}
|
||||
Component
|
||||
{
|
||||
id: menuItemDelegate
|
||||
MenuItem
|
||||
{
|
||||
text: model.name
|
||||
id: item
|
||||
text: model_data.name
|
||||
checkable: true;
|
||||
checked: model.active;
|
||||
checked: model_data.active;
|
||||
exclusiveGroup: profileSelectionMenuGroup;
|
||||
onTriggered:
|
||||
{
|
||||
UM.MachineManager.setActiveProfile(model.name);
|
||||
if (!model.active) {
|
||||
UM.MachineManager.setActiveProfile(model_data.name);
|
||||
if (!model_data.active) {
|
||||
//Selecting a profile was canceled; undo menu selection
|
||||
profileSelectionInstantiator.model.setProperty(index, "active", false);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
onObjectAdded: profileSelectionMenu.insertItem(index, object)
|
||||
onObjectRemoved: profileSelectionMenu.removeItem(object)
|
||||
}
|
||||
ExclusiveGroup { id: profileSelectionMenuGroup; }
|
||||
|
||||
|
||||
MenuSeparator { }
|
||||
MenuItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue