Merge pull request #3593 from fieldOfView/feature_separate_stage_qml

Separate qml files for Prepare and Monitor stages
This commit is contained in:
ChrisTerBeke 2018-05-24 10:37:02 +02:00 committed by GitHub
commit 25d9b875ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 233 additions and 62 deletions

View File

@ -73,6 +73,5 @@ class MonitorStage(CuraStage):
self.addDisplayComponent("main", main_component_path) self.addDisplayComponent("main", main_component_path)
def _updateSidebar(self): def _updateSidebar(self):
# TODO: currently the sidebar component for prepare and monitor stages is the same, this will change with the printer output device refactor! sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "MonitorSidebar.qml")
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml")
self.addDisplayComponent("sidebar", sidebar_component_path) self.addDisplayComponent("sidebar", sidebar_component_path)

View File

@ -14,5 +14,5 @@ class PrepareStage(CuraStage):
Application.getInstance().engineCreatedSignal.connect(self._engineCreated) Application.getInstance().engineCreatedSignal.connect(self._engineCreated)
def _engineCreated(self): def _engineCreated(self):
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "Sidebar.qml") sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles), "PrepareSidebar.qml")
self.addDisplayComponent("sidebar", sidebar_component_path) self.addDisplayComponent("sidebar", sidebar_component_path)

View File

@ -15,6 +15,8 @@ Item
id: base; id: base;
UM.I18nCatalog { id: catalog; name:"cura"} UM.I18nCatalog { id: catalog; name:"cura"}
height: childrenRect.height + UM.Theme.getSize("sidebar_margin").height
property bool printerConnected: Cura.MachineManager.printerConnected property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var activePrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0].activePrinter : null property var activePrinter: printerConnected ? Cura.MachineManager.printerOutputDevices[0].activePrinter : null

View File

@ -0,0 +1,211 @@
// Copyright (c) 2017 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
import UM 1.2 as UM
import Cura 1.0 as Cura
import "Menus"
import "Menus/ConfigurationMenu"
Rectangle
{
id: base
property int currentModeIndex
property bool hideSettings: PrintInformation.preSliced
property bool hideView: Cura.MachineManager.activeMachineName == ""
// Is there an output device for this printer?
property bool isNetworkPrinter: Cura.MachineManager.activeMachineNetworkKey != ""
property bool printerConnected: Cura.MachineManager.printerConnected
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property variant printDuration: PrintInformation.currentPrintTime
property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights
property variant printMaterialCosts: PrintInformation.materialCosts
property variant printMaterialNames: PrintInformation.materialNames
color: UM.Theme.getColor("sidebar")
UM.I18nCatalog { id: catalog; name:"cura"}
Timer {
id: tooltipDelayTimer
interval: 500
repeat: false
property var item
property string text
onTriggered:
{
base.showTooltip(base, {x: 0, y: item.y}, text);
}
}
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;
}
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onWheel:
{
wheel.accepted = true;
}
}
MachineSelection
{
id: machineSelection
width: base.width - configSelection.width - separator.width
height: UM.Theme.getSize("sidebar_header").height
anchors.top: base.top
anchors.left: parent.left
}
Rectangle
{
id: separator
visible: configSelection.visible
width: visible ? Math.round(UM.Theme.getSize("sidebar_lining_thin").height / 2) : 0
height: UM.Theme.getSize("sidebar_header").height
color: UM.Theme.getColor("sidebar_lining_thin")
anchors.left: machineSelection.right
}
ConfigurationSelection
{
id: configSelection
visible: isNetworkPrinter && printerConnected
width: visible ? Math.round(base.width * 0.15) : 0
height: UM.Theme.getSize("sidebar_header").height
anchors.top: base.top
anchors.right: parent.right
panelWidth: base.width
}
Loader
{
id: controlItem
anchors.bottom: footerSeparator.top
anchors.top: machineSelection.bottom
anchors.left: base.left
anchors.right: base.right
sourceComponent:
{
if(connectedPrinter != null)
{
if(connectedPrinter.controlItem != null)
{
return connectedPrinter.controlItem
}
}
return null
}
}
Loader
{
anchors.bottom: footerSeparator.top
anchors.top: machineSelection.bottom
anchors.left: base.left
anchors.right: base.right
source:
{
if(controlItem.sourceComponent == null)
{
return "PrintMonitor.qml"
}
else
{
return ""
}
}
}
Rectangle
{
id: footerSeparator
width: parent.width
height: UM.Theme.getSize("sidebar_lining").height
color: UM.Theme.getColor("sidebar_lining")
anchors.bottom: monitorButton.top
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
}
// MonitorButton is actually the bottom footer panel.
MonitorButton
{
id: monitorButton
implicitWidth: base.width
anchors.bottom: parent.bottom
}
SidebarTooltip
{
id: tooltip
}
UM.SettingPropertyProvider
{
id: machineExtruderCount
containerStackId: Cura.MachineManager.activeMachineId
key: "machine_extruder_count"
watchedProperties: [ "value" ]
storeIndex: 0
}
UM.SettingPropertyProvider
{
id: machineHeatedBed
containerStackId: Cura.MachineManager.activeMachineId
key: "machine_heated_bed"
watchedProperties: [ "value" ]
storeIndex: 0
}
// Make the ConfigurationSelector react when the global container changes, otherwise if Cura is not connected to the printer,
// switching printers make no reaction
Connections
{
target: Cura.MachineManager
onGlobalContainerChanged:
{
base.isNetworkPrinter = Cura.MachineManager.activeMachineNetworkKey != ""
base.printerConnected = Cura.MachineManager.printerOutputDevices.length != 0
}
}
}

