From 6752a184350ddc0126aa8788f1d092201353ac92 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 7 Nov 2016 14:02:19 +0100 Subject: [PATCH 1/3] Add dialog to set number of copies when duplicating models --- cura/CuraApplication.py | 3 +- resources/qml/Cura.qml | 9 +++- resources/qml/MultiplyObjectOptions.qml | 66 +++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 resources/qml/MultiplyObjectOptions.qml diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 59e5a15f71..532a60b58c 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -686,10 +686,9 @@ class CuraApplication(QtApplication): while current_node.getParent() and current_node.getParent().callDecoration("isGroup"): current_node = current_node.getParent() - new_node = copy.deepcopy(current_node) - op = GroupedOperation() for _ in range(count): + new_node = copy.deepcopy(current_node) op.addOperation(AddSceneNodeOperation(new_node, current_node.getParent())) op.push() diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 021178e6db..5380eaf7ca 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -605,6 +605,11 @@ UM.MainWindow } } + MultiplyObjectOptions + { + id: multiplyObjectOptions + } + Connections { target: Cura.Actions.multiplyObject @@ -612,7 +617,9 @@ UM.MainWindow { if(objectContextMenu.objectId != 0) { - Printer.multiplyObject(objectContextMenu.objectId, 1); + multiplyObjectOptions.objectId = objectContextMenu.objectId; + multiplyObjectOptions.visible = true; + multiplyObjectOptions.reset(); objectContextMenu.objectId = 0; } } diff --git a/resources/qml/MultiplyObjectOptions.qml b/resources/qml/MultiplyObjectOptions.qml new file mode 100644 index 0000000000..a55d7e0cdc --- /dev/null +++ b/resources/qml/MultiplyObjectOptions.qml @@ -0,0 +1,66 @@ +// Copyright (c) 2015 Ultimaker B.V. +// Cura is released under the terms of the AGPLv3 or higher. + +import QtQuick 2.2 +import QtQuick.Controls 1.1 +import QtQuick.Window 2.1 + +import UM 1.1 as UM + +UM.Dialog +{ + id: base + + //: Dialog title + title: catalog.i18nc("@title:window", "Duplicate Model") + + minimumWidth: 400 * Screen.devicePixelRatio + minimumHeight: 80 * Screen.devicePixelRatio + width: minimumWidth + height: minimumHeight + + property int objectId: 0; + onAccepted: Printer.multiplyObject(base.objectId, parseInt(copiesField.text)) + + property variant catalog: UM.I18nCatalog { name: "cura" } + + signal reset() + onReset: { + copiesField.text = "1"; + copiesField.selectAll(); + copiesField.focus = true; + } + + Row + { + spacing: UM.Theme.getSize("default_margin").width + + Label { + text: "Number of copies:" + anchors.verticalCenter: copiesField.verticalCenter + } + + TextField { + id: copiesField + validator: RegExpValidator { regExp: /^\d{0,2}/ } + maximumLength: 2 + } + } + + + rightButtons: + [ + Button + { + text: catalog.i18nc("@action:button","OK") + onClicked: base.accept() + enabled: base.objectId != 0 && parseInt(copiesField.text) > 0 + }, + Button + { + text: catalog.i18nc("@action:button","Cancel") + onClicked: base.reject() + } + ] +} + From 0ce4b5f2de7b7c61d439fbfa520059b18da37843 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Mon, 7 Nov 2016 14:07:06 +0100 Subject: [PATCH 2/3] Add "..." to Duplicate Model menu entry to indicate there is a dialog --- resources/qml/Actions.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index e88b7e77ea..d03070d7e7 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -232,7 +232,7 @@ Item Action { id: multiplyObjectAction; - text: catalog.i18nc("@action:inmenu","&Duplicate Model"); + text: catalog.i18nc("@action:inmenu","&Duplicate Model..."); iconName: "edit-duplicate" } From eeff3b65ec972031d99b06580b50e57cc1d8cb44 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Wed, 9 Nov 2016 09:27:44 +0100 Subject: [PATCH 3/3] Change wording from "duplicate" to "multiply" --- resources/qml/Actions.qml | 2 +- resources/qml/MultiplyObjectOptions.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index d03070d7e7..043552d768 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -232,7 +232,7 @@ Item Action { id: multiplyObjectAction; - text: catalog.i18nc("@action:inmenu","&Duplicate Model..."); + text: catalog.i18nc("@action:inmenu","&Multiply Model..."); iconName: "edit-duplicate" } diff --git a/resources/qml/MultiplyObjectOptions.qml b/resources/qml/MultiplyObjectOptions.qml index a55d7e0cdc..7756ab074b 100644 --- a/resources/qml/MultiplyObjectOptions.qml +++ b/resources/qml/MultiplyObjectOptions.qml @@ -12,7 +12,7 @@ UM.Dialog id: base //: Dialog title - title: catalog.i18nc("@title:window", "Duplicate Model") + title: catalog.i18nc("@title:window", "Multiply Model") minimumWidth: 400 * Screen.devicePixelRatio minimumHeight: 80 * Screen.devicePixelRatio