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

@ -0,0 +1,40 @@
// Copyright (c) 2017 Ultimaker B.V.
import QtQuick 2.10
import QtQuick.Controls 1.4
import UM 1.3 as UM
import Cura 1.0 as Cura
Item
{
// We show a nice overlay on the 3D viewer when the current output device has no monitor view
Rectangle
{
id: viewportOverlay
color: UM.Theme.getColor("viewport_overlay")
anchors.fill: parent
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onWheel: wheel.accepted = true
}
}
Loader
{
id: monitorViewComponent
anchors.fill: parent
height: parent.height
property real maximumWidth: parent.width
property real maximumHeight: parent.height
sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem: null
}
}

View file

@ -1,64 +0,0 @@
// Copyright (c) 2017 Ultimaker B.V.
import QtQuick 2.10
import QtQuick.Controls 1.4
import UM 1.3 as UM
import Cura 1.0 as Cura
Item
{
// parent could be undefined as this component is not visible at all times
width: parent ? parent.width : 0
height: parent ? parent.height : 0
// We show a nice overlay on the 3D viewer when the current output device has no monitor view
Rectangle
{
id: viewportOverlay
color: UM.Theme.getColor("viewport_overlay")
width: parent.width
height: parent.height
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onWheel: wheel.accepted = true
}
}
Loader
{
id: monitorViewComponent
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: parent.left
// If the sidebar is not set, the view should take the complete space.
property var widthFactor: monitorSidebarComponent.source == "" ? 1.0 : 0.7
width: Math.round(parent.width * widthFactor)
height: parent.height
property real maximumWidth: parent.width
property real maximumHeight: parent.height
sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem: null
}
Loader
{
id: monitorSidebarComponent
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: monitorViewComponent.right
anchors.right: parent.right
source: UM.Controller.activeStage.sidebarComponent != null ? UM.Controller.activeStage.sidebarComponent : ""
}
}

View file

@ -0,0 +1,14 @@
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.7
import QtQuick.Controls 2.3
import UM 1.3 as UM
import Cura 1.1 as Cura
Item
{
signal showTooltip(Item item, point location, string text)
signal hideTooltip()
}

View file

@ -65,15 +65,10 @@ class MonitorStage(CuraStage):
# We can only connect now, as we need to be sure that everything is loaded (plugins get created quite early)
Application.getInstance().getMachineManager().outputDevicesChanged.connect(self._onOutputDevicesChanged)
self._onOutputDevicesChanged()
self._updateMainOverlay()
self._updateSidebar()
def _updateMainOverlay(self):
main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("MonitorStage"),
"MonitorMainView.qml")
self.addDisplayComponent("main", main_component_path)
def _updateSidebar(self):
sidebar_component_path = os.path.join(Resources.getPath(Application.getInstance().ResourceTypes.QmlFiles),
"MonitorSidebar.qml")
self.addDisplayComponent("sidebar", sidebar_component_path)
plugin_path = Application.getInstance().getPluginRegistry().getPluginPath(self.getPluginId())
if plugin_path is not None:
menu_component_path = os.path.join(plugin_path, "MonitorMenu.qml")
main_component_path = os.path.join(plugin_path, "MonitorMain.qml")
self.addDisplayComponent("menu", menu_component_path)
self.addDisplayComponent("main", main_component_path)