mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-07 05:53:59 -06:00
Merge pull request #1740 from Ultimaker/feature_extruder_buttons
Add Extruder selection buttons to the Toolbar
This commit is contained in:
commit
b05954f99f
7 changed files with 272 additions and 136 deletions
80
resources/qml/ExtruderButton.qml
Normal file
80
resources/qml/ExtruderButton.qml
Normal file
|
@ -0,0 +1,80 @@
|
|||
// Copyright (c) 2017 Ultimaker B.V.
|
||||
// Cura is released under the terms of the AGPLv3 or higher.
|
||||
|
||||
import QtQuick 2.2
|
||||
import QtQuick.Controls 1.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Button
|
||||
{
|
||||
id: base
|
||||
|
||||
property var extruder;
|
||||
|
||||
text: catalog.i18ncp("@label", "Print Selected Model with %1", "Print Selected Models With %1", UM.Selection.selectionCount).arg(extruder.name)
|
||||
|
||||
style: UM.Theme.styles.tool_button;
|
||||
iconSource: checked ? UM.Theme.getIcon("material_selected") : UM.Theme.getIcon("material_not_selected");
|
||||
|
||||
checked: ExtruderManager.selectedObjectExtruders.indexOf(extruder.id) != -1
|
||||
enabled: UM.Selection.hasSelection
|
||||
|
||||
property color customColor: base.hovered ? UM.Theme.getColor("button_hover") : UM.Theme.getColor("button");
|
||||
|
||||
Rectangle
|
||||
{
|
||||
anchors.fill: parent
|
||||
anchors.margins: UM.Theme.getSize("default_lining").width;
|
||||
|
||||
color: "transparent"
|
||||
|
||||
border.width: base.checked ? UM.Theme.getSize("default_lining").width : 0;
|
||||
border.color: UM.Theme.getColor("button_text")
|
||||
}
|
||||
|
||||
Item
|
||||
{
|
||||
anchors
|
||||
{
|
||||
right: parent.right;
|
||||
top: parent.top;
|
||||
margins: UM.Theme.getSize("default_lining").width * 3
|
||||
}
|
||||
width: UM.Theme.getSize("default_margin").width
|
||||
height: UM.Theme.getSize("default_margin").height
|
||||
|
||||
Text
|
||||
{
|
||||
anchors.centerIn: parent;
|
||||
text: index + 1;
|
||||
color: parent.enabled ? UM.Theme.getColor("button_text") : UM.Theme.getColor("button_disabled_text")
|
||||
font: UM.Theme.getFont("default_bold");
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
anchors
|
||||
{
|
||||
left: parent.left;
|
||||
top: parent.top;
|
||||
margins: UM.Theme.getSize("default_lining").width * 3
|
||||
}
|
||||
|
||||
color: model.color
|
||||
|
||||
width: UM.Theme.getSize("default_margin").width
|
||||
height: UM.Theme.getSize("default_margin").height
|
||||
|
||||
border.width: UM.Theme.getSize("default_lining").width
|
||||
border.color: UM.Theme.getColor("lining");
|
||||
}
|
||||
|
||||
onClicked:
|
||||
{
|
||||
forceActiveFocus() //First grab focus, so all the text fields are updated
|
||||
CuraActions.setExtruderForSelection(extruder.id);
|
||||
}
|
||||
}
|
|
@ -6,28 +6,33 @@ import QtQuick.Controls 1.1
|
|||
import QtQuick.Controls.Styles 1.1
|
||||
import QtQuick.Layouts 1.1
|
||||
|
||||
import UM 1.0 as UM
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
|
||||
Item {
|
||||
Item
|
||||
{
|
||||
id: base;
|
||||
|
||||
width: buttons.width;
|
||||
height: buttons.height
|
||||
property int activeY
|
||||
|
||||
ColumnLayout {
|
||||
Column
|
||||
{
|
||||
id: buttons;
|
||||
|
||||
anchors.bottom: parent.bottom;
|
||||
anchors.left: parent.left;
|
||||
spacing: UM.Theme.getSize("button_lining").width
|
||||
|
||||
Repeater {
|
||||
Repeater
|
||||
{
|
||||
id: repeat
|
||||
|
||||
model: UM.ToolModel { }
|
||||
|
||||
Button {
|
||||
Button
|
||||
{
|
||||
text: model.name
|
||||
iconSource: UM.Theme.getIcon(model.icon);
|
||||
|
||||
|
@ -45,9 +50,11 @@ Item {
|
|||
}
|
||||
//Workaround since using ToolButton"s onClicked would break the binding of the checked property, instead
|
||||
//just catch the click so we do not trigger that behaviour.
|
||||
MouseArea {
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent;
|
||||
onClicked: {
|
||||
onClicked:
|
||||
{
|
||||
forceActiveFocus() //First grab focus, so all the text fields are updated
|
||||
if(parent.checked)
|
||||
{
|
||||
|
@ -61,9 +68,19 @@ Item {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item { height: UM.Theme.getSize("default_margin").height; width: 1; visible: extruders.count > 0 }
|
||||
|
||||
Repeater
|
||||
{
|
||||
id: extruders
|
||||
model: Cura.ExtrudersModel { id: extrudersModel }
|
||||
ExtruderButton { extruder: model }
|
||||
}
|
||||
}
|
||||
|
||||
UM.PointingRectangle {
|
||||
UM.PointingRectangle
|
||||
{
|
||||
id: panelBorder;
|
||||
|
||||
anchors.left: parent.right;
|
||||
|
@ -75,7 +92,8 @@ Item {
|
|||
target: Qt.point(parent.right, base.activeY + UM.Theme.getSize("button").height/2)
|
||||
arrowSize: UM.Theme.getSize("default_arrow").width
|
||||
|
||||
width: {
|
||||
width:
|
||||
{
|
||||
if (panel.item && panel.width > 0){
|
||||
return Math.max(panel.width + 2 * UM.Theme.getSize("default_margin").width)
|
||||
}
|
||||
|
@ -90,7 +108,8 @@ Item {
|
|||
|
||||
color: UM.Theme.getColor("lining");
|
||||
|
||||
UM.PointingRectangle {
|
||||
UM.PointingRectangle
|
||||
{
|
||||
id: panelBackground;
|
||||
|
||||
color: UM.Theme.getColor("tool_panel_background");
|
||||
|
@ -105,7 +124,8 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
Loader
|
||||
{
|
||||
id: panel
|
||||
|
||||
x: UM.Theme.getSize("default_margin").width;
|
||||
|
@ -116,6 +136,8 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
// This rectangle displays the information about the current angle etc. when
|
||||
// dragging a tool handle.
|
||||
Rectangle
|
||||
{
|
||||
x: -base.x + base.mouseX + UM.Theme.getSize("default_margin").width
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue