From 2d044a37ae364accfbd86dcf25c026046e0a7228 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Wed, 6 Dec 2017 13:33:05 +0100 Subject: [PATCH] Sidebar and main view via loader --- plugins/MonitorStage/MonitorStage.py | 7 ++++ resources/qml/Cura.qml | 45 ++++++++++---------------- resources/qml/Settings/SettingView.qml | 2 +- resources/qml/Sidebar.qml | 2 +- resources/qml/SidebarHeader.qml | 8 ++--- resources/qml/Topbar.qml | 45 ++++++++++++-------------- 6 files changed, 50 insertions(+), 59 deletions(-) diff --git a/plugins/MonitorStage/MonitorStage.py b/plugins/MonitorStage/MonitorStage.py index 8b98f2872c..7cd6fe5063 100644 --- a/plugins/MonitorStage/MonitorStage.py +++ b/plugins/MonitorStage/MonitorStage.py @@ -1,6 +1,8 @@ # Copyright (c) 2017 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. +import os.path from UM.Application import Application +from UM.Resources import Resources from cura.Stages.CuraStage import CuraStage @@ -10,6 +12,11 @@ class MonitorStage(CuraStage): def __init__(self): super().__init__() Application.getInstance().engineCreatedSignal.connect(self._engineCreated) + # TODO: connect output device state to icon source def _engineCreated(self): + # Note: 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), "Sidebar.qml") + sidebar_component = Application.getInstance().createQmlComponent(sidebar_component_path) + self.addDisplayComponent("sidebar", sidebar_component) self.setIconSource(Application.getInstance().getTheme().getIcon("tab_status_connected")) diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 3c9ca25b05..662de05063 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -358,15 +358,13 @@ UM.MainWindow Topbar { id: topbar - anchors.left:parent.left + anchors.left: parent.left anchors.right: parent.right anchors.top: parent.top - monitoringPrint: base.showPrintMonitor - onStartMonitoringPrint: base.showPrintMonitor = true - onStopMonitoringPrint: base.showPrintMonitor = false } - Loader { + Loader + { id: sidebar anchors @@ -382,39 +380,30 @@ UM.MainWindow sourceComponent: UM.Controller.activeStage.sidebarComponent } - Rectangle + Loader { - id: viewportOverlay + id: main - color: UM.Theme.getColor("viewport_overlay") anchors { top: topbar.bottom bottom: parent.bottom - left:parent.left + left: parent.left right: sidebar.left +// horizontalCenter: parent.horizontalCenter +// verticalCenter: parent.verticalCenter +// horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2 +// verticalCenterOffset: UM.Theme.getSize("sidebar_header").height / 2 } - visible: opacity > 0 - opacity: base.showPrintMonitor ? 1 : 0 - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.AllButtons +// MouseArea +// { +// anchors.fill: parent +// acceptedButtons: Qt.AllButtons +// onWheel: wheel.accepted = true +// } - onWheel: wheel.accepted = true - } - } - - Loader - { - sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem: null - visible: base.showPrintMonitor - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenterOffset: - UM.Theme.getSize("sidebar").width / 2 - anchors.verticalCenterOffset: UM.Theme.getSize("sidebar_header").height / 2 - property real maximumWidth: viewportOverlay.width - property real maximumHeight: viewportOverlay.height + sourceComponent: UM.Controller.activeStage.mainComponent } UM.MessageStack diff --git a/resources/qml/Settings/SettingView.qml b/resources/qml/Settings/SettingView.qml index 1ebb5cc40e..2079710315 100644 --- a/resources/qml/Settings/SettingView.qml +++ b/resources/qml/Settings/SettingView.qml @@ -24,7 +24,7 @@ Item { id: globalProfileRow height: UM.Theme.getSize("sidebar_setup").height - visible: !sidebar.monitoringPrint && !sidebar.hideSettings +// visible: !sidebar.monitoringPrint && !sidebar.hideSettings anchors { diff --git a/resources/qml/Sidebar.qml b/resources/qml/Sidebar.qml index 7429ef26df..992ad1f848 100644 --- a/resources/qml/Sidebar.qml +++ b/resources/qml/Sidebar.qml @@ -26,7 +26,7 @@ Component property var connectedPrinter: Cura.MachineManager.printerOutputDevices.length >= 1 ? Cura.MachineManager.printerOutputDevices[0] : null property int backendState: UM.Backend.state - property bool monitoringPrint: false + property bool monitoringPrint: UM.Controller.activeStage.id == "MonitorStage" property variant printDuration: PrintInformation.currentPrintTime property variant printMaterialLengths: PrintInformation.materialLengths diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 3e1e85824a..0f0572a48a 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -40,7 +40,7 @@ Column id: extruderSelectionRow width: parent.width height: Math.floor(UM.Theme.getSize("sidebar_tabs").height * 2 / 3) - visible: machineExtruderCount.properties.value > 1 && !sidebar.monitoringPrint + visible: machineExtruderCount.properties.value > 1 anchors { @@ -229,7 +229,7 @@ Column { id: materialRow height: UM.Theme.getSize("sidebar_setup").height - visible: Cura.MachineManager.hasMaterials && !sidebar.monitoringPrint && !sidebar.hideSettings + visible: Cura.MachineManager.hasMaterials anchors { @@ -279,7 +279,7 @@ Column { id: variantRow height: UM.Theme.getSize("sidebar_setup").height - visible: Cura.MachineManager.hasVariants && !sidebar.monitoringPrint && !sidebar.hideSettings + visible: Cura.MachineManager.hasVariants anchors { @@ -319,7 +319,7 @@ Column { id: materialInfoRow height: Math.floor(UM.Theme.getSize("sidebar_setup").height / 2) - visible: (Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials) && !sidebar.monitoringPrint && !sidebar.hideSettings + visible: Cura.MachineManager.hasVariants || Cura.MachineManager.hasMaterials anchors { diff --git a/resources/qml/Topbar.qml b/resources/qml/Topbar.qml index 5817aff13b..d50cc64608 100644 --- a/resources/qml/Topbar.qml +++ b/resources/qml/Topbar.qml @@ -16,27 +16,22 @@ Rectangle anchors.left: parent.left anchors.right: parent.right height: UM.Theme.getSize("sidebar_header").height - color: base.monitoringPrint ? UM.Theme.getColor("topbar_background_color_monitoring") : UM.Theme.getColor("topbar_background_color") + color: UM.Controller.activeStage.id == "MonitorStage" ? UM.Theme.getColor("topbar_background_color_monitoring") : UM.Theme.getColor("topbar_background_color") property bool printerConnected: Cura.MachineManager.printerOutputDevices.length != 0 property bool printerAcceptsCommands: printerConnected && Cura.MachineManager.printerOutputDevices[0].acceptsCommands - property bool monitoringPrint: false - - // outgoing signal - signal startMonitoringPrint() - signal stopMonitoringPrint() // update monitoring status when event was triggered outside topbar - Component.onCompleted: { - startMonitoringPrint.connect(function () { - base.monitoringPrint = true - UM.Controller.disableModelRendering() - }) - stopMonitoringPrint.connect(function () { - base.monitoringPrint = false - UM.Controller.enableModelRendering() - }) - } +// Component.onCompleted: { +// startMonitoringPrint.connect(function () { +// base.monitoringPrint = true +// UM.Controller.disableModelRendering() +// }) +// stopMonitoringPrint.connect(function () { +// base.monitoringPrint = false +// UM.Controller.enableModelRendering() +// }) +// } UM.I18nCatalog { @@ -79,9 +74,10 @@ Rectangle text: model.name checkable: true checked: model.active - exclusiveGroup: sidebarHeaderBarGroup + exclusiveGroup: topbarMenuGroup style: UM.Theme.styles.topbar_header_tab height: UM.Theme.getSize("sidebar_header").height + width: UM.Theme.getSize("topbar_button").width onClicked: UM.Controller.setActiveStage(model.id) iconSource: model.stage.iconSource @@ -90,6 +86,8 @@ Rectangle } } + ExclusiveGroup { id: topbarMenuGroup } + // Button // { // id: showMonitor @@ -149,8 +147,6 @@ Rectangle // } // } // } - - ExclusiveGroup { id: sidebarHeaderBarGroup } } ToolButton @@ -218,17 +214,16 @@ Rectangle menu: PrinterMenu { } } - //View orientation Item + // View orientation Item Row { id: viewOrientationControl height: 30 - spacing: 2 + visible: UM.Controller.activeStage.id != "MonitorStage" - visible: !base.monitoringPrint - - anchors { + anchors + { verticalCenter: base.verticalCenter right: viewModeButton.right rightMargin: UM.Theme.getSize("default_margin").width + viewModeButton.width @@ -306,7 +301,7 @@ Rectangle } style: UM.Theme.styles.combobox - visible: !base.monitoringPrint + visible: UM.Controller.activeStage.id != "MonitorStage" model: UM.ViewModel { } textRole: "name"