From cdc9ece474682c6651890713d2950de46f2855be Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 10 Mar 2016 11:57:47 +0100 Subject: [PATCH] Show separator between readonly profiles and custom profiles in profiles menu and sidebar profiles dropdown Contributes to CURA-855 --- resources/qml/Cura.qml | 42 +++++++++++++++++++++++++--------- resources/qml/ProfileSetup.qml | 36 +++++++++++++++++++++-------- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 279a9180e0..0bc7ad6a90 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -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; } diff --git a/resources/qml/ProfileSetup.qml b/resources/qml/ProfileSetup.qml index 62d37e8ed3..4365fe21ab 100644 --- a/resources/qml/ProfileSetup.qml +++ b/resources/qml/ProfileSetup.qml @@ -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 {