View File

@ -24,8 +24,6 @@ Rectangle
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property bool monitoringPrint: UM.Controller.activeStage.stageId == "MonitorStage"
property variant printDuration: PrintInformation.currentPrintTime property variant printDuration: PrintInformation.currentPrintTime
property variant printMaterialLengths: PrintInformation.materialLengths property variant printMaterialLengths: PrintInformation.materialLengths
property variant printMaterialWeights: PrintInformation.materialWeights property variant printMaterialWeights: PrintInformation.materialWeights
@ -120,7 +118,7 @@ Rectangle
SidebarHeader { SidebarHeader {
id: header id: header
width: parent.width width: parent.width
visible: !hideSettings && (machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants) && !monitoringPrint visible: !hideSettings && (machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants)
anchors.top: machineSelection.bottom anchors.top: machineSelection.bottom
onShowTooltip: base.showTooltip(item, location, text) onShowTooltip: base.showTooltip(item, location, text)
@ -158,7 +156,7 @@ Rectangle
width: Math.round(parent.width * 0.45) width: Math.round(parent.width * 0.45)
font: UM.Theme.getFont("large") font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
visible: !monitoringPrint && !hideView visible: !hideView
} }
// Settings mode selection toggle // Settings mode selection toggle
@ -185,7 +183,7 @@ Rectangle
} }
} }
visible: !monitoringPrint && !hideSettings && !hideView visible: !hideSettings && !hideView
Component Component
{ {
@ -282,7 +280,7 @@ Rectangle
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: base.left anchors.left: base.left
anchors.right: base.right anchors.right: base.right
visible: !monitoringPrint && !hideSettings visible: !hideSettings
replaceEnter: Transition { replaceEnter: Transition {
PropertyAnimation { PropertyAnimation {
@ -305,47 +303,11 @@ Rectangle
Loader Loader
{ {
id: controlItem
anchors.bottom: footerSeparator.top anchors.bottom: footerSeparator.top
anchors.top: monitoringPrint ? machineSelection.bottom : headerSeparator.bottom anchors.top: headerSeparator.bottom
anchors.left: base.left anchors.left: base.left
anchors.right: base.right anchors.right: base.right
sourceComponent: source: "SidebarContents.qml"
{
if(monitoringPrint && connectedPrinter != null)
{
if(connectedPrinter.controlItem != null)
{
return connectedPrinter.controlItem
}
}
return null
}
}
Loader
{
anchors.bottom: footerSeparator.top
anchors.top: monitoringPrint ? machineSelection.bottom : headerSeparator.bottom
anchors.left: base.left
anchors.right: base.right
source:
{
if(controlItem.sourceComponent == null)
{
if(monitoringPrint)
{
return "PrintMonitor.qml"
} else
{
return "SidebarContents.qml"
}
}
else
{
return ""
}
}
} }
Rectangle Rectangle
@ -367,7 +329,6 @@ Rectangle
anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height anchors.bottomMargin: UM.Theme.getSize("sidebar_margin").height
height: timeDetails.height + costSpec.height height: timeDetails.height + costSpec.height
width: base.width - (saveButton.buttonRowWidth + UM.Theme.getSize("sidebar_margin").width) width: base.width - (saveButton.buttonRowWidth + UM.Theme.getSize("sidebar_margin").width)
visible: !monitoringPrint
clip: true clip: true
Label Label
@ -570,8 +531,7 @@ Rectangle
} }
} }
// SaveButton and MonitorButton are actually the bottom footer panels. // SaveButton is actually the bottom footer panel.
// "!monitoringPrint" currently means "show-settings-mode"
SaveButton SaveButton
{ {
id: saveButton id: saveButton
@ -579,17 +539,6 @@ Rectangle
anchors.top: footerSeparator.bottom anchors.top: footerSeparator.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
visible: !monitoringPrint
}
MonitorButton
{
id: monitorButton
implicitWidth: base.width
anchors.top: footerSeparator.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.bottom: parent.bottom
visible: monitoringPrint
} }
SidebarTooltip SidebarTooltip

View File

@ -17,7 +17,17 @@ Column
property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex; property int currentExtruderIndex: Cura.ExtruderManager.activeExtruderIndex;
property bool currentExtruderVisible: extrudersList.visible; property bool currentExtruderVisible: extrudersList.visible;
property bool printerConnected: Cura.MachineManager.printerConnected property bool printerConnected: Cura.MachineManager.printerConnected
property bool hasManyPrinterTypes: printerConnected ? Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1 : false property bool hasManyPrinterTypes:
{
if (printerConnected)
{
if (Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount != null)
{
return Cura.MachineManager.printerOutputDevices[0].connectedPrintersTypeCount.length > 1;
}
}
return false;
}
property bool buildplateCompatibilityError: !Cura.MachineManager.variantBuildplateCompatible && !Cura.MachineManager.variantBuildplateUsable property bool buildplateCompatibilityError: !Cura.MachineManager.variantBuildplateCompatible && !Cura.MachineManager.variantBuildplateUsable
property bool buildplateCompatibilityWarning: Cura.MachineManager.variantBuildplateUsable property bool buildplateCompatibilityWarning: Cura.MachineManager.variantBuildplateUsable