From d8a88739a6e15497dca4979320bdfb9ac146e11f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 2 Jun 2023 13:51:43 +0200 Subject: [PATCH] Ensure that menu items for extruder are added to right spot in context menu Fixes CURA-10649 --- resources/qml/Menus/ContextMenu.qml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/resources/qml/Menus/ContextMenu.qml b/resources/qml/Menus/ContextMenu.qml index 65f3409c8a..f7029939cd 100644 --- a/resources/qml/Menus/ContextMenu.qml +++ b/resources/qml/Menus/ContextMenu.qml @@ -44,8 +44,19 @@ Cura.Menu onTriggered: CuraActions.setExtruderForSelection(model.id) shortcut: "Ctrl+" + (model.index + 1) } - // Add it to the fifth position (and above) as we want it to be added after the extruder header. - onObjectAdded: function(index, object) { base.insertItem(index + 5, object) } + + onObjectAdded: function(index, object) { + var extruder_header_location = 5; + // Find the location of the extruder header and insert it below that. + for (var i = 0; i < base.count; i++) + { + if(base.itemAt(i) === extruderHeader) + { + extruder_header_location = i + 1; + } + } + base.insertItem(extruder_header_location + index, object) + } onObjectRemoved: function(index, object) { base.removeItem(object) } }