blob: 1637b8d0cd087f8b26404bf286960c7b4df1b4ca (
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
// Copyright (c) 2020 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10
import QtQuick.Controls 2.3
import UM 1.1 as UM
import Cura 1.0 as Cura
Button
{
id: objectItemButton
width: parent.width
height: UM.Theme.getSize("action_button").height
checkable: true
hoverEnabled: true
onHoveredChanged:
{
if(hovered && (buttonTextMetrics.elidedText != buttonText.text || perObjectSettingsInfo.visible))
{
tooltip.show()
} else
{
tooltip.hide()
}
}
onClicked: Cura.SceneController.changeSelection(index)
background: Rectangle
{
id: backgroundRect
color: objectItemButton.hovered ? UM.Theme.getColor("action_button_hovered") : "transparent"
radius: UM.Theme.getSize("action_button_radius").width
border.width: UM.Theme.getSize("default_lining").width
border.color: objectItemButton.checked ? UM.Theme.getColor("primary") : "transparent"
}
contentItem: Item
{
width: objectItemButton.width - objectItemButton.leftPadding
height: UM.Theme.getSize("action_button").height
Rectangle
{
id: swatch
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
width: UM.Theme.getSize("standard_arrow").height
height: UM.Theme.getSize("standard_arrow").height
radius: Math.round(width / 2)
color: extruderColor
visible: showExtruderSwatches && extruderColor != ""
}
Label
{
id: buttonText
anchors
{
left: showExtruderSwatches ? swatch.right : parent.left
leftMargin: showExtruderSwatches ? UM.Theme.getSize("narrow_margin").width : 0
right: perObjectSettingsInfo.visible ? perObjectSettingsInfo.left : parent.right
verticalCenter: parent.verticalCenter
}
text: objectItemButton.text
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text_scene")
opacity: (outsideBuildArea) ? 0.5 : 1.0
visible: text != ""
renderType: Text.NativeRendering
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
Button
{
id: perObjectSettingsInfo
anchors
{
right: parent.right
rightMargin: 0
}
width: childrenRect.width
height: parent.height
padding: 0
leftPadding: UM.Theme.getSize("thin_margin").width
visible: meshType != "" || perObjectSettingsCount > 0
onClicked:
{
Cura.SceneController.changeSelection(index)
UM.Controller.setActiveTool("PerObjectSettingsTool")
}
property string tooltipText:
{
var result = "";
if (!visible)
{
return result;
}
if (meshType != "")
{
result += "<br>";
switch (meshType) {
case "support_mesh":
result += catalog.i18nc("@label", "Is printed as support.");
break;
case "cutting_mesh":
result += catalog.i18nc("@label", "Other models overlapping with this model are modified.");
break;
case "infill_mesh":
result += catalog.i18nc("@label", "Infill overlapping with this model is modified.");
break;
case "anti_overhang_mesh":
result += catalog.i18nc("@label", "Overlaps with this model are not supported.");
break;
}
}
if (perObjectSettingsCount != "")
{
result += "<br>" + catalog.i18ncp(
"@label %1 is the number of settings it overrides.", "Overrides %1 setting.", "Overrides %1 settings.", perObjectSettingsCount
).arg(perObjectSettingsCount);
}
return result;
}
contentItem: Item
{
height: parent.height
width: meshTypeIcon.width + perObjectSettingsCountLabel.width + UM.Theme.getSize("narrow_margin").width
Cura.NotificationIcon
{
id: perObjectSettingsCountLabel
anchors
{
right: parent.right
rightMargin: 0
}
visible: perObjectSettingsCount > 0
color: UM.Theme.getColor("text_scene")
labelText: perObjectSettingsCount.toString()
}
UM.RecolorImage
{
id: meshTypeIcon
anchors
{
right: perObjectSettingsCountLabel.left
rightMargin: UM.Theme.getSize("narrow_margin").width
}
width: parent.height
height: parent.height
color: UM.Theme.getColor("text_scene")
visible: meshType != ""
source:
{
switch (meshType) {
case "support_mesh":
return UM.Theme.getIcon("MeshTypeSupport");
case "cutting_mesh":
case "infill_mesh":
return UM.Theme.getIcon("MeshTypeIntersect");
case "anti_overhang_mesh":
return UM.Theme.getIcon("BlockSupportOverlaps");
}
return "";
}
}
}
background: Item {}
}
}
TextMetrics
{
id: buttonTextMetrics
text: buttonText.text
font: buttonText.font
elide: buttonText.elide
elideWidth: buttonText.width
}
Cura.ToolTip
{
id: tooltip
tooltipText: objectItemButton.text + perObjectSettingsInfo.tooltipText
}
UM.I18nCatalog
{
id: catalog
name: "cura"
}
}
|