mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-08 06:23:59 -06:00
CURA-4525 automatic build plate menu items using BuildPlateModel
This commit is contained in:
parent
97f61366a8
commit
bd8aa8d989
12 changed files with 131 additions and 152 deletions
|
@ -324,6 +324,7 @@ UM.MainWindow
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Button
|
||||
{
|
||||
id: openFileButton;
|
||||
|
@ -339,17 +340,19 @@ UM.MainWindow
|
|||
}
|
||||
action: Cura.Actions.open;
|
||||
}
|
||||
*/
|
||||
|
||||
Button
|
||||
{
|
||||
id: objectsButton;
|
||||
text: catalog.i18nc("@action:button","Objects");
|
||||
iconSource: UM.Theme.getIcon("load")
|
||||
iconSource: UM.Theme.getIcon("plus")
|
||||
style: UM.Theme.styles.tool_button
|
||||
tooltip: '';
|
||||
anchors
|
||||
{
|
||||
top: openFileButton.bottom;
|
||||
top: topbar.bottom;
|
||||
//top: openFileButton.bottom;
|
||||
topMargin: UM.Theme.getSize("default_margin").height;
|
||||
left: parent.left;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import QtQuick.Dialogs 1.2
|
|||
import QtQuick.Window 2.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.2 as Cura
|
||||
|
||||
Menu
|
||||
{
|
||||
|
@ -40,21 +40,21 @@ Menu
|
|||
}
|
||||
|
||||
MenuSeparator {}
|
||||
MenuItem {
|
||||
text: "build plate 0";
|
||||
onTriggered: CuraActions.setBuildPlateForSelection(0);
|
||||
checkable: true
|
||||
checked: false
|
||||
Instantiator
|
||||
{
|
||||
model: Cura.BuildPlateModel
|
||||
MenuItem {
|
||||
text: Cura.BuildPlateModel.getItem(index).name;
|
||||
onTriggered: CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.getItem(index).buildPlateNumber);
|
||||
checkable: true
|
||||
checked: Cura.BuildPlateModel.getItem(index).buildPlateNumber == Cura.BuildPlateModel.activeBuildPlate
|
||||
}
|
||||
onObjectAdded: base.insertItem(index, object);
|
||||
onObjectRemoved: base.removeItem(object)
|
||||
}
|
||||
MenuItem {
|
||||
text: "build plate 1";
|
||||
onTriggered: CuraActions.setBuildPlateForSelection(1);
|
||||
checkable: true
|
||||
checked: false
|
||||
}
|
||||
MenuItem {
|
||||
text: "build plate 2";
|
||||
onTriggered: CuraActions.setBuildPlateForSelection(2);
|
||||
text: "New build plate";
|
||||
onTriggered: CuraActions.setBuildPlateForSelection(Cura.BuildPlateModel.maxBuildPlate + 1);
|
||||
checkable: true
|
||||
checked: false
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@ import QtQuick 2.2
|
|||
import QtQuick.Controls 1.1
|
||||
|
||||
import UM 1.2 as UM
|
||||
import Cura 1.0 as Cura
|
||||
import Cura 1.2 as Cura
|
||||
|
||||
Menu
|
||||
{
|
||||
title: catalog.i18nc("@title:menu menubar:toplevel", "&View");
|
||||
id: menu
|
||||
id: base
|
||||
enabled: !PrintInformation.preSliced
|
||||
Instantiator
|
||||
{
|
||||
|
@ -23,30 +23,27 @@ Menu
|
|||
exclusiveGroup: group;
|
||||
onTriggered: UM.Controller.setActiveView(model.id);
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
onObjectAdded: base.insertItem(index, object)
|
||||
onObjectRemoved: base.removeItem(object)
|
||||
}
|
||||
ExclusiveGroup { id: group; }
|
||||
|
||||
MenuSeparator {}
|
||||
MenuItem {
|
||||
text: "build plate 0";
|
||||
onTriggered: CuraApplication.setActiveBuildPlate(0);
|
||||
}
|
||||
MenuItem {
|
||||
text: "build plate 1";
|
||||
onTriggered: CuraApplication.setActiveBuildPlate(1);
|
||||
}
|
||||
MenuItem {
|
||||
text: "build plate 2";
|
||||
onTriggered: CuraApplication.setActiveBuildPlate(2);
|
||||
MenuItem { action: Cura.Actions.homeCamera; }
|
||||
|
||||
MenuSeparator {}
|
||||
Instantiator
|
||||
{
|
||||
model: Cura.BuildPlateModel
|
||||
MenuItem {
|
||||
text: Cura.BuildPlateModel.getItem(index).name;
|
||||
onTriggered: Cura.BuildPlateModel.setActiveBuildPlate(Cura.BuildPlateModel.getItem(index).buildPlateNumber);
|
||||
checkable: true;
|
||||
checked: Cura.BuildPlateModel.getItem(index).buildPlateNumber == Cura.BuildPlateModel.activeBuildPlate;
|
||||
exclusiveGroup: buildPlateGroup;
|
||||
}
|
||||
onObjectAdded: base.insertItem(index, object);
|
||||
onObjectRemoved: base.removeItem(object)
|
||||
}
|
||||
ExclusiveGroup { id: buildPlateGroup; }
|
||||
|
||||
MenuItem {
|
||||
text: "New build plate";
|
||||
onTriggered: CuraApplication.newBuildPlate();
|
||||
}
|
||||
MenuSeparator {}
|
||||
MenuItem { action: Cura.Actions.homeCamera; }
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ Rectangle
|
|||
id: nodeNameLabel
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
//anchors.right: parent.right
|
||||
width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
|
||||
text: Cura.ObjectManager.getItem(index) ? Cura.ObjectManager.getItem(index).name : "";
|
||||
color: Cura.ObjectManager.getItem(index).isSelected ? palette.highlightedText : (Cura.ObjectManager.getItem(index).isOutsideBuildArea ? palette.mid : palette.text)
|
||||
|
@ -66,7 +65,7 @@ Rectangle
|
|||
anchors.left: nodeNameLabel.right
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
anchors.right: parent.right
|
||||
text: Cura.ObjectManager.getItem(index) ? Cura.ObjectManager.getItem(index).buildPlateNumber : 0;
|
||||
text: Cura.ObjectManager.getItem(index).buildPlateNumber != -1 ? Cura.ObjectManager.getItem(index).buildPlateNumber + 1 : "";
|
||||
color: Cura.ObjectManager.getItem(index).isSelected ? palette.highlightedText : palette.text
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
@ -134,41 +133,22 @@ Rectangle
|
|||
}
|
||||
}
|
||||
|
||||
ListModel
|
||||
{
|
||||
id: buildPlatesModel
|
||||
|
||||
ListElement
|
||||
{
|
||||
name: "build plate 0"
|
||||
buildPlateNumber: 0
|
||||
}
|
||||
ListElement
|
||||
{
|
||||
name: "build plate 1"
|
||||
buildPlateNumber: 1
|
||||
}
|
||||
ListElement
|
||||
{
|
||||
name: "build plate 2"
|
||||
buildPlateNumber: 2
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: buildPlateDelegate
|
||||
Rectangle
|
||||
{
|
||||
height: childrenRect.height
|
||||
color: CuraApplication.activeBuildPlate == buildPlateNumber ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
|
||||
color: Cura.BuildPlateModel.getItem(index).buildPlateNumber == Cura.BuildPlateModel.activeBuildPlate ? palette.highlight : index % 2 ? palette.base : palette.alternateBase
|
||||
width: parent.width
|
||||
Label
|
||||
{
|
||||
id: buildPlateNameLabel
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: UM.Theme.getSize("default_margin").width
|
||||
anchors.right: parent.right
|
||||
text: name //Cura.ObjectManager.getItem(index).name;
|
||||
color: CuraApplication.activeBuildPlate == buildPlateNumber ? palette.highlightedText : palette.text
|
||||
width: parent.width - 2 * UM.Theme.getSize("default_margin").width - 30
|
||||
text: Cura.BuildPlateModel.getItem(index) ? Cura.BuildPlateModel.getItem(index).name : "";
|
||||
color: Cura.BuildPlateModel.activeBuildPlate == index ? palette.highlightedText : palette.text
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
|
@ -177,7 +157,7 @@ Rectangle
|
|||
anchors.fill: parent;
|
||||
onClicked:
|
||||
{
|
||||
CuraApplication.setActiveBuildPlate(buildPlateNumber);
|
||||
Cura.BuildPlateModel.setActiveBuildPlate(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +172,6 @@ Rectangle
|
|||
|
||||
anchors
|
||||
{
|
||||
// top: objectsList.bottom;
|
||||
topMargin: UM.Theme.getSize("default_margin").height;
|
||||
left: parent.left;
|
||||
leftMargin: UM.Theme.getSize("default_margin").height;
|
||||
|
@ -210,21 +189,8 @@ Rectangle
|
|||
ListView
|
||||
{
|
||||
id: buildPlateListView
|
||||
model: buildPlatesModel
|
||||
|
||||
onModelChanged:
|
||||
{
|
||||
//currentIndex = -1;
|
||||
}
|
||||
model: Cura.BuildPlateModel
|
||||
width: parent.width
|
||||
currentIndex: -1
|
||||
onCurrentIndexChanged:
|
||||
{
|
||||
//base.selectedPrinter = listview.model[currentIndex];
|
||||
// Only allow connecting if the printer has responded to API query since the last refresh
|
||||
//base.completeProperties = base.selectedPrinter != null && base.selectedPrinter.getProperty("incomplete") != "true";
|
||||
}
|
||||
//Component.onCompleted: manager.startDiscovery()
|
||||
delegate: buildPlateDelegate
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue