Cura/resources/qml/WizardPages/AddMachine.qml
Arjen Hiemstra 57b2ce4f3e Merge branch 'master' of github.com:ultimaker/Cura into per_object_settings
* 'master' of github.com:ultimaker/Cura: (49 commits)
  15.10 restyling of the sidebar header
  15.10 restyling of the sidebar header
  15.10 restyling of the sidebar
  split magic_mesh)surface_mode into Normal, Surface, Both
  Added preference to disable automatic scale
  Removed unused import
  Added changeLog plugin
  Added missing )
  Merging of mine and Jaimes work
  Removed font from rectangle
  JSON: git diff! removed triangles and grid top/bottom skin options (though they are available)
  Code style & switch to translation catalog
  15.10 re-alignment of the toolbar
  15.10 New Icons
  15.10 restyling of the savebutton Area
  Added message asking about sending data to server
  Added exception handling for checking overlap.
  Fixed default button for general and view page
  Fixed double ID in qml
  Removed unused import
  ...
2015-09-01 15:44:19 +02:00

238 lines
7.7 KiB
QML

// Copyright (c) 2015 Ultimaker B.V.
// Cura is released under the terms of the AGPLv3 or higher.
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Window 2.1
import QtQuick.Controls.Styles 1.1
import UM 1.1 as UM
import Cura 1.0 as Cura
import ".."
Item
{
id: base
property string activeManufacturer: "Ultimaker";
property variant wizard: null;
UM.I18nCatalog { id: catalog; name: "cura"}
Connections
{
target: base.wizard
onNextClicked: //You can add functions here that get triggered when the final button is clicked in the wizard-element
{
saveMachine()
}
onBackClicked:
{
var old_page_count = base.wizard.getPageCount()
// Delete old pages (if any)
for (var i = old_page_count - 1; i > 0; i--)
{
base.wizard.removePage(i)
}
}
}
Label
{
id: title
anchors.left: parent.left
anchors.top: parent.top
text: catalog.i18nc("@title", "Add Printer")
font.pointSize: 18;
}
Label
{
id: subTitle
anchors.left: parent.left
anchors.top: title.bottom
text: catalog.i18nc("@label", "Please select the type of printer:");
}
ScrollView
{
id: machinesHolder
anchors{
left: parent.left;
top: subTitle.bottom;
right: parent.right;
bottom: machineNameHolder.top;
}
ListView
{
id: machineList
model: UM.MachineDefinitionsModel { id: machineDefinitionsModel; showVariants: false; }
focus: true
section.property: "manufacturer"
section.delegate: Button {
text: {
if (base,activeManufacturer == section)
return section + " ▼"
else
return section + " ►"
}
style: ButtonStyle {
background: Rectangle {
id: manufacturerBackground
opacity: 0.3
border.width: 0
color: control.hovered ? palette.light : "transparent";
height: UM.Theme.sizes.standard_list_lineheight.height
}
label: Text {
horizontalAlignment: Text.AlignLeft
text: control.text
color: palette.windowText
font.bold: true
}
}
onClicked: {
base.activeManufacturer = section;
machineList.currentIndex = machineList.model.find("manufacturer", section)
}
}
delegate: RadioButton {
id: machineButton
anchors.left: parent.left
anchors.leftMargin: UM.Theme.sizes.standard_list_lineheight.width
opacity: 1;
height: UM.Theme.sizes.standard_list_lineheight.height;
checked: ListView.isCurrentItem;
exclusiveGroup: printerGroup;
text: model.name
onClicked: {
ListView.view.currentIndex = index;
if(model.pages.length > 0) {
base.wizard.nextAvailable = true;
} else {
base.wizard.nextAvailable = false;
}
}
Label
{
id: author
// visible: model.author != "Ultimaker" ? true : false
//: Printer profile caption meaning: this profile is supported by the community
// text: qsTr("community supported profile");
text: model.author;
anchors.left: machineButton.right
anchors.leftMargin: UM.Theme.sizes.standard_list_lineheight.height/2
anchors.verticalCenter: machineButton.verticalCenter
anchors.verticalCenterOffset: UM.Theme.sizes.standard_list_lineheight.height / 4
font: UM.Theme.fonts.caption;
color: palette.mid
}
states: State {
name: "collapsed";
when: base.activeManufacturer != model.manufacturer;
PropertyChanges { target: machineButton; opacity: 0; height: 0; }
}
transitions: [
Transition {
to: "collapsed";
SequentialAnimation {
NumberAnimation { property: "opacity"; duration: 75; }
NumberAnimation { property: "height"; duration: 75; }
}
},
Transition {
from: "collapsed";
SequentialAnimation {
NumberAnimation { property: "height"; duration: 75; }
NumberAnimation { property: "opacity"; duration: 75; }
}
}
]
}
}
}
Item
{
id: machineNameHolder
height: childrenRect.height
anchors.bottom: parent.bottom;
Label
{
id: insertNameLabel
text: catalog.i18nc("@label", "Printer Name:");
}
TextField
{
id: machineName;
anchors.top: insertNameLabel.bottom
text: machineList.model.getItem(machineList.currentIndex).name
implicitWidth: UM.Theme.sizes.standard_list_input.width
}
}
function saveMachine()
{
if(machineList.currentIndex != -1)
{
var item = machineList.model.getItem(machineList.currentIndex);
machineList.model.createInstance(machineName.text, item.id)
var pages = machineList.model.getItem(machineList.currentIndex).pages
console.log(pages)
console.log(pages.length)
// Insert new pages (if any)
for(var i = 0; i < pages.length; i++)
{
console.log(pages[i])
switch(pages[i]) {
case "SelectUpgradedParts":
base.wizard.appendPage(UM.Resources.getPath(Cura.ResourceTypes.QmlFiles, "WizardPages/SelectUpgradedParts.qml"), catalog.i18nc("@title", "Select Upgraded Parts"));
break;
case "UpgradeFirmware":
base.wizard.appendPage(UM.Resources.getPath(Cura.ResourceTypes.QmlFiles, "WizardPages/UpgradeFirmware.qml"), catalog.i18nc("@title", "Upgrade Firmware"));
break;
case "UltimakerCheckup":
base.wizard.appendPage(UM.Resources.getPath(Cura.ResourceTypes.QmlFiles, "WizardPages/UltimakerCheckup.qml"), catalog.i18nc("@title", "Check Printer"));
break;
case "BedLeveling":
base.wizard.appendPage(UM.Resources.getPath(Cura.ResourceTypes.QmlFiles, "WizardPages/Bedleveling.qml"), catalog.i18nc("@title", "Bed Levelling"));
break;
default:
break;
}
}
if (elementRoot.getPageCount() == elementRoot.currentPage)
{
elementRoot.visible = false
}
}
}
ExclusiveGroup { id: printerGroup; }
UM.I18nCatalog { id: catalog; name: "cura"; }
SystemPalette { id: palette }
}