mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-14 02:07:51 -06:00
Made machine wizard more dynamic
This commit is contained in:
parent
a7f33ea5e7
commit
2454f78e2d
3 changed files with 87 additions and 70 deletions
|
@ -10,7 +10,8 @@ import QtQuick.Controls.Styles 1.1
|
||||||
import UM 1.0 as UM
|
import UM 1.0 as UM
|
||||||
import ".."
|
import ".."
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout
|
||||||
|
{
|
||||||
id: wizardPage
|
id: wizardPage
|
||||||
property string title
|
property string title
|
||||||
property int pageWidth
|
property int pageWidth
|
||||||
|
@ -20,33 +21,34 @@ ColumnLayout {
|
||||||
|
|
||||||
SystemPalette{id: palette}
|
SystemPalette{id: palette}
|
||||||
signal reloadModel(var newModel)
|
signal reloadModel(var newModel)
|
||||||
signal closeWizard()
|
|
||||||
|
|
||||||
width: wizardPage.pageWidth
|
width: wizardPage.pageWidth
|
||||||
height: wizardPage.pageHeight
|
height: wizardPage.pageHeight
|
||||||
|
|
||||||
Connections {
|
Connections
|
||||||
|
{
|
||||||
target: elementRoot
|
target: elementRoot
|
||||||
onFinalClicked: {//You can add functions here that get triggered when the final button is clicked in the wizard-element
|
onNextClicked: //You can add functions here that get triggered when the final button is clicked in the wizard-element
|
||||||
|
{
|
||||||
saveMachine()
|
saveMachine()
|
||||||
}
|
}
|
||||||
onResize: {
|
|
||||||
wizardPage.width = pageWidth
|
|
||||||
wizardPage.height = pageHeight
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function lineManufacturers(manufacturer){
|
function lineManufacturers(manufacturer)
|
||||||
|
{
|
||||||
var manufacturers = []
|
var manufacturers = []
|
||||||
for (var i = 0; i < UM.Models.availableMachinesModel.rowCount(); i++) {
|
for (var i = 0; i < UM.Models.availableMachinesModel.rowCount(); i++)
|
||||||
if (UM.Models.availableMachinesModel.getItem(i).manufacturer != manufacturers[manufacturers.length - 1]){
|
{
|
||||||
|
if (UM.Models.availableMachinesModel.getItem(i).manufacturer != manufacturers[manufacturers.length - 1])
|
||||||
|
{
|
||||||
manufacturers.push(UM.Models.availableMachinesModel.getItem(i).manufacturer)
|
manufacturers.push(UM.Models.availableMachinesModel.getItem(i).manufacturer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return manufacturers
|
return manufacturers
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label
|
||||||
|
{
|
||||||
id: title
|
id: title
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
@ -54,7 +56,8 @@ ColumnLayout {
|
||||||
font.pointSize: 18;
|
font.pointSize: 18;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label
|
||||||
|
{
|
||||||
id: subTitle
|
id: subTitle
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: title.bottom
|
anchors.top: title.bottom
|
||||||
|
@ -62,21 +65,25 @@ ColumnLayout {
|
||||||
text: qsTr("Please select the type of printer:");
|
text: qsTr("Please select the type of printer:");
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollView {
|
ScrollView
|
||||||
|
{
|
||||||
id: machinesHolder
|
id: machinesHolder
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: subTitle.bottom
|
anchors.top: subTitle.bottom
|
||||||
implicitWidth: wizardPage.width- UM.Theme.sizes.default_margin.width
|
implicitWidth: wizardPage.width- UM.Theme.sizes.default_margin.width
|
||||||
implicitHeight: wizardPage.height - subTitle.height - title.height - (machineNameHolder.height * 2)
|
implicitHeight: wizardPage.height - subTitle.height - title.height - (machineNameHolder.height * 2)
|
||||||
|
|
||||||
Component {
|
Component
|
||||||
|
{
|
||||||
id: machineDelegate
|
id: machineDelegate
|
||||||
ColumnLayout {
|
ColumnLayout
|
||||||
|
{
|
||||||
id: machineLayout
|
id: machineLayout
|
||||||
spacing: 0
|
spacing: 0
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: UM.Theme.sizes.standard_list_lineheight.width
|
anchors.leftMargin: UM.Theme.sizes.standard_list_lineheight.width
|
||||||
function showManufacturer(){
|
function showManufacturer()
|
||||||
|
{
|
||||||
if (model.manufacturer == UM.Models.availableMachinesModel.getItem(index - 1).manufacturer){
|
if (model.manufacturer == UM.Models.availableMachinesModel.getItem(index - 1).manufacturer){
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -84,7 +91,8 @@ ColumnLayout {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
height: {
|
height:
|
||||||
|
{
|
||||||
if (machineLayout.showManufacturer() & wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer)
|
if (machineLayout.showManufacturer() & wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer)
|
||||||
return UM.Theme.sizes.standard_list_lineheight.height * 2
|
return UM.Theme.sizes.standard_list_lineheight.height * 2
|
||||||
if (wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer | machineLayout.showManufacturer())
|
if (wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer | machineLayout.showManufacturer())
|
||||||
|
@ -92,31 +100,37 @@ ColumnLayout {
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
Behavior on height{
|
Behavior on height
|
||||||
|
{
|
||||||
NumberAnimation { target: machineLayout; property: "height"; duration: 200}
|
NumberAnimation { target: machineLayout; property: "height"; duration: 200}
|
||||||
}
|
}
|
||||||
Button {
|
Button
|
||||||
|
{
|
||||||
id: manufacturer
|
id: manufacturer
|
||||||
property color backgroundColor: "transparent"
|
property color backgroundColor: "transparent"
|
||||||
height: UM.Theme.sizes.standard_list_lineheight.height
|
height: UM.Theme.sizes.standard_list_lineheight.height
|
||||||
visible: machineLayout.showManufacturer()
|
visible: machineLayout.showManufacturer()
|
||||||
anchors.top: machineLayout.top
|
anchors.top: machineLayout.top
|
||||||
anchors.topMargin: 0
|
anchors.topMargin: 0
|
||||||
text: {
|
text:
|
||||||
|
{
|
||||||
if (wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer)
|
if (wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer)
|
||||||
return model.manufacturer + " ▼"
|
return model.manufacturer + " ▼"
|
||||||
else
|
else
|
||||||
return model.manufacturer + " ►"
|
return model.manufacturer + " ►"
|
||||||
}
|
}
|
||||||
style: ButtonStyle {
|
style: ButtonStyle
|
||||||
background: Rectangle {
|
{
|
||||||
|
background: Rectangle
|
||||||
|
{
|
||||||
id: manufacturerBackground
|
id: manufacturerBackground
|
||||||
opacity: 0.3
|
opacity: 0.3
|
||||||
border.width: 0
|
border.width: 0
|
||||||
color: manufacturer.backgroundColor
|
color: manufacturer.backgroundColor
|
||||||
height: UM.Theme.sizes.standard_list_lineheight.height
|
height: UM.Theme.sizes.standard_list_lineheight.height
|
||||||
}
|
}
|
||||||
label: Text {
|
label: Text
|
||||||
|
{
|
||||||
renderType: Text.NativeRendering
|
renderType: Text.NativeRendering
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
text: control.text
|
text: control.text
|
||||||
|
@ -124,20 +138,23 @@ ColumnLayout {
|
||||||
font.bold: true
|
font.bold: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea
|
||||||
|
{
|
||||||
id: mousearea
|
id: mousearea
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
onEntered: manufacturer.backgroundColor = palette.light
|
onEntered: manufacturer.backgroundColor = palette.light
|
||||||
onExited: manufacturer.backgroundColor = "transparent"
|
onExited: manufacturer.backgroundColor = "transparent"
|
||||||
onClicked: {
|
onClicked:
|
||||||
|
{
|
||||||
wizardPage.manufacturerIndex = wizardPage.manufacturers.indexOf(model.manufacturer)
|
wizardPage.manufacturerIndex = wizardPage.manufacturers.indexOf(model.manufacturer)
|
||||||
machineList.currentIndex = index
|
machineList.currentIndex = index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioButton {
|
RadioButton
|
||||||
|
{
|
||||||
id: machineButton
|
id: machineButton
|
||||||
opacity: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? 1 : 0
|
opacity: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? 1 : 0
|
||||||
height: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? UM.Theme.sizes.standard_list_lineheight.height : 0
|
height: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? UM.Theme.sizes.standard_list_lineheight.height : 0
|
||||||
|
@ -149,13 +166,15 @@ ColumnLayout {
|
||||||
exclusiveGroup: printerGroup;
|
exclusiveGroup: printerGroup;
|
||||||
text: model.name
|
text: model.name
|
||||||
onClicked: machineList.currentIndex = index;
|
onClicked: machineList.currentIndex = index;
|
||||||
function getAnimationTime(time){
|
function getAnimationTime(time)
|
||||||
|
{
|
||||||
if (machineButton.opacity == 0)
|
if (machineButton.opacity == 0)
|
||||||
return time
|
return time
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
Label {
|
Label
|
||||||
|
{
|
||||||
id: author
|
id: author
|
||||||
visible: model.author != "Ultimaker" ? true : false
|
visible: model.author != "Ultimaker" ? true : false
|
||||||
height: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? UM.Theme.sizes.standard_list_lineheight.height : 0
|
height: wizardPage.manufacturers[wizardPage.manufacturerIndex] == model.manufacturer ? UM.Theme.sizes.standard_list_lineheight.height : 0
|
||||||
|
@ -169,8 +188,10 @@ ColumnLayout {
|
||||||
font: UM.Theme.fonts.caption;
|
font: UM.Theme.fonts.caption;
|
||||||
color: palette.mid
|
color: palette.mid
|
||||||
}
|
}
|
||||||
Behavior on opacity {
|
Behavior on opacity
|
||||||
SequentialAnimation {
|
{
|
||||||
|
SequentialAnimation
|
||||||
|
{
|
||||||
PauseAnimation { duration: machineButton.getAnimationTime(100) }
|
PauseAnimation { duration: machineButton.getAnimationTime(100) }
|
||||||
NumberAnimation { properties:"opacity"; duration: machineButton.getAnimationTime(200) }
|
NumberAnimation { properties:"opacity"; duration: machineButton.getAnimationTime(200) }
|
||||||
}
|
}
|
||||||
|
@ -180,12 +201,16 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView {
|
ListView
|
||||||
|
{
|
||||||
id: machineList
|
id: machineList
|
||||||
property int currentIndex: 0
|
property int currentIndex: 0
|
||||||
property int otherMachinesIndex: {
|
property int otherMachinesIndex:
|
||||||
for (var i = 0; i < UM.Models.availableMachinesModel.rowCount(); i++) {
|
{
|
||||||
if (UM.Models.availableMachinesModel.getItem(i).manufacturer != "Ultimaker"){
|
for (var i = 0; i < UM.Models.availableMachinesModel.rowCount(); i++)
|
||||||
|
{
|
||||||
|
if (UM.Models.availableMachinesModel.getItem(i).manufacturer != "Ultimaker")
|
||||||
|
{
|
||||||
return i
|
return i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,16 +222,19 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Item{
|
Item
|
||||||
|
{
|
||||||
id: machineNameHolder
|
id: machineNameHolder
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
anchors.top: machinesHolder.bottom
|
anchors.top: machinesHolder.bottom
|
||||||
Label {
|
Label
|
||||||
|
{
|
||||||
id: insertNameLabel
|
id: insertNameLabel
|
||||||
//: Add Printer wizard field label
|
//: Add Printer wizard field label
|
||||||
text: qsTr("Printer Name:");
|
text: qsTr("Printer Name:");
|
||||||
}
|
}
|
||||||
TextField {
|
TextField
|
||||||
|
{
|
||||||
id: machineName;
|
id: machineName;
|
||||||
anchors.top: insertNameLabel.bottom
|
anchors.top: insertNameLabel.bottom
|
||||||
text: machineList.model.getItem(machineList.currentIndex).name
|
text: machineList.model.getItem(machineList.currentIndex).name
|
||||||
|
@ -217,38 +245,30 @@ ColumnLayout {
|
||||||
ExclusiveGroup { id: printerGroup; }
|
ExclusiveGroup { id: printerGroup; }
|
||||||
|
|
||||||
|
|
||||||
function saveMachine(){
|
function saveMachine()
|
||||||
if(machineList.currentIndex != -1) {
|
{
|
||||||
|
if(machineList.currentIndex != -1)
|
||||||
|
{
|
||||||
UM.Models.availableMachinesModel.createMachine(machineList.currentIndex, machineName.text)
|
UM.Models.availableMachinesModel.createMachine(machineList.currentIndex, machineName.text)
|
||||||
|
var pages = UM.Models.availableMachinesModel.getItem(machineList.currentIndex).pages
|
||||||
var chosenMachine = UM.Models.availableMachinesModel.getItem(machineList.currentIndex).name
|
var old_page_count = elementRoot.getPageCount()
|
||||||
var originalString = "Ultimaker Original"
|
// Delete old pages (if any)
|
||||||
var originalPlusString = "Ultimaker Original+"
|
for (var i = old_page_count - 1; i > 0; i--)
|
||||||
|
|
||||||
if (chosenMachine == originalString | chosenMachine == originalPlusString ){
|
|
||||||
wizardPage.reloadModel([
|
|
||||||
{
|
{
|
||||||
title: "Select Upgraded Parts",
|
elementRoot.removePage(i)
|
||||||
page: "SelectUpgradedParts.qml"
|
elementRoot.currentPage = 0
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Upgrade Ultimaker Firmware",
|
|
||||||
page: "UpgradeFirmware.qml"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Ultimaker Checkup",
|
|
||||||
page: "UltimakerCheckup.qml"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Bedleveling Wizard",
|
|
||||||
page: "Bedleveling.qml"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
// Insert new pages (if any)
|
||||||
wizardPage.closeWizard()
|
for(var i = 0; i < pages.count; i++)
|
||||||
|
{
|
||||||
|
elementRoot.insertPage(pages.getItem(i).page + ".qml",pages.getItem(i).title,i + 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hack to ensure the current page is set correctly
|
||||||
|
if(old_page_count == 1)
|
||||||
|
{
|
||||||
|
elementRoot.currentPage += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,6 @@ Column
|
||||||
TextField
|
TextField
|
||||||
{
|
{
|
||||||
id: machineName; Layout.fillWidth: true; text: machineList.model.getItem(machineList.currentIndex).name
|
id: machineName; Layout.fillWidth: true; text: machineList.model.getItem(machineList.currentIndex).name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item
|
Item
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
"author": "other",
|
"author": "other",
|
||||||
"manufacturer": "other",
|
"manufacturer": "other",
|
||||||
|
|
||||||
"add_pages": [{"page": "AddMachine", "title": "Add new printer"}],
|
|
||||||
|
|
||||||
"machine_settings": {
|
"machine_settings": {
|
||||||
"machine_start_gcode": {
|
"machine_start_gcode": {
|
||||||
"default": "G28 ; Home\nG1 Z15.0 F6000 ;move the platform down 15mm\n;Prime the extruder\nG92 E0\nG1 F200 E3\nG92 E0"
|
"default": "G28 ; Home\nG1 Z15.0 F6000 ;move the platform down 15mm\n;Prime the extruder\nG92 E0\nG1 F200 E3\nG92 E0"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue