Move USB sidebar into the main view of the monitorstage

CURA-5943
This commit is contained in:
Jaime van Kessel 2018-11-30 13:53:53 +01:00
parent 6db52dde46
commit 6d4a460e58
8 changed files with 250 additions and 184 deletions

View file

@ -146,6 +146,7 @@ UM.MainWindow
Rectangle
{
id: stageMenuBackground
anchors
{
left: parent.left
@ -153,7 +154,7 @@ UM.MainWindow
top: parent.top
}
visible: stageMenu.source != ""
height: Math.round(UM.Theme.getSize("stage_menu").height / 2)
height: visible ? Math.round(UM.Theme.getSize("stage_menu").height / 2) : 0
LinearGradient
{
@ -254,7 +255,13 @@ UM.MainWindow
// A stage can control this area. If nothing is set, it will therefore show the 3D view.
id: main
anchors.fill: parent
anchors
{
top: stageMenuBackground.bottom
left: parent.left
right: parent.right
bottom: parent.bottom
}
source: UM.Controller.activeStage != null ? UM.Controller.activeStage.mainComponent : ""
}

View file

@ -11,136 +11,180 @@ import Cura 1.0 as Cura
import "PrinterOutput"
Column
Rectangle
{
id: printMonitor
id: base
UM.I18nCatalog { id: catalog; name: "cura"}
function showTooltip(item, position, text)
{
tooltip.text = text;
position = item.mapToItem(base, position.x - UM.Theme.getSize("default_arrow").width, position.y);
tooltip.show(position);
}
function hideTooltip()
{
tooltip.hide();
}
function strPadLeft(string, pad, length) {
return (new Array(length + 1).join(pad) + string).slice(-length);
}
function getPrettyTime(time)
{
var hours = Math.floor(time / 3600)
time -= hours * 3600
var minutes = Math.floor(time / 60);
time -= minutes * 60
var seconds = Math.floor(time);
var finalTime = strPadLeft(hours, "0", 2) + ":" + strPadLeft(minutes, "0", 2) + ":" + strPadLeft(seconds, "0", 2);
return finalTime;
}
property var connectedDevice: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property var activePrinter: connectedDevice != null ? connectedDevice.activePrinter : null
property var activePrintJob: activePrinter != null ? activePrinter.activePrintJob: null
Cura.ExtrudersModel
SidebarTooltip
{
id: extrudersModel
simpleNames: true
id: tooltip
}
OutputDeviceHeader
Column
{
outputDevice: connectedDevice
}
id: printMonitor
Rectangle
{
color: UM.Theme.getColor("wide_lining")
width: parent.width
height: childrenRect.height
anchors.fill: parent
Flow
Cura.ExtrudersModel
{
id: extrudersGrid
spacing: UM.Theme.getSize("thick_lining").width
id: extrudersModel
simpleNames: true
}
OutputDeviceHeader
{
outputDevice: connectedDevice
}
Rectangle
{
color: UM.Theme.getColor("wide_lining")
width: parent.width
height: childrenRect.height
Repeater
Flow
{
id: extrudersRepeater
model: activePrinter != null ? activePrinter.extruders : null
id: extrudersGrid
spacing: UM.Theme.getSize("thick_lining").width
width: parent.width
ExtruderBox
Repeater
{
color: UM.Theme.getColor("main_background")
width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.round(extrudersGrid.width / 2 - UM.Theme.getSize("thick_lining").width / 2)
extruderModel: modelData
id: extrudersRepeater
model: activePrinter != null ? activePrinter.extruders : null
ExtruderBox
{
color: UM.Theme.getColor("main_background")
width: index == machineExtruderCount.properties.value - 1 && index % 2 == 0 ? extrudersGrid.width : Math.round(extrudersGrid.width / 2 - UM.Theme.getSize("thick_lining").width / 2)
extruderModel: modelData
}
}
}
}
}
Rectangle
{
color: UM.Theme.getColor("wide_lining")
width: parent.width
height: UM.Theme.getSize("thick_lining").width
}
HeatedBedBox
{
visible: {
if(activePrinter != null && activePrinter.bedTemperature != -1)
{
return true
}
return false
}
printerModel: activePrinter
}
UM.SettingPropertyProvider
{
id: bedTemperature
containerStack: Cura.MachineManager.activeMachine
key: "material_bed_temperature"
watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
storeIndex: 0
property var resolve: Cura.MachineManager.activeStack != Cura.MachineManager.activeMachine ? properties.resolve : "None"
}
UM.SettingPropertyProvider
{
id: machineExtruderCount
containerStack: Cura.MachineManager.activeMachine
key: "machine_extruder_count"
watchedProperties: ["value"]
}
ManualPrinterControl
{
printerModel: activePrinter
visible: activePrinter != null ? activePrinter.canControlManually : false
}
MonitorSection
{
label: catalog.i18nc("@label", "Active print")
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Job Name")
value: activePrintJob != null ? activePrintJob.name : ""
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Printing Time")
value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Estimated time left")
value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
visible:
Rectangle
{
if(activePrintJob == null)
color: UM.Theme.getColor("wide_lining")
width: parent.width
height: UM.Theme.getSize("thick_lining").width
}
HeatedBedBox
{
visible:
{
if(activePrinter != null && activePrinter.bedTemperature != -1)
{
return true
}
return false
}
return (activePrintJob.state == "printing" ||
activePrintJob.state == "resuming" ||
activePrintJob.state == "pausing" ||
activePrintJob.state == "paused")
printerModel: activePrinter
}
UM.SettingPropertyProvider
{
id: bedTemperature
containerStack: Cura.MachineManager.activeMachine
key: "material_bed_temperature"
watchedProperties: ["value", "minimum_value", "maximum_value", "resolve"]
storeIndex: 0
property var resolve: Cura.MachineManager.activeStack != Cura.MachineManager.activeMachine ? properties.resolve : "None"
}
UM.SettingPropertyProvider
{
id: machineExtruderCount
containerStack: Cura.MachineManager.activeMachine
key: "machine_extruder_count"
watchedProperties: ["value"]
}
ManualPrinterControl
{
printerModel: activePrinter
visible: activePrinter != null ? activePrinter.canControlManually : false
}
MonitorSection
{
label: catalog.i18nc("@label", "Active print")
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Job Name")
value: activePrintJob != null ? activePrintJob.name : ""
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Printing Time")
value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal) : ""
width: base.width
visible: activePrinter != null
}
MonitorItem
{
label: catalog.i18nc("@label", "Estimated time left")
value: activePrintJob != null ? getPrettyTime(activePrintJob.timeTotal - activePrintJob.timeElapsed) : ""
visible:
{
if(activePrintJob == null)
{
return false
}
return (activePrintJob.state == "printing" ||
activePrintJob.state == "resuming" ||
activePrintJob.state == "pausing" ||
activePrintJob.state == "paused")
}
width: base.width
}
width: base.width
}
}
}