From 5992e66ed670c038f3a05a58840321686076fdee Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 4 Feb 2019 15:08:59 +0100 Subject: [PATCH 1/2] Move action panel into each stage They can then decide if it needs to be there. For instance, the monitor stage doesn't want to have this panel. Also each stage can position it where they like, and in the near future I'll make a feature to let it decide whether or not to show the preview button. Contributes to issue CURA-6086. --- plugins/PrepareStage/PrepareMain.qml | 24 +++++++++++++++++++ plugins/PrepareStage/PrepareStage.py | 8 +++---- plugins/PreviewStage/PreviewMain.qml | 21 ++++++++++++---- .../qml/ActionPanel/ActionPanelWidget.qml | 3 ++- resources/qml/Cura.qml | 24 ------------------- 5 files changed, 46 insertions(+), 34 deletions(-) create mode 100644 plugins/PrepareStage/PrepareMain.qml diff --git a/plugins/PrepareStage/PrepareMain.qml b/plugins/PrepareStage/PrepareMain.qml new file mode 100644 index 0000000000..bfeb62f0e8 --- /dev/null +++ b/plugins/PrepareStage/PrepareMain.qml @@ -0,0 +1,24 @@ +//Copyright (c) 2019 Ultimaker B.V. +//Cura is released under the terms of the LGPLv3 or higher. + +import QtQuick 2.4 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.1 +import QtQuick.Controls.Styles 1.1 + +import UM 1.0 as UM +import Cura 1.0 as Cura + +Item +{ + id: prepareMain + + Cura.ActionPanelWidget + { + id: actionPanelWidget + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.bottomMargin: UM.Theme.getSize("thick_margin").height + } +} \ No newline at end of file diff --git a/plugins/PrepareStage/PrepareStage.py b/plugins/PrepareStage/PrepareStage.py index b0f862dc48..c2dee9693b 100644 --- a/plugins/PrepareStage/PrepareStage.py +++ b/plugins/PrepareStage/PrepareStage.py @@ -1,13 +1,11 @@ -# Copyright (c) 2018 Ultimaker B.V. +# Copyright (c) 2019 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. + import os.path from UM.Application import Application from UM.PluginRegistry import PluginRegistry -from UM.Resources import Resources from cura.Stages.CuraStage import CuraStage - - ## Stage for preparing model (slicing). class PrepareStage(CuraStage): def __init__(self, parent = None): @@ -16,4 +14,6 @@ class PrepareStage(CuraStage): def _engineCreated(self): menu_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMenu.qml") + main_component_path = os.path.join(PluginRegistry.getInstance().getPluginPath("PrepareStage"), "PrepareMain.qml") self.addDisplayComponent("menu", menu_component_path) + self.addDisplayComponent("main", main_component_path) \ No newline at end of file diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index 04241783e9..eac1071822 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2019 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.4 @@ -9,10 +9,21 @@ import QtQuick.Controls.Styles 1.1 import UM 1.0 as UM import Cura 1.0 as Cura - -Loader +Item { - id: previewMain + Loader + { + id: previewMain - source: UM.Controller.activeView != null && UM.Controller.activeView.mainComponent != null ? UM.Controller.activeView.mainComponent : "" + source: UM.Controller.activeView != null && UM.Controller.activeView.mainComponent != null ? UM.Controller.activeView.mainComponent : "" + } + + Cura.ActionPanelWidget + { + id: actionPanelWidget + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: UM.Theme.getSize("thick_margin").width + anchors.bottomMargin: UM.Theme.getSize("thick_margin").height + } } \ No newline at end of file diff --git a/resources/qml/ActionPanel/ActionPanelWidget.qml b/resources/qml/ActionPanel/ActionPanelWidget.qml index 1f68fe90ed..af27adf604 100644 --- a/resources/qml/ActionPanel/ActionPanelWidget.qml +++ b/resources/qml/ActionPanel/ActionPanelWidget.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2019 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -17,6 +17,7 @@ Item id: base width: childrenRect.width height: childrenRect.height + visible: CuraApplication.platformActivity Rectangle { diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index 4aca41f6a1..f9909d8308 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -246,30 +246,6 @@ UM.MainWindow } } - Cura.ActionPanelWidget - { - id: actionPanelWidget - anchors.right: parent.right - anchors.bottom: parent.bottom - anchors.rightMargin: UM.Theme.getSize("thick_margin").width - anchors.bottomMargin: UM.Theme.getSize("thick_margin").height - - /* - Show this panel only if there is something on the build plate, and there is NOT an opaque item in front of the build plate. - This cannot be solved by Z indexing! If you want to try solving this, please increase this counter when you're done: - Number of people having tried to fix this by z-indexing: 2 - The problem arises from the following render order requirements: - - The stage menu must be rendered above the stage main. - - The stage main must be rendered above the action panel (because the monitor page must be rendered above the action panel). - - The action panel must be rendered above the expandable components drop-down. - However since the expandable components drop-downs are child elements of the stage menu, - they can't be rendered lower than elements that are lower than the stage menu. - Therefore we opted to forego the second requirement and hide the action panel instead when something obscures it (except the expandable components). - We assume that QQuickRectangles are always opaque and any other item is not. - */ - visible: CuraApplication.platformActivity && (main.item == null || !qmlTypeOf(main.item, "QQuickRectangle")) - } - Loader { // A stage can control this area. If nothing is set, it will therefore show the 3D view. From a831cfa558b3025ac2b53e9951ceb670027fa0f7 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 4 Feb 2019 15:19:09 +0100 Subject: [PATCH 2/2] Configure whether preview shortcut is visible from ActionPanelWidget property This way it's more dynamic: You don't need to hardcode the plug-in name in the widget to see whether or not it's visible. Contributes to issue CURA-6086. --- plugins/PreviewStage/PreviewMain.qml | 1 + resources/qml/ActionPanel/ActionPanelWidget.qml | 9 +++++++++ resources/qml/ActionPanel/OutputProcessWidget.qml | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/PreviewStage/PreviewMain.qml b/plugins/PreviewStage/PreviewMain.qml index eac1071822..1600df6d4f 100644 --- a/plugins/PreviewStage/PreviewMain.qml +++ b/plugins/PreviewStage/PreviewMain.qml @@ -25,5 +25,6 @@ Item anchors.bottom: parent.bottom anchors.rightMargin: UM.Theme.getSize("thick_margin").width anchors.bottomMargin: UM.Theme.getSize("thick_margin").height + hasPreviewButton: false } } \ No newline at end of file diff --git a/resources/qml/ActionPanel/ActionPanelWidget.qml b/resources/qml/ActionPanel/ActionPanelWidget.qml index af27adf604..4d61380c99 100644 --- a/resources/qml/ActionPanel/ActionPanelWidget.qml +++ b/resources/qml/ActionPanel/ActionPanelWidget.qml @@ -19,6 +19,8 @@ Item height: childrenRect.height visible: CuraApplication.platformActivity + property bool hasPreviewButton: true + Rectangle { id: actionPanelWidget @@ -47,6 +49,13 @@ Item rightMargin: UM.Theme.getSize("thick_margin").width } sourceComponent: actionPanelWidget.outputAvailable ? outputProcessWidget : sliceProcessWidget + onLoaded: + { + if(actionPanelWidget.outputAvailable) + { + loader.item.hasPreviewButton = base.hasPreviewButton; + } + } } Component diff --git a/resources/qml/ActionPanel/OutputProcessWidget.qml b/resources/qml/ActionPanel/OutputProcessWidget.qml index 63974d7f34..f4505c620c 100644 --- a/resources/qml/ActionPanel/OutputProcessWidget.qml +++ b/resources/qml/ActionPanel/OutputProcessWidget.qml @@ -1,4 +1,4 @@ -// Copyright (c) 2018 Ultimaker B.V. +// Copyright (c) 2019 Ultimaker B.V. // Cura is released under the terms of the LGPLv3 or higher. import QtQuick 2.7 @@ -19,6 +19,7 @@ Column spacing: UM.Theme.getSize("thin_margin").height property bool preSlicedData: PrintInformation.preSliced + property alias hasPreviewButton: previewStageShortcut.visible UM.I18nCatalog { @@ -120,7 +121,6 @@ Column toolTipContentAlignment: Cura.ToolTip.ContentAlignment.AlignLeft onClicked: UM.Controller.setActiveStage("PreviewStage") - visible: UM.Controller.activeStage != null && UM.Controller.activeStage.stageId != "PreviewStage" } Cura.OutputDevicesActionButton