Remove sidebar controller implementation in favor of stages

This commit is contained in:
ChrisTerBeke 2017-12-06 09:44:30 +01:00
parent a5b99bd862
commit f1b9a17611
5 changed files with 101 additions and 197 deletions

View file

@ -90,7 +90,7 @@ Rectangle
SidebarHeader {
id: header
width: parent.width
visible: (machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariants) && Cura.SidebarController.activeSidebarId == "default"
visible: machineExtruderCount.properties.value > 1 || Cura.MachineManager.hasMaterials || Cura.MachineManager.hasVariantst
onShowTooltip: base.showTooltip(item, location, text)
onHideTooltip: base.hideTooltip()
}
@ -98,7 +98,7 @@ Rectangle
Rectangle {
id: headerSeparator
width: parent.width
visible: settingsModeSelection.visible && header.visible && Cura.SidebarController.activeSidebarId == "default"
visible: settingsModeSelection.visible && header.visible
height: visible ? UM.Theme.getSize("sidebar_lining").height : 0
color: UM.Theme.getColor("sidebar_lining")
anchors.top: header.bottom
@ -115,7 +115,7 @@ Rectangle
width: Math.floor(parent.width * 0.45)
font: UM.Theme.getFont("large")
color: UM.Theme.getColor("text")
visible: !monitoringPrint && !hideView && Cura.SidebarController.activeSidebarId == "default"
visible: !monitoringPrint && !hideView
}
Rectangle {
@ -137,7 +137,7 @@ Rectangle
}
}
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
visible: !monitoringPrint && !hideSettings && !hideView && Cura.SidebarController.activeSidebarId == "default"
visible: !monitoringPrint && !hideSettings && !hideView
Component{
id: wizardDelegate
Button {
@ -218,7 +218,7 @@ Rectangle
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: base.left
anchors.right: base.right
visible: !monitoringPrint && !hideSettings && Cura.SidebarController.activeSidebarId == "default"
visible: !monitoringPrint && !hideSettings
delegate: StackViewDelegate
{
@ -249,29 +249,6 @@ Rectangle
}
}
// The sidebarRepeater exposes sidebar views provided by plugins.
// Whenever a plugin sidebar view is active (e.g. not "default"), that sidebar view is shown.
Repeater
{
id: sidebarRepeater
model: Cura.SidebarViewModel { }
delegate: Loader
{
id: delegate
asynchronous: true
visible: model.active
// dynamically get the component from the sidebar controller or set the default sidebar
sourceComponent: {
if (model.id !== "default") {
return Cura.SidebarController.getSidebarComponent(model.id)
}
}
}
}
Loader
{
id: controlItem

View file

@ -1,65 +0,0 @@
// 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
{
id: printerOutputSection
UM.I18nCatalog {
id: catalog
name: "cura"
}
color: UM.Theme.getColor("sidebar")
// status
property bool isMonitoring: false
// printer data
property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0
property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands
property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null
property int backendState: UM.Backend.state
// print job data
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
// helper function for padding pretty time
function strPadLeft(string, pad, length) {
return (new Array(length + 1).join(pad) + string).slice(-length);
}
// convert a timestamp to a human readable pretty time
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
}
// TODO: change name of this component
MonitorButton
{
id: monitorButton
implicitWidth: base.width
anchors.top: footerSeparator.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.bottom: parent.bottom
visible: monitoringPrint
}
}

View file

@ -67,91 +67,109 @@ Rectangle
anchors.rightMargin: UM.Theme.getSize("default_margin").width
spacing: UM.Theme.getSize("default_margin").width
Button
// The topbar is dynamically filled with all available stages
Repeater
{
id: showSettings
height: UM.Theme.getSize("sidebar_header").height
text: catalog.i18nc("@title:tab", "Prepare")
checkable: true
checked: isChecked()
exclusiveGroup: sidebarHeaderBarGroup
style: UM.Theme.styles.topbar_header_tab
id: stagesMenu
// We use a Qt.binding to re-bind the checkbox state after manually setting it
// https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
onClicked: {
base.stopMonitoringPrint()
checked = Qt.binding(isChecked)
}
model: UM.StageModel{}
function isChecked () {
return !base.monitoringPrint
}
property color overlayColor: "transparent"
property string overlayIconSource: ""
}
Button
{
id: showMonitor
width: UM.Theme.getSize("topbar_button").width
height: UM.Theme.getSize("sidebar_header").height
text: catalog.i18nc("@title:tab", "Monitor")
checkable: true
checked: isChecked()
exclusiveGroup: sidebarHeaderBarGroup
style: UM.Theme.styles.topbar_header_tab_no_overlay
// We use a Qt.binding to re-bind the checkbox state after manually setting it
// https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
onClicked: {
base.startMonitoringPrint()
checked = Qt.binding(isChecked)
}
function isChecked () {
return base.monitoringPrint
}
property string iconSource:
delegate: Button
{
if (!printerConnected)
{
return UM.Theme.getIcon("tab_status_unknown");
}
else if (!printerAcceptsCommands)
{
return UM.Theme.getIcon("tab_status_unknown");
}
if (Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
{
return UM.Theme.getIcon("tab_status_busy");
}
switch (Cura.MachineManager.printerOutputDevices[0].jobState)
{
case "printing":
case "pre_print":
case "pausing":
case "resuming":
return UM.Theme.getIcon("tab_status_busy");
case "wait_cleanup":
return UM.Theme.getIcon("tab_status_finished");
case "ready":
case "":
return UM.Theme.getIcon("tab_status_connected")
case "paused":
return UM.Theme.getIcon("tab_status_paused")
case "error":
return UM.Theme.getIcon("tab_status_stopped")
default:
return UM.Theme.getIcon("tab_status_unknown")
}
text: model.name
checkable: true
checked: model.active
exclusiveGroup: sidebarHeaderBarGroup
style: UM.Theme.styles.topbar_header_tab
height: UM.Theme.getSize("sidebar_header").height
}
}
// Button
// {
// id: showSettings
// height: UM.Theme.getSize("sidebar_header").height
// text: catalog.i18nc("@title:tab", "Prepare")
// checkable: true
// checked: isChecked()
// exclusiveGroup: sidebarHeaderBarGroup
// style: UM.Theme.styles.topbar_header_tab
//
// // We use a Qt.binding to re-bind the checkbox state after manually setting it
// // https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
// onClicked: {
// base.stopMonitoringPrint()
// checked = Qt.binding(isChecked)
// }
//
// function isChecked () {
// return !base.monitoringPrint
// }
//
// property color overlayColor: "transparent"
// property string overlayIconSource: ""
// }
// Button
// {
// id: showMonitor
// width: UM.Theme.getSize("topbar_button").width
// height: UM.Theme.getSize("sidebar_header").height
// text: catalog.i18nc("@title:tab", "Monitor")
// checkable: true
// checked: isChecked()
// exclusiveGroup: sidebarHeaderBarGroup
// style: UM.Theme.styles.topbar_header_tab_no_overlay
//
// // We use a Qt.binding to re-bind the checkbox state after manually setting it
// // https://stackoverflow.com/questions/38798450/qt-5-7-qml-why-are-my-checkbox-property-bindings-disappearing
// onClicked: {
// base.startMonitoringPrint()
// checked = Qt.binding(isChecked)
// }
//
// function isChecked () {
// return base.monitoringPrint
// }
//
// property string iconSource:
// {
// if (!printerConnected)
// {
// return UM.Theme.getIcon("tab_status_unknown");
// }
// else if (!printerAcceptsCommands)
// {
// return UM.Theme.getIcon("tab_status_unknown");
// }
//
// if (Cura.MachineManager.printerOutputDevices[0].printerState == "maintenance")
// {
// return UM.Theme.getIcon("tab_status_busy");
// }
//
// switch (Cura.MachineManager.printerOutputDevices[0].jobState)
// {
// case "printing":
// case "pre_print":
// case "pausing":
// case "resuming":
// return UM.Theme.getIcon("tab_status_busy");
// case "wait_cleanup":
// return UM.Theme.getIcon("tab_status_finished");
// case "ready":
// case "":
// return UM.Theme.getIcon("tab_status_connected")
// case "paused":
// return UM.Theme.getIcon("tab_status_paused")
// case "error":
// return UM.Theme.getIcon("tab_status_stopped")
// default:
// return UM.Theme.getIcon("tab_status_unknown")
// }
// }
// }
ExclusiveGroup { id: sidebarHeaderBarGroup }
}