1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
|
// Copyright (c) 2022 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.3
import UM 1.5 as UM
import Cura 1.0 as Cura
import "."
Item
{
property var printerModel: null
property var activePrintJob: printerModel != null ? printerModel.activePrintJob : null
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property var _buttonSize: UM.Theme.getSize("setting_control").height + UM.Theme.getSize("thin_margin").height
implicitWidth: parent.width
implicitHeight: childrenRect.height
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
UM.Label
{
text: catalog.i18nc("@label", "Jog Position")
color: UM.Theme.getColor("setting_control_text")
width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("setting_control").height
}
GridLayout
{
columns: 3
rows: 4
rowSpacing: UM.Theme.getSize("default_lining").width
columnSpacing: UM.Theme.getSize("default_lining").height
UM.Label
{
text: catalog.i18nc("@label", "X/Y")
color: UM.Theme.getColor("setting_control_text")
width: height
height: UM.Theme.getSize("setting_control").height
horizontalAlignment: Text.AlignHCenter
Layout.row: 0
Layout.column: 1
Layout.preferredWidth: width
Layout.preferredHeight: height
}
Cura.SecondaryButton
{
Layout.row: 1
Layout.column: 1
Layout.preferredWidth: _buttonSize
Layout.preferredHeight: _buttonSize
iconSource: UM.Theme.getIcon("ChevronSingleUp")
leftPadding: (Layout.preferredWidth - iconSize) / 2
onClicked: printerModel.moveHead(0, distancesRow.currentDistance, 0)
}
Cura.SecondaryButton
{
Layout.row: 2
Layout.column: 0
Layout.preferredWidth: _buttonSize
Layout.preferredHeight: _buttonSize
iconSource: UM.Theme.getIcon("ChevronSingleLeft")
leftPadding: (Layout.preferredWidth - iconSize) / 2
onClicked: printerModel.moveHead(-distancesRow.currentDistance, 0, 0)
}
Cura.SecondaryButton
{
Layout.row: 2
Layout.column: 2
Layout.preferredWidth: _buttonSize
Layout.preferredHeight: _buttonSize
iconSource: UM.Theme.getIcon("ChevronSingleRight")
leftPadding: (Layout.preferredWidth - iconSize) / 2
onClicked: printerModel.moveHead(distancesRow.currentDistance, 0, 0)
}
Cura.SecondaryButton
{
Layout.row: 3
Layout.column: 1
Layout.preferredWidth: _buttonSize
Layout.preferredHeight: _buttonSize
iconSource: UM.Theme.getIcon("ChevronSingleDown")
leftPadding: (Layout.preferredWidth - iconSize) / 2
onClicked: printerModel.moveHead(0, -distancesRow.currentDistance, 0)
}
Cura.SecondaryButton
{
Layout.row: 2
Layout.column: 1
Layout.preferredWidth: _buttonSize
Layout.preferredHeight: _buttonSize
iconSource: UM.Theme.getIcon("House")
leftPadding: (Layout.preferredWidth - iconSize) / 2
onClicked: printerModel.homeHead()
}
}
Column
{
spacing: UM.Theme.getSize("default_lining").height
UM.Label
{
text: catalog.i18nc("@label", "Z")
color: UM.Theme.getColor("setting_control_text")
width: UM.Theme.getSize("section").height
height: UM.Theme.getSize("setting_control").height
horizontalAlignment: Text.AlignHCenter
}
Cura.SecondaryButton
{
iconSource: UM.Theme.getIcon("ChevronSingleUp")
width: height
height: _buttonSize
leftPadding: (width - iconSize) / 2
onClicked: printerModel.moveHead(0, 0, distancesRow.currentDistance)
}
Cura.SecondaryButton
{
iconSource: UM.Theme.getIcon("House")
width: height
height: _buttonSize
leftPadding: (width - iconSize) / 2
onClicked: printerModel.homeBed()
}
Cura.SecondaryButton
{
iconSource: UM.Theme.getIcon("ChevronSingleDown")
width: height
height: _buttonSize
leftPadding: (width - iconSize) / 2
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
UM.Label
{
text: catalog.i18nc("@label", "Jog Distance")
color: UM.Theme.getColor("setting_control_text")
width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("setting_control").height
}
Row
{
Repeater
{
model: distancesModel
delegate: Cura.SecondaryButton
{
height: UM.Theme.getSize("setting_control").height
text: model.label
ButtonGroup.group: distanceGroup
color: distancesRow.currentDistance == model.value ? UM.Theme.getColor("primary_button") : UM.Theme.getColor("secondary_button")
textColor: distancesRow.currentDistance == model.value ? UM.Theme.getColor("primary_button_text"): UM.Theme.getColor("secondary_button_text")
hoverColor: distancesRow.currentDistance == model.value ? UM.Theme.getColor("primary_button_hover"): UM.Theme.getColor("secondary_button_hover")
onClicked: distancesRow.currentDistance = model.value
}
}
}
}
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
UM.Label
{
text: catalog.i18nc("@label", "Send G-code")
color: UM.Theme.getColor("setting_control_text")
width: Math.floor(parent.width * 0.4) - UM.Theme.getSize("default_margin").width
height: UM.Theme.getSize("setting_control").height
}
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 == null || !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: -tooltip.width, 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 }
}
ButtonGroup { id: distanceGroup }
}
}
|