mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 15:37:27 -06:00
Monitor tab refactor + skeleton loading
Contributes to CL-1051
This commit is contained in:
parent
7c01e632df
commit
97fa5094ce
9 changed files with 348 additions and 505 deletions
|
@ -9,7 +9,9 @@ import UM 1.3 as UM
|
|||
|
||||
Item {
|
||||
id: root;
|
||||
|
||||
property var printJob: null;
|
||||
property var running: isRunning(printJob);
|
||||
|
||||
Button {
|
||||
id: button;
|
||||
|
@ -36,164 +38,165 @@ Item {
|
|||
|
||||
Popup {
|
||||
id: popup;
|
||||
background: Item {
|
||||
height: popup.height;
|
||||
width: popup.width;
|
||||
|
||||
DropShadow {
|
||||
anchors.fill: pointedRectangle;
|
||||
color: "#3F000000"; // 25% shadow
|
||||
radius: 5;
|
||||
source: pointedRectangle;
|
||||
transparentBorder: true;
|
||||
verticalOffset: 2;
|
||||
}
|
||||
|
||||
Item {
|
||||
id: pointedRectangle
|
||||
width: parent.width - 10 * screenScaleFactor; // Because of the shadow
|
||||
height: parent.height - 10 * screenScaleFactor; // Because of the shadow
|
||||
anchors.horizontalCenter: parent.horizontalCenter;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
|
||||
Rectangle {
|
||||
id: point
|
||||
anchors.right: bloop.right;
|
||||
anchors.rightMargin: 24;
|
||||
color: UM.Theme.getColor("setting_control");
|
||||
height: 14 * screenScaleFactor;
|
||||
transform: Rotation {
|
||||
angle: 45;
|
||||
}
|
||||
width: 14 * screenScaleFactor;
|
||||
y: 1;
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bloop
|
||||
anchors {
|
||||
bottom: parent.bottom;
|
||||
bottomMargin: 8 * screenScaleFactor; // Because of the shadow
|
||||
top: parent.top;
|
||||
topMargin: 8 * screenScaleFactor; // Because of the shadow + point
|
||||
}
|
||||
color: UM.Theme.getColor("setting_control");
|
||||
width: parent.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
clip: true;
|
||||
closePolicy: Popup.CloseOnPressOutside;
|
||||
contentItem: Column {
|
||||
id: popupOptions;
|
||||
anchors {
|
||||
top: parent.top;
|
||||
topMargin: UM.Theme.getSize("default_margin").height + 10 * screenScaleFactor; // Account for the point of the box
|
||||
}
|
||||
height: childrenRect.height + spacing * popupOptions.children.length + UM.Theme.getSize("default_margin").height;
|
||||
spacing: Math.floor(UM.Theme.getSize("default_margin").height / 2);
|
||||
width: parent.width;
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
enabled: printJob && !running ? OutputDevice.queuedPrintJobs[0].key != printJob.key : false;
|
||||
onClicked: {
|
||||
sendToTopConfirmationDialog.visible = true;
|
||||
popup.close();
|
||||
}
|
||||
text: catalog.i18nc("@label", "Move to top");
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
enabled: printJob && !running;
|
||||
onClicked: {
|
||||
deleteConfirmationDialog.visible = true;
|
||||
popup.close();
|
||||
}
|
||||
text: catalog.i18nc("@label", "Delete");
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
enabled: printJob && running;
|
||||
onClicked: {
|
||||
if (printJob.state == "paused") {
|
||||
printJob.setState("print");
|
||||
} else if(printJob.state == "printing") {
|
||||
printJob.setState("pause");
|
||||
}
|
||||
popup.close();
|
||||
}
|
||||
text: printJob && printJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause");
|
||||
}
|
||||
|
||||
PrintJobContextMenuItem {
|
||||
enabled: printJob && running;
|
||||
onClicked: {
|
||||
abortConfirmationDialog.visible = true;
|
||||
popup.close();
|
||||
}
|
||||
text: catalog.i18nc("@label", "Abort");
|
||||
}
|
||||
}
|
||||
enter: Transition {
|
||||
NumberAnimation {
|
||||
duration: 75;
|
||||
property: "visible";
|
||||
}
|
||||
}
|
||||
exit: Transition {
|
||||
NumberAnimation {
|
||||
duration: 75;
|
||||
property: "visible";
|
||||
}
|
||||
}
|
||||
height: contentItem.height + 2 * padding;
|
||||
onClosed: visible = false;
|
||||
onOpened: visible = true;
|
||||
padding: 5 * screenScaleFactor; // Because shadow
|
||||
transformOrigin: Popup.Top;
|
||||
visible: false;
|
||||
width: 182 * screenScaleFactor;
|
||||
x: (button.width - width) + 26 * screenScaleFactor;
|
||||
y: button.height + 5 * screenScaleFactor; // Because shadow
|
||||
contentItem: Item {
|
||||
width: popup.width
|
||||
height: childrenRect.height + 36 * screenScaleFactor
|
||||
anchors.topMargin: 10 * screenScaleFactor
|
||||
anchors.bottomMargin: 10 * screenScaleFactor
|
||||
Button {
|
||||
id: sendToTopButton
|
||||
text: catalog.i18nc("@label", "Move to top")
|
||||
onClicked:
|
||||
{
|
||||
sendToTopConfirmationDialog.visible = true;
|
||||
popup.close();
|
||||
}
|
||||
width: parent.width
|
||||
enabled: printJob ? OutputDevice.queuedPrintJobs[0].key != printJob.key : false;
|
||||
visible: enabled
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 18 * screenScaleFactor
|
||||
height: visible ? 39 * screenScaleFactor : 0 * screenScaleFactor
|
||||
hoverEnabled: true
|
||||
background: Rectangle
|
||||
{
|
||||
opacity: sendToTopButton.down || sendToTopButton.hovered ? 1 : 0
|
||||
color: UM.Theme.getColor("viewport_background")
|
||||
}
|
||||
contentItem: Label
|
||||
{
|
||||
text: sendToTopButton.text
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: sendToTopConfirmationDialog
|
||||
title: catalog.i18nc("@window:title", "Move print job to top")
|
||||
icon: StandardIcon.Warning
|
||||
text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to move %1 to the top of the queue?").arg(printJob.name) : "";
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
Component.onCompleted: visible = false
|
||||
onYes: {
|
||||
if (printJob) {
|
||||
OutputDevice.sendJobToTop(printJob.key)
|
||||
}
|
||||
}
|
||||
}
|
||||
MessageDialog {
|
||||
id: sendToTopConfirmationDialog;
|
||||
Component.onCompleted: visible = false;
|
||||
icon: StandardIcon.Warning;
|
||||
onYes: OutputDevice.sendJobToTop(printJob.key);
|
||||
standardButtons: StandardButton.Yes | StandardButton.No;
|
||||
text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to move %1 to the top of the queue?").arg(printJob.name) : "";
|
||||
title: catalog.i18nc("@window:title", "Move print job to top");
|
||||
}
|
||||
|
||||
Button
|
||||
{
|
||||
id: deleteButton
|
||||
text: catalog.i18nc("@label", "Delete")
|
||||
onClicked:
|
||||
{
|
||||
deleteConfirmationDialog.visible = true;
|
||||
popup.close();
|
||||
}
|
||||
width: parent.width
|
||||
height: 39 * screenScaleFactor
|
||||
anchors.top: sendToTopButton.bottom
|
||||
hoverEnabled: true
|
||||
background: Rectangle
|
||||
{
|
||||
opacity: deleteButton.down || deleteButton.hovered ? 1 : 0
|
||||
color: UM.Theme.getColor("viewport_background")
|
||||
}
|
||||
contentItem: Label
|
||||
{
|
||||
text: deleteButton.text
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
}
|
||||
MessageDialog {
|
||||
id: deleteConfirmationDialog;
|
||||
Component.onCompleted: visible = false;
|
||||
icon: StandardIcon.Warning;
|
||||
onYes: OutputDevice.deleteJobFromQueue(printJob.key);
|
||||
standardButtons: StandardButton.Yes | StandardButton.No;
|
||||
text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to delete %1?").arg(printJob.name) : "";
|
||||
title: catalog.i18nc("@window:title", "Delete print job");
|
||||
}
|
||||
|
||||
MessageDialog
|
||||
{
|
||||
id: deleteConfirmationDialog
|
||||
title: catalog.i18nc("@window:title", "Delete print job")
|
||||
icon: StandardIcon.Warning
|
||||
text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to delete %1?").arg(printJob.name) : "";
|
||||
standardButtons: StandardButton.Yes | StandardButton.No
|
||||
Component.onCompleted: visible = false
|
||||
onYes: OutputDevice.deleteJobFromQueue(printJob.key)
|
||||
}
|
||||
}
|
||||
|
||||
background: Item
|
||||
{
|
||||
width: popup.width
|
||||
height: popup.height
|
||||
|
||||
DropShadow
|
||||
{
|
||||
anchors.fill: pointedRectangle
|
||||
radius: 5
|
||||
color: "#3F000000" // 25% shadow
|
||||
source: pointedRectangle
|
||||
transparentBorder: true
|
||||
verticalOffset: 2
|
||||
}
|
||||
|
||||
Item
|
||||
{
|
||||
id: pointedRectangle
|
||||
width: parent.width - 10 * screenScaleFactor // Because of the shadow
|
||||
height: parent.height - 10 * screenScaleFactor // Because of the shadow
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: point
|
||||
height: 14 * screenScaleFactor
|
||||
width: 14 * screenScaleFactor
|
||||
color: UM.Theme.getColor("setting_control")
|
||||
transform: Rotation { angle: 45}
|
||||
anchors.right: bloop.right
|
||||
anchors.rightMargin: 24
|
||||
y: 1
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: bloop
|
||||
color: UM.Theme.getColor("setting_control")
|
||||
width: parent.width
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8 * screenScaleFactor // Because of the shadow + point
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: 8 * screenScaleFactor // Because of the shadow
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
exit: Transition
|
||||
{
|
||||
NumberAnimation { property: "visible"; duration: 75; }
|
||||
}
|
||||
enter: Transition
|
||||
{
|
||||
NumberAnimation { property: "visible"; duration: 75; }
|
||||
}
|
||||
|
||||
onClosed: visible = false
|
||||
onOpened: visible = true
|
||||
MessageDialog {
|
||||
id: abortConfirmationDialog;
|
||||
Component.onCompleted: visible = false;
|
||||
icon: StandardIcon.Warning;
|
||||
onYes: printJob.setState("abort");
|
||||
standardButtons: StandardButton.Yes | StandardButton.No;
|
||||
text: printJob ? catalog.i18nc("@label %1 is the name of a print job.", "Are you sure you want to abort %1?").arg(printJob.name) : "";
|
||||
title: catalog.i18nc("@window:title", "Abort print");
|
||||
}
|
||||
|
||||
// Utils
|
||||
function switchPopupState() {
|
||||
popup.visible ? popup.close() : popup.open()
|
||||
popup.visible ? popup.close() : popup.open();
|
||||
}
|
||||
function isRunning(job) {
|
||||
if (!job) {
|
||||
return false;
|
||||
}
|
||||
return ["paused", "printing", "pre_print"].indexOf(job.state) !== -1;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue