mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 15:44:04 -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
|
Instantiator
|
||||||
{
|
{
|
||||||
id: profileMenuInstantiator
|
id: profileMenuInstantiator
|
||||||
model: UM.ProfilesModel { }
|
model: UM.ProfilesModel { addSeparators: true }
|
||||||
MenuItem {
|
Loader {
|
||||||
text: model.name;
|
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;
|
checkable: true;
|
||||||
checked: model.active;
|
checked: model_data.active;
|
||||||
exclusiveGroup: profileMenuGroup;
|
exclusiveGroup: profileMenuGroup;
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
UM.MachineManager.setActiveProfile(model.name);
|
UM.MachineManager.setActiveProfile(model_data.name);
|
||||||
if (!model.active) {
|
if (!model_data.active) {
|
||||||
//Selecting a profile was canceled; undo menu selection
|
//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 activeProfileName = UM.MachineManager.activeProfile;
|
||||||
var activeProfileIndex = profileMenuInstantiator.model.find("name", activeProfileName);
|
var activeProfileIndex = profileMenuInstantiator.model.find("name", activeProfileName);
|
||||||
profileMenuInstantiator.model.setProperty(activeProfileIndex, "active", true);
|
profileMenuInstantiator.model.setProperty(activeProfileIndex, "active", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onObjectAdded: profileMenu.insertItem(index, object)
|
|
||||||
onObjectRemoved: profileMenu.removeItem(object)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExclusiveGroup { id: profileMenuGroup; }
|
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
|
|
||||||
MenuItem { action: actions.addProfile; }
|
MenuItem { action: actions.addProfile; }
|
||||||
|
|
|
@ -51,29 +51,47 @@ Item{
|
||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
id: profileSelectionInstantiator
|
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
|
MenuItem
|
||||||
{
|
{
|
||||||
text: model.name
|
id: item
|
||||||
|
text: model_data.name
|
||||||
checkable: true;
|
checkable: true;
|
||||||
checked: model.active;
|
checked: model_data.active;
|
||||||
exclusiveGroup: profileSelectionMenuGroup;
|
exclusiveGroup: profileSelectionMenuGroup;
|
||||||
onTriggered:
|
onTriggered:
|
||||||
{
|
{
|
||||||
UM.MachineManager.setActiveProfile(model.name);
|
UM.MachineManager.setActiveProfile(model_data.name);
|
||||||
if (!model.active) {
|
if (!model_data.active) {
|
||||||
//Selecting a profile was canceled; undo menu selection
|
//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 activeProfileName = UM.MachineManager.activeProfile;
|
||||||
var activeProfileIndex = profileSelectionInstantiator.model.find("name", activeProfileName);
|
var activeProfileIndex = profileSelectionInstantiator.model.find("name", activeProfileName);
|
||||||
profileSelectionInstantiator.model.setProperty(activeProfileIndex, "active", true);
|
profileSelectionInstantiator.model.setProperty(activeProfileIndex, "active", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onObjectAdded: profileSelectionMenu.insertItem(index, object)
|
|
||||||
onObjectRemoved: profileSelectionMenu.removeItem(object)
|
|
||||||
}
|
}
|
||||||
ExclusiveGroup { id: profileSelectionMenuGroup; }
|
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem {
|
MenuItem {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue