From 0816f071f8920de4942eaa423831b900fdda15f3 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 3 Jan 2020 13:37:51 +0100 Subject: [PATCH] Add job status --- qml/components/ChoiceSetting.qml | 44 +--------- qml/pages/JobsPage.qml | 16 +++- qml/pages/utils.js | 58 +++++++++++++ src/ippprinter.cpp | 1 + translations/harbour-seaprint-de.ts | 126 +++++++++++++++++----------- translations/harbour-seaprint-fr.ts | 126 +++++++++++++++++----------- translations/harbour-seaprint.ts | 126 +++++++++++++++++----------- 7 files changed, 311 insertions(+), 186 deletions(-) diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 2a82256..3178c86 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -1,53 +1,15 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import "../pages/utils.js" as Utils Setting { property var choices - function prettifyChoice(name, value) - { - switch(name) { - case "print-quality": - switch(value) { - case 3: - return qsTr("draft"); - case 4: - return qsTr("normal"); - case 5: - return qsTr("high"); - default: - return qsTr("unknown quality ")+value - } - case "orientation-requested": - switch(value) { - case 3: - return qsTr("portrait"); - case 4: - return qsTr("landscape"); - case 5: - return qsTr("reverse landscape"); - case 6: - return qsTr("reverse portrait"); - default: - return qsTr("unknown orientation ")+value - } - case "printer-resolution": - - var units = ""; - if(value.units==3) { - units=qsTr("dpi"); - } else if (units==4){ - units=qsTr("dots/cm") - } - return ""+value.x+"x"+value.y+units; - } - return value; - } ValueButton { enabled: valid anchors.verticalCenter: parent.verticalCenter label: prettyName - value: prettifyChoice(name, choice ? choice : default_choice) + value: Utils.ippName(name, choice ? choice : default_choice) onClicked: parent.clicked() } @@ -56,7 +18,7 @@ Setting { Repeater { model: choices MenuItem { - text: prettifyChoice(name, choices[index]) + text: Utils.ippName(name, choices[index]) onClicked: { choice = choices[index]; diff --git a/qml/pages/JobsPage.qml b/qml/pages/JobsPage.qml index 76b9f23..920d39d 100644 --- a/qml/pages/JobsPage.qml +++ b/qml/pages/JobsPage.qml @@ -1,6 +1,6 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 - +import "utils.js" as Utils Page { id: page @@ -53,16 +53,24 @@ Page { id: idLabel leftPadding: Theme.horizontalPageMargin anchors.verticalCenter: parent.verticalCenter + color: Theme.highlightColor text: printer.jobs[index]["job-id"].value Component.onCompleted: console.log(JSON.stringify(printer.jobs)) } - Label { + Column { anchors.left: idLabel.right anchors.leftMargin: Theme.horizontalPageMargin anchors.verticalCenter: parent.verticalCenter - text: printer.jobs[index]["job-name"] ? printer.jobs[index]["job-name"].value : qsTr("Untitled job") - Component.onCompleted: console.log(JSON.stringify(printer.jobs)) + Label { + text: printer.jobs[index]["job-name"] ? printer.jobs[index]["job-name"].value : qsTr("Untitled job") + Component.onCompleted: console.log(JSON.stringify(printer.jobs)) + } + Label { + font.pixelSize: Theme.fontSizeTiny + color: Theme.secondaryColor + text: Utils.ippName("job-state", printer.jobs[index]["job-state"].value) + } } RemorseItem { diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 8ab43b8..ed3e6a5 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -28,3 +28,61 @@ function has(arrayish, what) } return false } + +function ippName(name, value) +{ + switch(name) { + case "job-state": + switch(value) { + case 3: + return qsTr("pending"); + case 4: + return qsTr("pending-held"); + case 5: + return qsTr("processing"); + case 6: + return qsTr("processing-stopped"); + case 7: + return qsTr("canceled"); + case 8: + return qsTr("aborted"); + case 9: + return qsTr("completed"); + default: + return qsTr("unknown state ")+value + } + case "print-quality": + switch(value) { + case 3: + return qsTr("draft"); + case 4: + return qsTr("normal"); + case 5: + return qsTr("high"); + default: + return qsTr("unknown quality ")+value + } + case "orientation-requested": + switch(value) { + case 3: + return qsTr("portrait"); + case 4: + return qsTr("landscape"); + case 5: + return qsTr("reverse landscape"); + case 6: + return qsTr("reverse portrait"); + default: + return qsTr("unknown orientation ")+value + } + case "printer-resolution": + var units = ""; + if(value.units==3) { + units=qsTr("dpi"); + } else if (units==4){ + units=qsTr("dots/cm") + } + return ""+value.x+"x"+value.y+units; + } + return value; +} diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 75652c6..d7bc012 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -191,6 +191,7 @@ bool IppPrinter::getJobs() { qDebug() << "getting jobs"; QJsonObject o = opAttrs(); + o.insert("requested-attributes", QJsonObject {{"tag", IppMsg::Keyword}, {"value", "all"}}); IppMsg job = IppMsg(o, QJsonObject()); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index e1c3686..c0c073a 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -83,53 +83,6 @@ - - ChoiceSetting - - draft - - - - normal - - - - high - - - - unknown quality - - - - portrait - - - - landscape - - - - reverse landscape - - - - reverse portrait - - - - unknown orientation - - - - dpi - - - - dots/cm - - - CoverPage @@ -250,4 +203,83 @@ + + utils + + pending + + + + pending-held + + + + processing + + + + processing-stopped + + + + canceled + + + + aborted + + + + completed + + + + unknown state + + + + draft + + + + normal + + + + high + + + + unknown quality + + + + portrait + + + + landscape + + + + reverse landscape + + + + reverse portrait + + + + unknown orientation + + + + dpi + + + + dots/cm + + + diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 89ca6f4..9589d0f 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -83,53 +83,6 @@ Inconnu - - ChoiceSetting - - draft - brouillon - - - normal - normale - - - high - haute - - - unknown quality - qualité inconnue - - - portrait - portrait - - - landscape - paysage - - - reverse landscape - paysage inversé - - - reverse portrait - portrait inversé - - - unknown orientation - orientation inconnue - - - dpi - dpi - - - dots/cm - pts/cm - - CoverPage @@ -250,4 +203,83 @@ Échec de l'impression : + + utils + + pending + + + + pending-held + + + + processing + + + + processing-stopped + + + + canceled + + + + aborted + + + + completed + + + + unknown state + + + + draft + brouillon + + + normal + normale + + + high + haute + + + unknown quality + qualité inconnue + + + portrait + portrait + + + landscape + paysage + + + reverse landscape + paysage inversé + + + reverse portrait + portrait inversé + + + unknown orientation + orientation inconnue + + + dpi + dpi + + + dots/cm + pts/cm + + diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index e1c3686..c0c073a 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -83,53 +83,6 @@ - - ChoiceSetting - - draft - - - - normal - - - - high - - - - unknown quality - - - - portrait - - - - landscape - - - - reverse landscape - - - - reverse portrait - - - - unknown orientation - - - - dpi - - - - dots/cm - - - CoverPage @@ -250,4 +203,83 @@ + + utils + + pending + + + + pending-held + + + + processing + + + + processing-stopped + + + + canceled + + + + aborted + + + + completed + + + + unknown state + + + + draft + + + + normal + + + + high + + + + unknown quality + + + + portrait + + + + landscape + + + + reverse landscape + + + + reverse portrait + + + + unknown orientation + + + + dpi + + + + dots/cm + + +