Make custom commands functional, fix UI layout, typos

This commit is contained in:
ChrisTerBeke 2018-01-26 22:10:44 +01:00
parent 4d19428f42
commit bd46515382
No known key found for this signature in database
GPG key ID: A49F1AB9D7E0C263
3 changed files with 109 additions and 52 deletions

View file

@ -6,7 +6,7 @@ from UM.Logger import Logger
MYPY = False MYPY = False
if MYPY: if MYPY:
from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel from cura.PrinterOutput.PrintJobOutputModel import PrintJobOutputModel
from cura.PrinterOutput.ExtruderOuputModel import ExtruderOuputModel from cura.PrinterOutput.ExtruderOuputModel import ExtruderOutputModel
from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel from cura.PrinterOutput.PrinterOutputModel import PrinterOutputModel
@ -18,7 +18,7 @@ class PrinterOutputController:
self.can_control_manually = True self.can_control_manually = True
self._output_device = output_device self._output_device = output_device
def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOuputModel", temperature: int): def setTargetHotendTemperature(self, printer: "PrinterOutputModel", extruder: "ExtruderOutputModel", temperature: int):
Logger.log("w", "Set target hotend temperature not implemented in controller") Logger.log("w", "Set target hotend temperature not implemented in controller")
def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: int): def setTargetBedTemperature(self, printer: "PrinterOutputModel", temperature: int):

View file

@ -1,3 +1,6 @@
// Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.2 import QtQuick 2.2
import QtQuick.Controls 1.1 import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1 import QtQuick.Controls.Styles 1.1
@ -11,6 +14,7 @@ Item
implicitWidth: parent.width implicitWidth: parent.width
height: visible ? UM.Theme.getSize("sidebar_extruder_box").height : 0 height: visible ? UM.Theme.getSize("sidebar_extruder_box").height : 0
property var printerModel property var printerModel
Rectangle Rectangle
{ {
color: UM.Theme.getColor("sidebar") color: UM.Theme.getColor("sidebar")
@ -195,7 +199,7 @@ Item
} }
} }
Button //The pre-heat button. Button // The pre-heat button.
{ {
id: preheatButton id: preheatButton
height: UM.Theme.getSize("setting_control").height height: UM.Theme.getSize("setting_control").height

View file

@ -9,7 +9,6 @@ import QtQuick.Layouts 1.1
import UM 1.2 as UM import UM 1.2 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
Item Item
{ {
property var printerModel property var printerModel
@ -101,29 +100,29 @@ Item
Column Column
{ {
enabled: // enabled:
{ // {
if (printerModel == null) // if (printerModel == null)
{ // {
return false; //Can't control the printer if not connected // return false; //Can't control the printer if not connected
} // }
//
if (!connectedDevice.acceptsCommands) // if (!connectedDevice.acceptsCommands)
{ // {
return false; //Not allowed to do anything. // return false; //Not allowed to do anything.
} // }
//
if(activePrintJob == null) // if(activePrintJob == null)
{ // {
return true // return true
} // }
//
if (activePrintJob.state == "printing" || activePrintJob.state == "resuming" || activePrintJob.state == "pausing" || activePrintJob.state == "error" || activePrintJob.state == "offline") // 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 false; //Printer is in a state where it can't react to manual control
} // }
return true; // return true;
} // }
MonitorSection MonitorSection
@ -442,7 +441,7 @@ Item
Label Label
{ {
text: catalog.i18nc("@label", "Custom command input") text: catalog.i18nc("@label", "Send G-code")
color: UM.Theme.getColor("setting_control_text") color: UM.Theme.getColor("setting_control_text")
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
@ -453,37 +452,91 @@ Item
Row Row
{ {
TextInput // Input field for custom G-code commands.
Rectangle
{ {
id: customCommandInput id: customCommandControl
font: UM.Theme.getFont("default") // state
color: !enabled ? UM.Theme.getColor("setting_control_disabled_text") : UM.Theme.getColor("setting_control_text") visible: printerModel != null ? printerModel.canPreHeatBed: true
selectByMouse: true enabled: {
if (printerModel == null) {
return false // Can't preheat 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 pre-heating
}
return true
}
anchors.left: parent.left // style
anchors.leftMargin: UM.Theme.getSize("setting_unit_margin").width color: !enabled ? UM.Theme.getColor("setting_control_disabled") : UM.Theme.getColor("setting_validation_ok")
anchors.right: parent.right border.width: UM.Theme.getSize("default_lining").width
anchors.verticalCenter: parent.verticalCenter 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")
renderType: Text.NativeRendering
}
}
Row
{
Button
{
id: sendCustomCommandButton
// size
width: UM.Theme.getSize("setting_control").width
height: UM.Theme.getSize("setting_control").height height: UM.Theme.getSize("setting_control").height
anchors.right: parent.right // highlight
anchors.bottom: parent.bottom Rectangle
anchors.margins: UM.Theme.getSize("default_margin").width {
anchors.fill: parent
anchors.margins: UM.Theme.getSize("default_lining").width
color: UM.Theme.getColor("setting_control_highlight")
opacity: customCommandControl.hovered ? 1.0 : 0
}
onClicked: { // cursor hover popup
printerModel.sendCustomCommand(customCommandInput.text) 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.sendCustomCommand(customCommandControlInput.text)
customCommandControlInput.text = ""
}
} }
} }
} }