Hide action panel when displaying a stage with a background

This is not the worst hack ever, but it's quite a hack.

Contributes to issue CURA-6054.
This commit is contained in:
Ghostkeeper 2019-01-03 16:02:49 +01:00
parent 6eca0ce69f
commit 798c1f198c
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276
2 changed files with 51 additions and 23 deletions

View file

@ -1,4 +1,5 @@
// Copyright (c) 2017 Ultimaker B.V.
// Copyright (c) 2018 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.
import QtQuick 2.10
import QtQuick.Controls 1.4
@ -7,31 +8,27 @@ 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
{
// 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
// This mouse area is to prevent mouse clicks to be passed onto the scene.
MouseArea
{
id: viewportOverlay
color: UM.Theme.getColor("viewport_overlay")
anchors.fill: parent
// This mouse area is to prevent mouse clicks to be passed onto the scene.
MouseArea
{
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onWheel: wheel.accepted = true
}
// Disable dropping files into Cura when the monitor page is active
DropArea
{
anchors.fill: parent
}
acceptedButtons: Qt.AllButtons
onWheel: wheel.accepted = true
}
// Disable dropping files into Cura when the monitor page is active
DropArea
{
anchors.fill: parent
}
Loader
{
id: monitorViewComponent
@ -45,4 +42,4 @@ Item
sourceComponent: Cura.MachineManager.printerOutputDevices.length > 0 ? Cura.MachineManager.printerOutputDevices[0].monitorItem : null
}
}
}

View file

@ -252,7 +252,21 @@ UM.MainWindow
anchors.bottom: parent.bottom
anchors.rightMargin: UM.Theme.getSize("thick_margin").width
anchors.bottomMargin: UM.Theme.getSize("thick_margin").height
visible: CuraApplication.platformActivity
/*
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
@ -818,4 +832,21 @@ UM.MainWindow
}
}
}
/**
* Function to check whether a QML object has a certain type.
* Taken from StackOverflow: https://stackoverflow.com/a/28384228 and
* adapted to our code style.
* Licensed under CC BY-SA 3.0.
* \param obj The QtObject to get the name of.
* \param class_name (str) The name of the class to check against. Has to be
* the QtObject class name, not the QML entity name.
*/
function qmlTypeOf(obj, class_name)
{
//className plus "(" is the class instance without modification.
//className plus "_QML" is the class instance with user-defined properties.
var str = obj.toString();
return str.indexOf(class_name + "(") == 0 || str.indexOf(class_name + "_QML") == 0;
}
}