123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554 |
- // Copyright (c) 2017 Ultimaker B.V.
- // Cura is released under the terms of the LGPLv3 or higher.
- import QtQuick 2.2
- import QtQuick.Controls 1.1
- import QtQuick.Controls.Styles 1.1
- import QtQuick.Layouts 1.1
- import UM 1.2 as UM
- import Cura 1.0 as Cura
- Item
- {
- property var printerModel
- property var activePrintJob: printerModel != null ? printerModel.activePrintJob : null
- implicitWidth: parent.width
- implicitHeight: childrenRect.height
- Component
- {
- id: monitorButtonStyle
- ButtonStyle
- {
- background: Rectangle
- {
- border.width: UM.Theme.getSize("default_lining").width
- border.color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled_border");
- }
- else if(control.pressed)
- {
- return UM.Theme.getColor("action_button_active_border");
- }
- else if(control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered_border");
- }
- return UM.Theme.getColor("action_button_border");
- }
- color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled");
- }
- else if(control.pressed)
- {
- return UM.Theme.getColor("action_button_active");
- }
- else if(control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered");
- }
- return UM.Theme.getColor("action_button");
- }
- Behavior on color
- {
- ColorAnimation
- {
- duration: 50
- }
- }
- }
- label: Item
- {
- UM.RecolorImage
- {
- anchors.verticalCenter: parent.verticalCenter
- anchors.horizontalCenter: parent.horizontalCenter
- width: Math.floor(control.width / 2)
- height: Math.floor(control.height / 2)
- sourceSize.width: width
- sourceSize.height: width
- color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled_text");
- }
- else if(control.pressed)
- {
- return UM.Theme.getColor("action_button_active_text");
- }
- else if(control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered_text");
- }
- return UM.Theme.getColor("action_button_text");
- }
- source: control.iconSource
- }
- }
- }
- }
- Column
- {
- enabled:
- {
- if (printerModel == null)
- {
- return false; //Can't control the printer if not connected
- }
- if (!connectedDevice.acceptsCommands)
- {
- return false; //Not allowed to do anything.
- }
- if(activePrintJob == null)
- {
- return true
- }
- if (activePrintJob.state == "printing" || activePrintJob.state == "resuming" || activePrintJob.state == "pausing" || activePrintJob.state == "error" || activePrintJob.state == "offline")
- {
- return false; //Printer is in a state where it can't react to manual control
- }
- return true;
- }
- MonitorSection
- {
- label: catalog.i18nc("@label", "Printer control")
- width: base.width
- }
- Row
- {
- width: base.width - 2 * UM.Theme.getSize("default_margin").width
- height: childrenRect.height + UM.Theme.getSize("default_margin").width
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- spacing: UM.Theme.getSize("default_margin").width
- Label
- {
- text: catalog.i18nc("@label", "Jog Position")
- color: UM.Theme.getColor("setting_control_text")
- font: UM.Theme.getFont("default")
- width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
- height: UM.Theme.getSize("setting_control").height
- verticalAlignment: Text.AlignVCenter
- }
- GridLayout
- {
- columns: 3
- rows: 4
- rowSpacing: UM.Theme.getSize("default_lining").width
- columnSpacing: UM.Theme.getSize("default_lining").height
- Label
- {
- text: catalog.i18nc("@label", "X/Y")
- color: UM.Theme.getColor("setting_control_text")
- font: UM.Theme.getFont("default")
- width: height
- height: UM.Theme.getSize("setting_control").height
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- Layout.row: 1
- Layout.column: 2
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- }
- Button
- {
- Layout.row: 2
- Layout.column: 2
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- iconSource: UM.Theme.getIcon("arrow_top");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(0, distancesRow.currentDistance, 0)
- }
- }
- Button
- {
- Layout.row: 3
- Layout.column: 1
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- iconSource: UM.Theme.getIcon("arrow_left");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(-distancesRow.currentDistance, 0, 0)
- }
- }
- Button
- {
- Layout.row: 3
- Layout.column: 3
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- iconSource: UM.Theme.getIcon("arrow_right");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(distancesRow.currentDistance, 0, 0)
- }
- }
- Button
- {
- Layout.row: 4
- Layout.column: 2
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- iconSource: UM.Theme.getIcon("arrow_bottom");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(0, -distancesRow.currentDistance, 0)
- }
- }
- Button
- {
- Layout.row: 3
- Layout.column: 2
- Layout.preferredWidth: width
- Layout.preferredHeight: height
- iconSource: UM.Theme.getIcon("home");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.homeHead()
- }
- }
- }
- Column
- {
- spacing: UM.Theme.getSize("default_lining").height
- Label
- {
- text: catalog.i18nc("@label", "Z")
- color: UM.Theme.getColor("setting_control_text")
- font: UM.Theme.getFont("default")
- width: UM.Theme.getSize("section").height
- height: UM.Theme.getSize("setting_control").height
- verticalAlignment: Text.AlignVCenter
- horizontalAlignment: Text.AlignHCenter
- }
- Button
- {
- iconSource: UM.Theme.getIcon("arrow_top");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(0, 0, distancesRow.currentDistance)
- }
- }
- Button
- {
- iconSource: UM.Theme.getIcon("home");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.homeBed()
- }
- }
- Button
- {
- iconSource: UM.Theme.getIcon("arrow_bottom");
- style: monitorButtonStyle
- width: height
- height: UM.Theme.getSize("setting_control").height
- onClicked:
- {
- printerModel.moveHead(0, 0, -distancesRow.currentDistance)
- }
- }
- }
- }
- Row
- {
- id: distancesRow
- width: base.width - 2 * UM.Theme.getSize("default_margin").width
- height: childrenRect.height + UM.Theme.getSize("default_margin").width
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- spacing: UM.Theme.getSize("default_margin").width
- property real currentDistance: 10
- Label
- {
- text: catalog.i18nc("@label", "Jog Distance")
- color: UM.Theme.getColor("setting_control_text")
- font: UM.Theme.getFont("default")
- width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
- height: UM.Theme.getSize("setting_control").height
- verticalAlignment: Text.AlignVCenter
- }
- Row
- {
- Repeater
- {
- model: distancesModel
- delegate: Button
- {
- height: UM.Theme.getSize("setting_control").height
- width: height + UM.Theme.getSize("default_margin").width
- text: model.label
- exclusiveGroup: distanceGroup
- checkable: true
- checked: distancesRow.currentDistance == model.value
- onClicked: distancesRow.currentDistance = model.value
- style: ButtonStyle {
- background: Rectangle {
- border.width: control.checked ? UM.Theme.getSize("default_lining").width * 2 : UM.Theme.getSize("default_lining").width
- border.color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled_border");
- }
- else if (control.checked || control.pressed)
- {
- return UM.Theme.getColor("action_button_active_border");
- }
- else if(control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered_border");
- }
- return UM.Theme.getColor("action_button_border");
- }
- color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled");
- }
- else if (control.checked || control.pressed)
- {
- return UM.Theme.getColor("action_button_active");
- }
- else if (control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered");
- }
- return UM.Theme.getColor("action_button");
- }
- Behavior on color { ColorAnimation { duration: 50; } }
- Label {
- anchors.left: parent.left
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- anchors.leftMargin: UM.Theme.getSize("default_lining").width * 2
- anchors.rightMargin: UM.Theme.getSize("default_lining").width * 2
- color:
- {
- if(!control.enabled)
- {
- return UM.Theme.getColor("action_button_disabled_text");
- }
- else if (control.checked || control.pressed)
- {
- return UM.Theme.getColor("action_button_active_text");
- }
- else if (control.hovered)
- {
- return UM.Theme.getColor("action_button_hovered_text");
- }
- return UM.Theme.getColor("action_button_text");
- }
- font: UM.Theme.getFont("default")
- text: control.text
- horizontalAlignment: Text.AlignHCenter
- elide: Text.ElideMiddle
- }
- }
- label: Item { }
- }
- }
- }
- }
- }
- Row
- {
- id: customCommandInputRow
- width: base.width - 2 * UM.Theme.getSize("default_margin").width
- height: childrenRect.height + UM.Theme.getSize("default_margin").width
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("default_margin").width
- spacing: UM.Theme.getSize("default_margin").width
- Label
- {
- text: catalog.i18nc("@label", "Send G-code")
- color: UM.Theme.getColor("setting_control_text")
- font: UM.Theme.getFont("default")
- width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
- height: UM.Theme.getSize("setting_control").height
- verticalAlignment: Text.AlignVCenter
- }
- Row
- {
- // Input field for custom G-code commands.
- Rectangle
- {
- id: customCommandControl
- // state
- visible: printerModel != null ? printerModel.canSendRawGcode: true
- enabled: {
- if (printerModel == null) {
- return false // Can't send custom commands if not connected.
- }
- if (!connectedPrinter.acceptsCommands) {
- return false // Not allowed to do anything
- }
- if (connectedPrinter.jobState == "printing" || connectedPrinter.jobState == "pre_print" || connectedPrinter.jobState == "resuming" || connectedPrinter.jobState == "pausing" || connectedPrinter.jobState == "paused" || connectedPrinter.jobState == "error" || connectedPrinter.jobState == "offline") {
- return false // Printer is in a state where it can't react to custom commands.
- }
- return true
- }
- // style
- color: !enabled ? UM.Theme.getColor("setting_control_disabled") : UM.Theme.getColor("setting_validation_ok")
- border.width: UM.Theme.getSize("default_lining").width
- border.color: !enabled ? UM.Theme.getColor("setting_control_disabled_border") : customCommandControlMouseArea.containsMouse ? UM.Theme.getColor("setting_control_border_highlight") : UM.Theme.getColor("setting_control_border")
- // size
- width: UM.Theme.getSize("setting_control").width
- height: UM.Theme.getSize("setting_control").height
- // highlight
- Rectangle
- {
- anchors.fill: parent
- anchors.margins: UM.Theme.getSize("default_lining").width
- color: UM.Theme.getColor("setting_control_highlight")
- opacity: customCommandControl.hovered ? 1.0 : 0
- }
- // cursor hover popup
- MouseArea
- {
- id: customCommandControlMouseArea
- hoverEnabled: true
- anchors.fill: parent
- cursorShape: Qt.IBeamCursor
- onHoveredChanged:
- {
- if (containsMouse) {
- base.showTooltip(
- base,
- { x: 0, y: customCommandControlMouseArea.mapToItem(base, 0, 0).y },
- catalog.i18nc("@tooltip of G-code command input", "Send a custom G-code command to the connected printer. Press 'enter' to send the command.")
- )
- } else {
- base.hideTooltip()
- }
- }
- }
- TextInput
- {
- id: customCommandControlInput
- // style
- font: UM.Theme.getFont("default")
- color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text")
- selectByMouse: true
- clip: true
- enabled: parent.enabled
- renderType: Text.NativeRendering
- // anchors
- anchors.left: parent.left
- anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- // send the command when pressing enter
- // we also clear the text field
- Keys.onReturnPressed:
- {
- printerModel.sendRawCommand(customCommandControlInput.text)
- customCommandControlInput.text = ""
- }
- }
- }
- }
- }
- ListModel
- {
- id: distancesModel
- ListElement { label: "0.1"; value: 0.1 }
- ListElement { label: "1"; value: 1 }
- ListElement { label: "10"; value: 10 }
- ListElement { label: "100"; value: 100 }
- }
- ExclusiveGroup { id: distanceGroup }
- }
- }
|