mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 06:03:57 -06:00
Removed separators from profilesmodel
Profile menu now inserts separators in QML CURA-855
This commit is contained in:
parent
e5a5cffe7d
commit
2e5868cb82
2 changed files with 57 additions and 25 deletions
|
@ -215,26 +215,42 @@ UM.MainWindow
|
||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
id: profileMenuInstantiator
|
id: profileMenuInstantiator
|
||||||
model: UM.ProfilesModel { addSeparators: true }
|
model: UM.ProfilesModel {}
|
||||||
|
property int separatorIndex: -1
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
property QtObject model_data: model
|
property QtObject model_data: model
|
||||||
property int model_index: index
|
property int model_index: index
|
||||||
sourceComponent: model.separator ? profileMenuSeparatorDelegate : profileMenuItemDelegate
|
sourceComponent: profileMenuItemDelegate
|
||||||
|
}
|
||||||
|
|
||||||
|
onObjectAdded:
|
||||||
|
{
|
||||||
|
//Insert a separator between readonly and custom profiles
|
||||||
|
if(separatorIndex < 0 && index > 0) {
|
||||||
|
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) {
|
||||||
|
profileMenu.addSeparator();
|
||||||
|
separatorIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Because of the separator, custom profiles move one index lower
|
||||||
|
profileMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item);
|
||||||
|
}
|
||||||
|
onObjectRemoved:
|
||||||
|
{
|
||||||
|
//When adding a profile, the menu is rebuild by removing all items.
|
||||||
|
//If a separator was added, we need to remove that too.
|
||||||
|
if(separatorIndex >= 0)
|
||||||
|
{
|
||||||
|
profileMenu.removeItem(profileMenu.items[separatorIndex])
|
||||||
|
separatorIndex = -1;
|
||||||
|
}
|
||||||
|
profileMenu.removeItem(object.item);
|
||||||
}
|
}
|
||||||
onObjectAdded: profileMenu.insertItem(index, object.item)
|
|
||||||
onObjectRemoved: profileMenu.removeItem(object.item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ExclusiveGroup { id: profileMenuGroup; }
|
ExclusiveGroup { id: profileMenuGroup; }
|
||||||
|
|
||||||
Component
|
|
||||||
{
|
|
||||||
id: profileMenuSeparatorDelegate
|
|
||||||
MenuSeparator {
|
|
||||||
id: item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Component
|
Component
|
||||||
{
|
{
|
||||||
id: profileMenuItemDelegate
|
id: profileMenuItemDelegate
|
||||||
|
@ -259,7 +275,7 @@ UM.MainWindow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { id: profileMenuSeparator }
|
||||||
|
|
||||||
MenuItem { action: actions.addProfile; }
|
MenuItem { action: actions.addProfile; }
|
||||||
MenuItem { action: actions.manageProfiles; }
|
MenuItem { action: actions.manageProfiles; }
|
||||||
|
|
|
@ -51,23 +51,40 @@ Item{
|
||||||
Instantiator
|
Instantiator
|
||||||
{
|
{
|
||||||
id: profileSelectionInstantiator
|
id: profileSelectionInstantiator
|
||||||
model: UM.ProfilesModel { addSeparators: true }
|
model: UM.ProfilesModel {}
|
||||||
|
property int separatorIndex: -1
|
||||||
|
|
||||||
Loader {
|
Loader {
|
||||||
property QtObject model_data: model
|
property QtObject model_data: model
|
||||||
property int model_index: index
|
property int model_index: index
|
||||||
sourceComponent: model.separator ? menuSeparatorDelegate : menuItemDelegate
|
sourceComponent: menuItemDelegate
|
||||||
|
}
|
||||||
|
onObjectAdded:
|
||||||
|
{
|
||||||
|
//Insert a separator between readonly and custom profiles
|
||||||
|
if(separatorIndex < 0 && index > 0) {
|
||||||
|
if(model.getItem(index-1).readOnly != model.getItem(index).readOnly) {
|
||||||
|
profileSelectionMenu.addSeparator();
|
||||||
|
separatorIndex = index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//Because of the separator, custom profiles move one index lower
|
||||||
|
profileSelectionMenu.insertItem((model.getItem(index).readOnly) ? index : index + 1, object.item);
|
||||||
|
}
|
||||||
|
onObjectRemoved:
|
||||||
|
{
|
||||||
|
//When adding a profile, the menu is rebuild by removing all items.
|
||||||
|
//If a separator was added, we need to remove that too.
|
||||||
|
if(separatorIndex >= 0)
|
||||||
|
{
|
||||||
|
profileSelectionMenu.removeItem(profileSelectionMenu.items[separatorIndex])
|
||||||
|
separatorIndex = -1;
|
||||||
|
}
|
||||||
|
profileSelectionMenu.removeItem(object.item);
|
||||||
}
|
}
|
||||||
onObjectAdded: profileSelectionMenu.insertItem(index, object.item)
|
|
||||||
onObjectRemoved: profileSelectionMenu.removeItem(object.item)
|
|
||||||
}
|
}
|
||||||
ExclusiveGroup { id: profileSelectionMenuGroup; }
|
ExclusiveGroup { id: profileSelectionMenuGroup; }
|
||||||
Component
|
|
||||||
{
|
|
||||||
id: menuSeparatorDelegate
|
|
||||||
MenuSeparator {
|
|
||||||
id: item
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Component
|
Component
|
||||||
{
|
{
|
||||||
id: menuItemDelegate
|
id: menuItemDelegate
|
||||||
|
@ -92,7 +109,6 @@ Item{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
MenuItem {
|
MenuItem {
|
||||||
action: base.addProfileAction;
|
action: base.addProfileAction;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue