Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ContextMenu.qml « Menus « qml « resources - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 65f3409c8afeb8b7f5aaef4fde41184a64202d83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.2
import QtQuick.Controls 2.1
import QtQuick.Window 2.1

import UM 1.5 as UM
import Cura 1.0 as Cura

Cura.Menu
{
    id: base

    property bool shouldShowExtruders: machineExtruderCount.properties.value > 1;

    property var multiBuildPlateModel: CuraApplication.getMultiBuildPlateModel()

    // Selection-related actions.
    Cura.MenuItem { action: Cura.Actions.centerSelection; }
    Cura.MenuItem { action: Cura.Actions.deleteSelection; }
    Cura.MenuItem { action: Cura.Actions.multiplySelection; }

    // Extruder selection - only visible if there is more than 1 extruder
    Cura.MenuSeparator { visible: base.shouldShowExtruders }
    Cura.MenuItem
    {
        id: extruderHeader
        text: catalog.i18ncp("@label", "Print Selected Model With:", "Print Selected Models With:", UM.Selection.selectionCount)
        enabled: false
        visible: base.shouldShowExtruders
    }

    Instantiator
    {
        model: CuraApplication.getExtrudersModel()
        Cura.MenuItem
        {
            text: "%1: %2 - %3".arg(model.name).arg(model.material).arg(model.variant)
            visible: base.shouldShowExtruders
            enabled: UM.Selection.hasSelection && model.enabled
            checkable: true
            checked: Cura.ExtruderManager.selectedObjectExtruders.indexOf(model.id) != -1
            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) }
        onObjectRemoved: function(index, object) {  base.removeItem(object) }
    }

    // Global actions
    Cura.MenuSeparator {}
    Cura.MenuItem { action: Cura.Actions.selectAll }
    Cura.MenuItem { action: Cura.Actions.arrangeAll }
    Cura.MenuItem { action: Cura.Actions.deleteAll }
    Cura.MenuItem { action: Cura.Actions.reloadAll }
    Cura.MenuItem { action: Cura.Actions.resetAllTranslation }
    Cura.MenuItem { action: Cura.Actions.resetAll }

    // Group actions
    Cura.MenuSeparator {}
    Cura.MenuItem { action: Cura.Actions.groupObjects }
    Cura.MenuItem { action: Cura.Actions.mergeObjects }
    Cura.MenuItem { action: Cura.Actions.unGroupObjects }

    Connections
    {
        target: UM.Controller
        function onContextMenuRequested() { base.popup() }
    }

    Connections
    {
        target: Cura.Actions.multiplySelection
        function onTriggered() { multiplyDialog.open() }
    }

    UM.SettingPropertyProvider
    {
        id: machineExtruderCount

        containerStack: Cura.MachineManager.activeMachine
        key: "machine_extruder_count"
        watchedProperties: [ "value" ]
    }

    UM.Dialog
    {
        id: multiplyDialog

        title: catalog.i18ncp("@title:window", "Multiply Selected Model", "Multiply Selected Models", UM.Selection.selectionCount)

        width: UM.Theme.getSize("small_popup_dialog").width
        height: UM.Theme.getSize("small_popup_dialog").height
        minimumWidth: UM.Theme.getSize("small_popup_dialog").width
        minimumHeight: UM.Theme.getSize("small_popup_dialog").height

        onAccepted: CuraActions.multiplySelection(copiesField.value)

        buttonSpacing: UM.Theme.getSize("thin_margin").width

        rightButtons:
        [
            Cura.SecondaryButton
            {
                text: "Cancel"
                onClicked: multiplyDialog.reject()
            },
            Cura.PrimaryButton
            {
                text: "Ok"
                onClicked: multiplyDialog.accept()
            }
        ]

        Row
        {
            spacing: UM.Theme.getSize("default_margin").width

            UM.Label
            {
                text: catalog.i18nc("@label", "Number of Copies")
                anchors.verticalCenter: copiesField.verticalCenter
                width: contentWidth
                wrapMode: Text.NoWrap
            }

            Cura.SpinBox
            {
                id: copiesField
                editable: true
                focus: true
                from: 1
                to: 99
                width: 2 * UM.Theme.getSize("button").width
                value: 1
            }
        }
    }
}