Disable printer cards which are not in focus

Contributes to CL-1151
This commit is contained in:
Ian Paschal 2018-12-14 16:55:48 +01:00
parent 2112681217
commit e877b47e22
4 changed files with 25 additions and 8 deletions

View file

@ -8,11 +8,13 @@ import UM 1.3 as UM
import Cura 1.0 as Cura import Cura 1.0 as Cura
Rectangle { Rectangle {
id: base
property var iconSource: null; property var iconSource: null;
color: "#0a0850" // TODO: Theme! color: "#0a0850" // TODO: Theme!
height: width; height: width;
radius: Math.round(0.5 * width); radius: Math.round(0.5 * width);
width: 24 * screenScaleFactor; width: 24 * screenScaleFactor;
property var enabled: true
UM.RecolorImage { UM.RecolorImage {
id: icon; id: icon;
@ -29,12 +31,18 @@ Rectangle {
MouseArea { MouseArea {
id: clickArea; id: clickArea;
anchors.fill: parent; anchors.fill: parent;
hoverEnabled: true; hoverEnabled: base.enabled
onClicked: { onClicked: {
if (OutputDevice.activeCameraUrl != "") { if (base.enabled)
OutputDevice.setActiveCameraUrl(""); {
} else { if (OutputDevice.activeCameraUrl != "")
OutputDevice.setActiveCameraUrl(modelData.cameraUrl); {
OutputDevice.setActiveCameraUrl("")
}
else
{
OutputDevice.setActiveCameraUrl(modelData.cameraUrl)
}
} }
} }
} }

View file

@ -124,6 +124,7 @@ Item
MonitorPrinterCard MonitorPrinterCard
{ {
printer: modelData printer: modelData
enabled: model.index == currentIndex
} }
} }
} }

View file

@ -25,6 +25,11 @@ Item
property var borderSize: 1 * screenScaleFactor // TODO: Theme, and remove from here property var borderSize: 1 * screenScaleFactor // TODO: Theme, and remove from here
// If the printer card's controls are enabled. This is used by the carousel
// to prevent opening the context menu or camera while the printer card is not
// "in focus"
property var enabled: true
width: 834 * screenScaleFactor // TODO: Theme! width: 834 * screenScaleFactor // TODO: Theme!
height: childrenRect.height height: childrenRect.height
@ -124,6 +129,7 @@ Item
printJob: printer.activePrintJob printJob: printer.activePrintJob
width: 36 * screenScaleFactor // TODO: Theme! width: 36 * screenScaleFactor // TODO: Theme!
height: 36 * screenScaleFactor // TODO: Theme! height: 36 * screenScaleFactor // TODO: Theme!
enabled: base.enabled
} }
CameraButton CameraButton
{ {
@ -136,6 +142,7 @@ Item
bottomMargin: 20 * screenScaleFactor // TODO: Theme! bottomMargin: 20 * screenScaleFactor // TODO: Theme!
} }
iconSource: "../svg/icons/camera.svg" iconSource: "../svg/icons/camera.svg"
enabled: base.enabled
} }
} }
@ -320,7 +327,7 @@ Item
implicitHeight: 32 * screenScaleFactor // TODO: Theme! implicitHeight: 32 * screenScaleFactor // TODO: Theme!
implicitWidth: 96 * screenScaleFactor // TODO: Theme! implicitWidth: 96 * screenScaleFactor // TODO: Theme!
visible: printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0 visible: printer.activePrintJob && printer.activePrintJob.configurationChanges.length > 0
onClicked: overrideConfirmationDialog.open() onClicked: base.enabled ? overrideConfirmationDialog.open() : {}
} }
} }

View file

@ -13,6 +13,7 @@ Item {
property var printJob: null; property var printJob: null;
property var started: isStarted(printJob); property var started: isStarted(printJob);
property var assigned: isAssigned(printJob); property var assigned: isAssigned(printJob);
property var enabled: true
Button { Button {
id: button; id: button;
@ -31,8 +32,8 @@ Item {
verticalAlignment: Text.AlignVCenter; verticalAlignment: Text.AlignVCenter;
} }
height: width; height: width;
hoverEnabled: true; hoverEnabled: base.enabled
onClicked: parent.switchPopupState(); onClicked: base.enabled ? parent.switchPopupState() : {}
text: "\u22EE"; //Unicode; Three stacked points. text: "\u22EE"; //Unicode; Three stacked points.
visible: { visible: {
if (!printJob) { if (!printJob) {