From 1b9c29579b6febbc8281d833698cef27f8c06606 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 9 May 2016 14:55:01 +0200 Subject: [PATCH] Reworked add machine (Still stub) CURA-1278 --- resources/qml/AddMachineDialog.qml | 165 +++++++++++++++++++++++++++++ resources/qml/Cura.qml | 14 +-- 2 files changed, 172 insertions(+), 7 deletions(-) create mode 100644 resources/qml/AddMachineDialog.qml diff --git a/resources/qml/AddMachineDialog.qml b/resources/qml/AddMachineDialog.qml new file mode 100644 index 0000000000..c6e852aa3e --- /dev/null +++ b/resources/qml/AddMachineDialog.qml @@ -0,0 +1,165 @@ +// Copyright (c) 2016 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 + + +UM.Dialog +{ + id: base + title: catalog.i18nc("@title:window", "Add Printer") + property string activeManufacturer: "Ultimaker"; + + function getMachineName() + { + var name = machineList.model.getItem(machineList.currentIndex).name + return name + } + + ScrollView + { + id: machinesHolder + + anchors + { + left: parent.left; + top: parent.top; + right: parent.right; + bottom: parent.bottom; + } + ListView + { + id: machineList + + model: UM.DefinitionContainersModel + { + id: machineDefinitionsModel + filter: {"visible":true} + } + section.property: "manufacturer" + section.delegate: Button + { + text: section + style: ButtonStyle + { + background: Rectangle + { + border.width: 0 + color: "transparent"; + height: UM.Theme.getSize("standard_list_lineheight").height + width: machineList.width + } + label: Label + { + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("standard_arrow").width + UM.Theme.getSize("default_margin").width + text: control.text + color: palette.windowText + font.bold: true + UM.RecolorImage + { + id: downArrow + anchors.verticalCenter: parent.verticalCenter + anchors.right: parent.left + anchors.rightMargin: UM.Theme.getSize("default_margin").width + width: UM.Theme.getSize("standard_arrow").width + height: UM.Theme.getSize("standard_arrow").height + sourceSize.width: width + sourceSize.height: width + color: palette.windowText + source: base.activeManufacturer == section ? UM.Theme.getIcon("arrow_bottom") : UM.Theme.getIcon("arrow_right") + } + } + } + + onClicked: + { + base.activeManufacturer = section; + machineList.currentIndex = machineList.model.find("manufacturer", section) + machineName.text = getMachineName() + } + } + + delegate: RadioButton + { + id: machineButton + + anchors.left: parent.left + anchors.leftMargin: UM.Theme.getSize("standard_list_lineheight").width + + opacity: 1; + height: UM.Theme.getSize("standard_list_lineheight").height; + + checked: ListView.isCurrentItem; + + exclusiveGroup: printerGroup; + + text: model.name + + onClicked: + { + ListView.view.currentIndex = index; + machineName.text = getMachineName() + } + + 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; } + } + } + ] + } + } + } + + TextField + { + id: machineName; + text: getMachineName() + implicitWidth: UM.Theme.getSize("standard_list_input").width + maximumLength: 40 + anchors.bottom:parent.bottom + } + + Item + { + UM.I18nCatalog + { + id: catalog; + name: "cura"; + } + SystemPalette { id: palette } + ExclusiveGroup { id: printerGroup; } + } +} \ No newline at end of file diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index cdff5fc9ab..e39cd733d9 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -626,7 +626,7 @@ UM.MainWindow resetAll.onTriggered: Printer.resetAll(); reloadAll.onTriggered: Printer.reloadAll(); - addMachine.onTriggered: addMachineWizard.visible = true; + addMachine.onTriggered: addMachineDialog.visible = true; addProfile.onTriggered: { UM.MachineManager.createProfile(); @@ -742,9 +742,9 @@ UM.MainWindow id: engineLog; } - AddMachineWizard + AddMachineDialog { - id: addMachineWizard + id: addMachineDialog } AboutDialog @@ -757,8 +757,8 @@ UM.MainWindow target: Printer onRequestAddPrinter: { - addMachineWizard.visible = true - addMachineWizard.firstRun = false + addMachineDialog.visible = true + addMachineDialog.firstRun = false } } @@ -777,8 +777,8 @@ UM.MainWindow } else if(UM.MachineManager.activeMachineInstance == "") { - addMachineWizard.firstRun = true; - addMachineWizard.open(); + addMachineDialog.firstRun = true; + addMachineDialog.open(); } } }