mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-04 07:04:18 +08:00
Merge branch 'CL-1126_monitor_tab_context_menu_improvements' into 3.6
This commit is contained in:
commit
7ecffdef3d
@ -11,7 +11,7 @@ import UM 1.3 as UM
|
|||||||
Item {
|
Item {
|
||||||
id: root;
|
id: root;
|
||||||
property var printJob: null;
|
property var printJob: null;
|
||||||
property var running: isRunning(printJob);
|
property var started: isStarted(printJob);
|
||||||
property var assigned: isAssigned(printJob);
|
property var assigned: isAssigned(printJob);
|
||||||
|
|
||||||
Button {
|
Button {
|
||||||
@ -34,7 +34,13 @@ Item {
|
|||||||
hoverEnabled: true;
|
hoverEnabled: true;
|
||||||
onClicked: parent.switchPopupState();
|
onClicked: parent.switchPopupState();
|
||||||
text: "\u22EE"; //Unicode; Three stacked points.
|
text: "\u22EE"; //Unicode; Three stacked points.
|
||||||
visible: printJob.state == "queued" || running ? true : false;
|
visible: {
|
||||||
|
if (!printJob) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var states = ["queued", "sent_to_printer", "pre_print", "printing", "pausing", "paused", "resuming"];
|
||||||
|
return states.indexOf(printJob.state) !== -1;
|
||||||
|
}
|
||||||
width: 35 * screenScaleFactor; // TODO: Theme!
|
width: 35 * screenScaleFactor; // TODO: Theme!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +108,12 @@ Item {
|
|||||||
width: parent.width;
|
width: parent.width;
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem {
|
||||||
enabled: {
|
onClicked: {
|
||||||
|
sendToTopConfirmationDialog.visible = true;
|
||||||
|
popup.close();
|
||||||
|
}
|
||||||
|
text: catalog.i18nc("@label", "Move to top");
|
||||||
|
visible: {
|
||||||
if (printJob && printJob.state == "queued" && !assigned) {
|
if (printJob && printJob.state == "queued" && !assigned) {
|
||||||
if (OutputDevice && OutputDevice.queuedPrintJobs[0]) {
|
if (OutputDevice && OutputDevice.queuedPrintJobs[0]) {
|
||||||
return OutputDevice.queuedPrintJobs[0].key != printJob.key;
|
return OutputDevice.queuedPrintJobs[0].key != printJob.key;
|
||||||
@ -110,42 +121,75 @@ Item {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
onClicked: {
|
|
||||||
sendToTopConfirmationDialog.visible = true;
|
|
||||||
popup.close();
|
|
||||||
}
|
|
||||||
text: catalog.i18nc("@label", "Move to top");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem {
|
||||||
enabled: printJob && !running;
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
deleteConfirmationDialog.visible = true;
|
deleteConfirmationDialog.visible = true;
|
||||||
popup.close();
|
popup.close();
|
||||||
}
|
}
|
||||||
text: catalog.i18nc("@label", "Delete");
|
text: catalog.i18nc("@label", "Delete");
|
||||||
|
visible: {
|
||||||
|
if (!printJob) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var states = ["queued", "sent_to_printer"];
|
||||||
|
return states.indexOf(printJob.state) !== -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem {
|
||||||
enabled: printJob && running;
|
enabled: visible && !(printJob.state == "pausing" || printJob.state == "resuming");
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (printJob.state == "paused") {
|
if (printJob.state == "paused") {
|
||||||
printJob.setState("print");
|
printJob.setState("print");
|
||||||
} else if(printJob.state == "printing") {
|
popup.close();
|
||||||
printJob.setState("pause");
|
return;
|
||||||
|
}
|
||||||
|
if (printJob.state == "printing") {
|
||||||
|
printJob.setState("pause");
|
||||||
|
popup.close();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
popup.close();
|
|
||||||
}
|
}
|
||||||
text: printJob && printJob.state == "paused" ? catalog.i18nc("@label", "Resume") : catalog.i18nc("@label", "Pause");
|
text: {
|
||||||
|
if (!printJob) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
switch(printJob.state) {
|
||||||
|
case "paused":
|
||||||
|
return catalog.i18nc("@label", "Resume");
|
||||||
|
case "pausing":
|
||||||
|
return catalog.i18nc("@label", "Pausing...");
|
||||||
|
case "resuming":
|
||||||
|
return catalog.i18nc("@label", "Resuming...");
|
||||||
|
default:
|
||||||
|
catalog.i18nc("@label", "Pause");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visible: {
|
||||||
|
if (!printJob) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var states = ["printing", "pausing", "paused", "resuming"];
|
||||||
|
return states.indexOf(printJob.state) !== -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintJobContextMenuItem {
|
PrintJobContextMenuItem {
|
||||||
enabled: printJob && running;
|
enabled: visible && printJob.state !== "aborting";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
abortConfirmationDialog.visible = true;
|
abortConfirmationDialog.visible = true;
|
||||||
popup.close();
|
popup.close();
|
||||||
}
|
}
|
||||||
text: catalog.i18nc("@label", "Abort");
|
text: printJob.state == "aborting" ? catalog.i18nc("@label", "Aborting...") : catalog.i18nc("@label", "Abort");
|
||||||
|
visible: {
|
||||||
|
if (!printJob) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var states = ["pre_print", "printing", "pausing", "paused", "resuming"];
|
||||||
|
return states.indexOf(printJob.state) !== -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
enter: Transition {
|
enter: Transition {
|
||||||
@ -205,11 +249,11 @@ Item {
|
|||||||
function switchPopupState() {
|
function switchPopupState() {
|
||||||
popup.visible ? popup.close() : popup.open();
|
popup.visible ? popup.close() : popup.open();
|
||||||
}
|
}
|
||||||
function isRunning(job) {
|
function isStarted(job) {
|
||||||
if (!job) {
|
if (!job) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ["paused", "printing", "pre_print"].indexOf(job.state) !== -1;
|
return ["pre_print", "printing", "pausing", "paused", "resuming", "aborting"].indexOf(job.state) !== -1;
|
||||||
}
|
}
|
||||||
function isAssigned(job) {
|
function isAssigned(job) {
|
||||||
if (!job) {
|
if (!job) {
|
||||||
@ -217,4 +261,13 @@ Item {
|
|||||||
}
|
}
|
||||||
return job.assignedPrinter ? true : false;
|
return job.assignedPrinter ? true : false;
|
||||||
}
|
}
|
||||||
|
function getMenuLength() {
|
||||||
|
var visible = 0;
|
||||||
|
for (var i = 0; i < popupOptions.children.length; i++) {
|
||||||
|
if (popupOptions.children[i].visible) {
|
||||||
|
visible++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,13 +12,12 @@ Button {
|
|||||||
color: UM.Theme.getColor("monitor_context_menu_highlight");
|
color: UM.Theme.getColor("monitor_context_menu_highlight");
|
||||||
}
|
}
|
||||||
contentItem: Label {
|
contentItem: Label {
|
||||||
color: UM.Theme.getColor("text");
|
color: enabled ? UM.Theme.getColor("text") : UM.Theme.getColor("text_inactive");
|
||||||
text: parent.text
|
text: parent.text
|
||||||
horizontalAlignment: Text.AlignLeft;
|
horizontalAlignment: Text.AlignLeft;
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
height: 39 * screenScaleFactor; // TODO: Theme!
|
height: visible ? 39 * screenScaleFactor : 0; // TODO: Theme!
|
||||||
hoverEnabled: true;
|
hoverEnabled: true;
|
||||||
visible: enabled;
|
|
||||||
width: parent.width;
|
width: parent.width;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user