From b78198536817b019d3caaf45b7c04238492ef162 Mon Sep 17 00:00:00 2001 From: dashinfantry <45334556+dashinfantry@users.noreply.github.com> Date: Tue, 14 Jan 2020 20:19:36 +0800 Subject: [PATCH 01/94] Update harbour-seaprint-zh_CN.ts --- translations/harbour-seaprint-zh_CN.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 0851332..4bc2bc1 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -283,7 +283,7 @@ No compatible formats supported - 不支持相关格式 + 不支持相关格式 From 24d37ddf2cd701ef841d2dfa5ab026229bd37734 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quent=C3=AD?= <33203663+Quenty31@users.noreply.github.com> Date: Tue, 14 Jan 2020 18:18:38 +0100 Subject: [PATCH 02/94] Update harbour-seaprint-fr.ts --- translations/harbour-seaprint-fr.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index b096ce2..aab9b47 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -207,11 +207,11 @@ utils pending - + en attente pending-held - + en attente de confirmation processing @@ -283,7 +283,7 @@ No compatible formats supported - + Aucun format compatible supporté From fc91a959c1726450ad98288dab3119a25b419088 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 14 Jan 2020 19:53:33 +0100 Subject: [PATCH 03/94] Oooops, 0.4.1 already happened --- rpm/harbour-seaprint.spec | 4 ++-- rpm/harbour-seaprint.yaml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index 7006d86..459a79f 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,8 +9,8 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4 -Release: 3 +Version: 0.4.1 +Release: 1 Group: Qt/Qt License: LICENSE URL: http://example.org/ diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index 353ab28..b765339 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,7 +1,7 @@ Name: harbour-seaprint Summary: SeaPrint -Version: 0.4 -Release: 3 +Version: 0.4.1 +Release: 1 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt From 10b38adebbe396e1e3455bb4daa89be52cee431a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 14 Jan 2020 19:53:55 +0100 Subject: [PATCH 04/94] Update translation credits --- qml/pages/AboutPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index 9b3ea00..2a09416 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -89,7 +89,7 @@ Page { AboutLabel { font.pixelSize: Theme.fontSizeSmall text: qsTr("Chinese")+" - dashinfantry\n"+ - qsTr("French")+" - ensag-dev\n"+ + qsTr("French")+" - ensag-dev, Quentí\n"+ qsTr("Spanish")+" - carmenfdezb" } From 2f973f3d57eca58ef5febd9867ad02b8732d4da3 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 20 Jan 2020 20:11:41 +0100 Subject: [PATCH 05/94] File format additions, user agent --- qml/pages/FirstPage.qml | 2 +- src/ippdiscovery.cpp | 7 ++++++- src/ippprinter.cpp | 8 ++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 4ec8511..9fc45df 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -242,7 +242,7 @@ Page { FilePickerPage { title: fileButton.label showSystemFiles: false - nameFilters: ["*.pdf", "*.jpg", "*.jpeg"] + nameFilters: ["*.pdf", "*.jpg", "*.jpeg", "*.pwg", "*.urf"] onSelectedContentPropertiesChanged: { page.selectedFile = selectedContentProperties.filePath diff --git a/src/ippdiscovery.cpp b/src/ippdiscovery.cpp index 4ccfd0a..440f48b 100644 --- a/src/ippdiscovery.cpp +++ b/src/ippdiscovery.cpp @@ -1,4 +1,6 @@ #include "ippdiscovery.h" +#include + #define A 1 #define PTR 12 #define TXT 16 @@ -287,7 +289,10 @@ QImage IppDiscovery::requestImage(const QString &id, QSize *size, const QSize &r url.setHost(_AAs.value(url.host())); } - QNetworkReply* reply = nam->get(QNetworkRequest(url)); + QNetworkRequest request(url); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + + QNetworkReply* reply = nam->get(request); QEventLoop el; connect(reply, SIGNAL(finished()),&el,SLOT(quit())); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 9094882..ba2071e 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,4 +1,6 @@ #include "ippprinter.h" +#include "ioprepender.h" +#include IppPrinter::IppPrinter() { @@ -84,6 +86,7 @@ void IppPrinter::refresh() { request.setUrl(httpUrl()); // request.setRawHeader("User-Agent", "MyOwnBrowser 1.0"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); QJsonObject o = opAttrs(); IppMsg msg = IppMsg(o); @@ -205,6 +208,7 @@ bool IppPrinter::print(QJsonObject attrs, QString filename){ request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); QJsonObject o = opAttrs(); o.insert("job-name", QJsonObject {{"tag", IppMsg::NameWithoutLanguage}, {"value", fileinfo.fileName()}}); @@ -246,6 +250,8 @@ bool IppPrinter::getJobs() { request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + _jobs_nam->post(request, contents); return true; @@ -266,6 +272,8 @@ bool IppPrinter::cancelJob(qint32 jobId) { request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + _job_cancel_nam->post(request, contents); return true; From 8257eed03ae833f8e4abe48b5d047ff01400598d Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 26 Jan 2020 13:27:56 +0100 Subject: [PATCH 06/94] Add debug page --- harbour-seaprint.pro | 1 + qml/pages/DebugPage.qml | 43 +++++++++++++++++++++++++++++++++++++++++ qml/pages/FirstPage.qml | 20 +++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 qml/pages/DebugPage.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 1393b4c..0056fae 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -34,6 +34,7 @@ DISTFILES += qml/harbour-seaprint.qml \ qml/pages/*.qml \ qml/pages/*.js \ qml/pages/*svg \ + qml/pages/DebugPage.qml \ rpm/harbour-seaprint.changes.in \ rpm/harbour-seaprint.changes.run.in \ rpm/harbour-seaprint.spec \ diff --git a/qml/pages/DebugPage.qml b/qml/pages/DebugPage.qml new file mode 100644 index 0000000..73ec9d8 --- /dev/null +++ b/qml/pages/DebugPage.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Page { + + id: aboutPage + + allowedOrientations: Orientation.All + + property var printer + + SilicaFlickable { + id: flick + anchors.fill : parent + contentHeight: textArea.height + header.height + contentWidth : parent.width - (2.0 * Theme.paddingLarge) + + PageHeader { + id: header + title: printer.attrs["printer-name"].value + } + + TextArea { + id: textArea + + readOnly: true + width: parent.width + anchors.top: header.bottom + anchors.bottom: flick.bottom + font.family: "courier" + font.pixelSize: Theme.fontSizeTiny + wrapMode: TextEdit.Wrap + text: JSON.stringify(printer.attrs, null, " ") + + onPressAndHold: { + selectAll() + copy() + deselect() + notifier.notify("Copied to clipboard") + } + } + } +} diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 9fc45df..24cfadf 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -131,7 +131,26 @@ Page { } } + Timer + { + id: debugCountReset + interval: 666 + repeat: false + onTriggered: + { + debugCount = 0; + } + } + + property int debugCount: 0 + onClicked: { + if(++debugCount == 5) + { + pageStack.push(Qt.resolvedUrl("DebugPage.qml"), {printer: printer}) + return; + } + debugCountReset.restart(); if(!canPrint) return; if(selectedFile != "") @@ -161,6 +180,7 @@ Page { source: printer.attrs["printer-icons"] ? "image://ippdiscovery/"+printer.attrs["printer-icons"].value[0] : "icon-seaprint-nobg.svg" // Some printers serve their icons over https with invalid certs... onStatusChanged: if (status == Image.Error) source = "icon-seaprint-nobg.svg" + } Column { From 86bfedf01a1e33a48f3bab73afc099bdadbcf861 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 16 Feb 2020 14:01:19 +0100 Subject: [PATCH 07/94] Consider PDF support listed in printer-info --- qml/pages/FirstPage.qml | 23 +++++++++++++++++------ qml/pages/utils.js | 22 +++++++++++++++++++++- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 24cfadf..295988a 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -108,7 +108,7 @@ Page { visible: false property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown") - property bool canPrint: printer.attrs["document-format-supported"].value.indexOf(selectedFileType) != -1 + property bool canPrint: Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1 Connections { target: printer @@ -208,12 +208,23 @@ Page { text: printer.url } - Label { - id: format_label - color: canPrint ? Theme.primaryColor : "red" - font.pixelSize: Theme.fontSizeExtraSmall - text: Utils.supported_formats(printer) + Row { + spacing: Theme.paddingMedium + Label { + id: format_label + color: canPrint ? Theme.primaryColor : "red" + font.pixelSize: Theme.fontSizeExtraSmall + text: Utils.supported_formats(printer).supported + } + Label { + id: maybe_format_label + color: canPrint ? Theme.secondaryColor : "red" + font.pixelSize: Theme.fontSizeExtraSmall + font.italic: true + text: Utils.supported_formats(printer).maybe + } } + } RemorseItem { diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 2567562..92393cd 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,13 +1,16 @@ function supported_formats(printer) { var formats = printer.attrs["document-format-supported"].value; + var mimetypes = []; var supported = []; if(has(formats, "application/pdf")) { + mimetypes.push("application/pdf"); supported.push("PDF"); } if(has(formats, "image/jpeg")) { + mimetypes.push("image/jpeg"); supported.push("JPEG"); } @@ -16,7 +19,24 @@ function supported_formats(printer) supported.push(qsTr("No compatible formats supported")) } - return supported.join(" "); + + //var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";"); + var maybe = [] + var info = printer.attrs["printer-info"].value.split(";"); + for(var i in info) + { + if(info[i].split(":")[0] == "CMD") + { + if(has(info[i].split(":")[1].split(","), "PDF")) + { + mimetypes.push("application/pdf"); + maybe.push("PDF"); + } + break; + } + } + + return {supported: supported.join(" "), maybe: maybe.join(" "), mimetypes: mimetypes}; } function has(arrayish, what) From 3a5b5cdf59043f610294271e68f52a0fe823cd53 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 16 Feb 2020 14:15:48 +0100 Subject: [PATCH 08/94] Actually consider PDF support in printer-info --- qml/pages/FirstPage.qml | 7 +++++++ qml/pages/utils.js | 11 +++-------- rpm/harbour-seaprint.spec | 2 +- rpm/harbour-seaprint.yaml | 2 +- translations/harbour-seaprint-de.ts | 8 ++++---- translations/harbour-seaprint-es.ts | 8 ++++---- translations/harbour-seaprint-fr.ts | 8 ++++---- translations/harbour-seaprint-zh_CN.ts | 8 ++++---- translations/harbour-seaprint.ts | 8 ++++---- 9 files changed, 32 insertions(+), 30 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 295988a..320029a 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -210,6 +210,13 @@ Page { Row { spacing: Theme.paddingMedium + Label { + id: format_unsupported_label + visible: format_label.text == "" && maybe_format_label.text == "" + color: "red" + font.pixelSize: Theme.fontSizeExtraSmall + text: qsTr("No compatible formats supported") + } Label { id: format_label color: canPrint ? Theme.primaryColor : "red" diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 92393cd..cf5a413 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -14,20 +14,15 @@ function supported_formats(printer) supported.push("JPEG"); } - if(supported.length == 0) - { - supported.push(qsTr("No compatible formats supported")) - } - - //var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";"); var maybe = [] - var info = printer.attrs["printer-info"].value.split(";"); + var info = printer.attrs["printer-info"] ? printer.attrs["printer-info"].value.split(";") : []; + for(var i in info) { if(info[i].split(":")[0] == "CMD") { - if(has(info[i].split(":")[1].split(","), "PDF")) + if(!has(supported, "PDF") && has(info[i].split(":")[1].split(","), "PDF")) { mimetypes.push("application/pdf"); maybe.push("PDF"); diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index 459a79f..b35427a 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,7 +9,7 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4.1 +Version: 0.4.2 Release: 1 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index b765339..54b8576 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,6 +1,6 @@ Name: harbour-seaprint Summary: SeaPrint -Version: 0.4.1 +Version: 0.4.2 Release: 1 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 23f38dc..7486638 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -140,6 +140,10 @@ Unknown + + No compatible formats supported + + JobsPage @@ -281,9 +285,5 @@ dots/cm - - No compatible formats supported - - diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 4ea77af..94bf9ec 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -140,6 +140,10 @@ Unknown Desconocido + + No compatible formats supported + No hay formatos compatibles + JobsPage @@ -281,9 +285,5 @@ dots/cm ppp - - No compatible formats supported - No hay formatos compatibles - diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index aab9b47..95255cc 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -140,6 +140,10 @@ Unknown Inconnu + + No compatible formats supported + Aucun format compatible supporté + JobsPage @@ -281,9 +285,5 @@ dots/cm pts/cm - - No compatible formats supported - Aucun format compatible supporté - diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 4bc2bc1..cf011ef 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -140,6 +140,10 @@ Unknown 未知 + + No compatible formats supported + 不支持相关格式 + JobsPage @@ -281,9 +285,5 @@ dots/cm 点/厘米 - - No compatible formats supported - 不支持相关格式 - diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 7d79407..7bd5741 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -140,6 +140,10 @@ Unknown + + No compatible formats supported + + JobsPage @@ -281,9 +285,5 @@ dots/cm - - No compatible formats supported - - From 4526aedcc8d3c94a277e4d305f9fe00d1b54b761 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 17 Feb 2020 19:58:46 +0100 Subject: [PATCH 09/94] Disable unsupported settings Make the GUI reflect that even the most basic printer settings may be unavailable --- qml/components/ChoiceSetting.qml | 1 + qml/components/IntegerSetting.qml | 1 + qml/components/RangeSetting.qml | 1 + qml/pages/PrinterPage.qml | 8 +++++--- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 3178c86..361e40d 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -15,6 +15,7 @@ Setting { property var menu: ContextMenu { id: menu + enabled: valid Repeater { model: choices MenuItem { diff --git a/qml/components/IntegerSetting.qml b/qml/components/IntegerSetting.qml index ad06862..5b09a00 100644 --- a/qml/components/IntegerSetting.qml +++ b/qml/components/IntegerSetting.qml @@ -16,6 +16,7 @@ Setting { property var menu: ContextMenu { id: menu + enabled: valid MenuItem { Slider { diff --git a/qml/components/RangeSetting.qml b/qml/components/RangeSetting.qml index 02f232c..f3ee289 100644 --- a/qml/components/RangeSetting.qml +++ b/qml/components/RangeSetting.qml @@ -20,6 +20,7 @@ Setting { property var menu: ContextMenu { id: menu + enabled: valid MenuItem { } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index c3111f7..94d29d3 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -82,13 +82,14 @@ Page { } Component.onCompleted: { - console.log("handling", tag, name, prettyName, JSON.stringify(printer.attrs[name+"-supported"]), JSON.stringify(printer.attrs[name+"-default"])) + console.log("handling", tag, name, prettyName, JSON.stringify(printer.attrs), JSON.stringify(printer.attrs[name+"-supported"]), JSON.stringify(printer.attrs[name+"-default"])) switch(tag) { case 0x21: loader.setSource("../components/IntegerSetting.qml", {name: name, prettyName: prettyName, tag: tag, + valid: printer.attrs.hasOwnProperty(name+"-supported"), low: printer.attrs[name+"-supported"].value.low, high: printer.attrs[name+"-supported"].value.high, default_choice: printer.attrs[name+"-default"].value @@ -98,8 +99,8 @@ Page { loader.setSource("../components/RangeSetting.qml", {name: name, prettyName: prettyName, - valid: false, //TODO - tag: 0x33 // integer-range + tag: tag, + valid: false //TODO printer.attrs.hasOwnProperty(name+"-supported"), }) break case 0x32: @@ -108,6 +109,7 @@ Page { {name: name, prettyName: prettyName, tag: tag, + valid: printer.attrs.hasOwnProperty(name+"-supported"), choices: printer.attrs[name+"-supported"].value, default_choice: printer.attrs[name+"-default"].value }) From 6180c3733d26d2f972009fac28d89ede351543e2 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 17 Feb 2020 20:06:39 +0100 Subject: [PATCH 10/94] Add Postscript to supported formats --- qml/pages/FirstPage.qml | 6 +++++- qml/pages/utils.js | 10 ++++++++++ rpm/harbour-seaprint.spec | 2 +- rpm/harbour-seaprint.yaml | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 320029a..3d5902a 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -51,6 +51,10 @@ Page { { selectedFileType = "application/pdf" } + else if(Utils.endsWith(".ps", selectedFile)) + { + selectedFileType = "application/postscript" + } else if(Utils.endsWith(".jpg", selectedFile) || Utils.endsWith(".jpeg", selectedFile)) { selectedFileType = "image/jpeg" @@ -280,7 +284,7 @@ Page { FilePickerPage { title: fileButton.label showSystemFiles: false - nameFilters: ["*.pdf", "*.jpg", "*.jpeg", "*.pwg", "*.urf"] + nameFilters: ["*.pdf", "*.jpg", "*.jpeg", "*.ps"] onSelectedContentPropertiesChanged: { page.selectedFile = selectedContentProperties.filePath diff --git a/qml/pages/utils.js b/qml/pages/utils.js index cf5a413..76ce63c 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -8,6 +8,11 @@ function supported_formats(printer) mimetypes.push("application/pdf"); supported.push("PDF"); } + if(has(formats, "application/postscript")) + { + mimetypes.push("application/postscript"); + supported.push("Postscript"); + } if(has(formats, "image/jpeg")) { mimetypes.push("image/jpeg"); @@ -27,6 +32,11 @@ function supported_formats(printer) mimetypes.push("application/pdf"); maybe.push("PDF"); } + if(!has(supported, "Postscript") && has(info[i].split(":")[1].split(","), "POSTSCRIPT")) + { + mimetypes.push("application/postscript"); + maybe.push("Postscript"); + } break; } } diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index b35427a..bd3deed 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -10,7 +10,7 @@ Name: harbour-seaprint Summary: SeaPrint Version: 0.4.2 -Release: 1 +Release: 2 Group: Qt/Qt License: LICENSE URL: http://example.org/ diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index 54b8576..a7ca1dc 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,7 +1,7 @@ Name: harbour-seaprint Summary: SeaPrint Version: 0.4.2 -Release: 1 +Release: 2 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt From 544bd0945d223af9b01408a1e483ffdf3cb1ed75 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 18 Feb 2020 20:40:31 +0100 Subject: [PATCH 11/94] Move mime type checking to my own class --- harbour-seaprint.pro | 6 ++++-- qml/pages/FirstPage.qml | 24 ++++++------------------ src/harbour-seaprint.cpp | 11 +++++++---- src/mimer.cpp | 28 ++++++++++++++++++++++++++++ src/mimer.h | 22 ++++++++++++++++++++++ 5 files changed, 67 insertions(+), 24 deletions(-) create mode 100644 src/mimer.cpp create mode 100644 src/mimer.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 0056fae..ac04c3e 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -25,7 +25,8 @@ SOURCES += src/harbour-seaprint.cpp \ src/ippdiscovery.cpp \ src/bytestream.cpp \ src/ippmsg.cpp \ - src/ippprinter.cpp + src/ippprinter.cpp \ + src/mimer.cpp DISTFILES += qml/harbour-seaprint.qml \ @@ -61,4 +62,5 @@ HEADERS += \ src/ippdiscovery.h \ src/bytestream.h \ src/ippmsg.h \ - src/ippprinter.h + src/ippprinter.h \ + src/mimer.h diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 3d5902a..9635101 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -3,6 +3,7 @@ import Sailfish.Silica 1.0 import Sailfish.Pickers 1.0 import seaprint.ippdiscovery 1.0 import seaprint.ippprinter 1.0 +import seaprint.mimer 1.0 import "utils.js" as Utils import "../components" import Nemo.DBus 2.0 @@ -46,23 +47,10 @@ Page { Component.onCompleted: { IppDiscovery.discover(); if(selectedFile != "") - { // Until i can convince FilePickerPage to do its magic without user interaction - if(Utils.endsWith(".pdf", selectedFile)) - { - selectedFileType = "application/pdf" - } - else if(Utils.endsWith(".ps", selectedFile)) - { - selectedFileType = "application/postscript" - } - else if(Utils.endsWith(".jpg", selectedFile) || Utils.endsWith(".jpeg", selectedFile)) - { - selectedFileType = "image/jpeg" - } - else - { - selectedFile = "" - } + { + var type = Mimer.get_type(selectedFile); + console.log(type); + selectedFileType = type; } } @@ -288,7 +276,7 @@ Page { onSelectedContentPropertiesChanged: { page.selectedFile = selectedContentProperties.filePath - page.selectedFileType = selectedContentProperties.mimeType + page.selectedFileType = Mimer.get_type(selectedContentProperties.filePath) } } } diff --git a/src/harbour-seaprint.cpp b/src/harbour-seaprint.cpp index 422372d..2cdd31f 100644 --- a/src/harbour-seaprint.cpp +++ b/src/harbour-seaprint.cpp @@ -4,14 +4,16 @@ #include #include #include +#include -static QObject* ippdiscovery_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) +template +static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { Q_UNUSED(engine) Q_UNUSED(scriptEngine) - IppDiscovery *ippdiscovery = IppDiscovery::instance(); - return ippdiscovery; + T *inst = T::instance(); + return inst; } @@ -21,7 +23,8 @@ int main(int argc, char *argv[]) app->setApplicationVersion(QStringLiteral(SEAPRINT_VERSION)); - qmlRegisterSingletonType("seaprint.ippdiscovery", 1, 0, "IppDiscovery", ippdiscovery_singletontype_provider); + qmlRegisterSingletonType("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider); + qmlRegisterSingletonType("seaprint.mimer", 1, 0, "Mimer", singletontype_provider); qmlRegisterType("seaprint.ippprinter", 1, 0, "IppPrinter"); QQuickView* view = SailfishApp::createView(); diff --git a/src/mimer.cpp b/src/mimer.cpp new file mode 100644 index 0000000..597e7df --- /dev/null +++ b/src/mimer.cpp @@ -0,0 +1,28 @@ +#include "mimer.h" + +Mimer::Mimer() +{ + +} + +Mimer* Mimer::m_Instance = 0; + +Mimer* Mimer::instance() +{ + static QMutex mutex; + if (!m_Instance) + { + mutex.lock(); + + if (!m_Instance) + m_Instance = new Mimer; + + mutex.unlock(); + } + + return m_Instance; +} + +QString Mimer::get_type(QString filename) { + return _db.mimeTypeForFile(filename).name(); +} diff --git a/src/mimer.h b/src/mimer.h new file mode 100644 index 0000000..535566b --- /dev/null +++ b/src/mimer.h @@ -0,0 +1,22 @@ +#ifndef MIMER_H +#define MIMER_H + +#include +#include +#include +#include + +class Mimer : public QObject +{ + Q_OBJECT +public: + static Mimer* instance(); + Q_INVOKABLE QString get_type(QString filename); +private: + Mimer(); + static Mimer* m_Instance; + QMimeDatabase _db; + +}; + +#endif // MIMER_H From 2ed80100f0f0be9f82944e6f1063676fb7ffdc67 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 18 Feb 2020 21:22:17 +0100 Subject: [PATCH 12/94] Remove debug printout that could prevent setting delegates from loading --- qml/pages/PrinterPage.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 94d29d3..bff96b6 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -82,7 +82,6 @@ Page { } Component.onCompleted: { - console.log("handling", tag, name, prettyName, JSON.stringify(printer.attrs), JSON.stringify(printer.attrs[name+"-supported"]), JSON.stringify(printer.attrs[name+"-default"])) switch(tag) { case 0x21: loader.setSource("../components/IntegerSetting.qml", From 3f3624559bbc4da4347b2574cdf851ee660e863c Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 23 Feb 2020 10:54:35 +0100 Subject: [PATCH 13/94] Ensure UTF-8 strings --- src/ippmsg.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index c0cf29c..a0afc91 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -268,8 +268,12 @@ Bytestream IppMsg::encode_attr(quint8 tag, QString name, QJsonValueRef value) case Charset: case NaturalLanguage: case MimeMediaType: - req << quint16(value.toString().length()) << value.toString().toStdString(); + { + QByteArray tmpstr = value.toString().toUtf8(); + req << quint16(tmpstr.length()); + req.putBytes(tmpstr.data(), tmpstr.length()); break; + } default: qDebug() << "uncaught tag" << tag; Q_ASSERT(false); From 5c67f44d78560d6452752439f5466a5f4dc67bd6 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 23 Feb 2020 13:11:28 +0100 Subject: [PATCH 14/94] Notify on failing to cancel job --- qml/pages/JobsPage.qml | 9 +++++++++ src/ippprinter.cpp | 5 ++++- src/ippprinter.h | 1 + translations/harbour-seaprint-de.ts | 4 ++++ translations/harbour-seaprint-es.ts | 4 ++++ translations/harbour-seaprint-fr.ts | 4 ++++ translations/harbour-seaprint-zh_CN.ts | 4 ++++ translations/harbour-seaprint.ts | 4 ++++ 8 files changed, 34 insertions(+), 1 deletion(-) diff --git a/qml/pages/JobsPage.qml b/qml/pages/JobsPage.qml index b3b7c6c..dd3fb32 100644 --- a/qml/pages/JobsPage.qml +++ b/qml/pages/JobsPage.qml @@ -13,6 +13,15 @@ Page { console.log(JSON.stringify(printer.jobs)) } + Connections { + target: printer + onCancelStatus: { + if(status != true) { + notifier.notify(qsTr("Cancelling job failed")) + } + } + } + // To enable PullDownMenu, place our content in a SilicaFlickable SilicaFlickable { anchors.fill: parent diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index ba2071e..2c49dc0 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -157,17 +157,20 @@ void IppPrinter::getJobsRequestFinished(QNetworkReply *reply) void IppPrinter::cancelJobFinished(QNetworkReply *reply) { + bool status = false; if(reply->error() == QNetworkReply::NoError) { try { IppMsg resp(reply); qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getJobAttrs(); + status = resp.getStatus() <= 0xff; } catch(std::exception e) { qDebug() << e.what(); } } + emit cancelStatus(status); getJobs(); } @@ -259,7 +262,7 @@ bool IppPrinter::getJobs() { bool IppPrinter::cancelJob(qint32 jobId) { - qDebug() << "getting jobs"; + qDebug() << "cancelling jobs"; QJsonObject o = opAttrs(); o.insert("job-id", QJsonObject {{"tag", IppMsg::Integer}, {"value", jobId}}); diff --git a/src/ippprinter.h b/src/ippprinter.h index 3763373..e82a7ad 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -35,6 +35,7 @@ signals: void jobsChanged(); void jobAttrsFinished(bool status); + void cancelStatus(bool status); public slots: void onUrlChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 7486638..89eb17b 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -171,6 +171,10 @@ job + + Cancelling job failed + + PrinterPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 94bf9ec..922ac40 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -171,6 +171,10 @@ job trabajo + + Cancelling job failed + + PrinterPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 95255cc..9979cf0 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -171,6 +171,10 @@ job tâche + + Cancelling job failed + + PrinterPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index cf011ef..74bf7d7 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -171,6 +171,10 @@ Cancelling job 正在取消作业 + + Cancelling job failed + + PrinterPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 7bd5741..afc7692 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -171,6 +171,10 @@ job + + Cancelling job failed + + PrinterPage From 1900c0b48321633dd3d7130b5ba4bd5a9ffe4932 Mon Sep 17 00:00:00 2001 From: ensag-dev <59049879+ensag-dev@users.noreply.github.com> Date: Fri, 6 Mar 2020 16:01:29 +0100 Subject: [PATCH 15/94] Translation + correction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Accord avec "tâche", féminin. --- translations/harbour-seaprint-fr.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 9979cf0..3fc98e6 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -142,7 +142,7 @@ No compatible formats supported - Aucun format compatible supporté + Aucun format compatible supporté @@ -173,7 +173,7 @@ Cancelling job failed - + Échec de l'annulation de la tâche d'impression @@ -231,15 +231,15 @@ canceled - annulé + annulée aborted - abandonné + abandonnée completed - terminé + terminée unknown state From ac191a48937280cebed4e8c341ee55c4dac2ce11 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 7 Mar 2020 11:51:10 +0100 Subject: [PATCH 16/94] Ooops 0.4.3 was a thing already --- rpm/harbour-seaprint.spec | 2 +- rpm/harbour-seaprint.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index bd3deed..a64c0e7 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,7 +9,7 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4.2 +Version: 0.4.3 Release: 2 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index a7ca1dc..484f31d 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,6 +1,6 @@ Name: harbour-seaprint Summary: SeaPrint -Version: 0.4.2 +Version: 0.4.3 Release: 2 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS From ed25def70a582f3f098e065bf01da04c500ffaaa Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 4 Apr 2020 13:43:38 +0200 Subject: [PATCH 17/94] ' apparently --- translations/harbour-seaprint-fr.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 3fc98e6..b87cf77 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -173,7 +173,7 @@ Cancelling job failed - Échec de l'annulation de la tâche d'impression + Échec de l'annulation de la tâche d'impression From e0b10c83a11d2cb43f2c735fe9b9834aaf9ac19a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 4 Apr 2020 13:56:36 +0200 Subject: [PATCH 18/94] make print() a slot --- qml/pages/PrinterPage.qml | 2 +- src/ippprinter.cpp | 10 ++++++---- src/ippprinter.h | 6 ++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index bff96b6..e65d138 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -14,7 +14,7 @@ Page { Connections { target: printer - onJobAttrsFinished: { + onJobFinished: { var msg = printer.jobAttrs["job-state-message"] && printer.jobAttrs["job-state-message"].value != "" ? printer.jobAttrs["job-state-message"].value : Utils.ippName("job-state", printer.jobAttrs["job-state"].value) if(status == true) { diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 2c49dc0..6d0e3c2 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -134,7 +134,7 @@ void IppPrinter::printRequestFinished(QNetworkReply *reply) _jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Network error"}}); } emit jobAttrsChanged(); - emit jobAttrsFinished(status); + emit jobFinished(status); } void IppPrinter::getJobsRequestFinished(QNetworkReply *reply) @@ -198,13 +198,16 @@ void IppPrinter::ignoreKnownSslErrors(QNetworkReply *reply, const QListpost(request, contents); file.close(); - return true; } bool IppPrinter::getJobs() { diff --git a/src/ippprinter.h b/src/ippprinter.h index e82a7ad..5464bc4 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -24,7 +24,6 @@ public: Q_INVOKABLE void refresh(); - Q_INVOKABLE bool print(QJsonObject attrs, QString file); Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool cancelJob(qint32 jobId); @@ -34,10 +33,13 @@ signals: void jobAttrsChanged(); void jobsChanged(); - void jobAttrsFinished(bool status); + void jobFinished(bool status); void cancelStatus(bool status); public slots: + void print(QJsonObject attrs, QString file); + + void onUrlChanged(); void getPrinterAttributesFinished(QNetworkReply* reply); void printRequestFinished(QNetworkReply* reply); From 0de30b5e36dbb90e309bd6ef83610b46384b1035 Mon Sep 17 00:00:00 2001 From: dashinfantry <45334556+dashinfantry@users.noreply.github.com> Date: Tue, 14 Apr 2020 13:27:56 +0800 Subject: [PATCH 19/94] Update harbour-seaprint-zh_CN.ts --- translations/harbour-seaprint-zh_CN.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 74bf7d7..0d93959 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -142,7 +142,7 @@ No compatible formats supported - 不支持相关格式 + 不支持相关格式 @@ -173,7 +173,7 @@ Cancelling job failed - + 作业失败 From 5ea76a44330de69f2572c2a253c5b9604aa83fe7 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 26 Jan 2020 12:08:57 +0100 Subject: [PATCH 20/94] WIP: make an IODevice shim --- harbour-seaprint.pro | 7 ++- src/ippprinter.cpp | 106 +++++++++++++++++++++++++++++++++++++++---- src/ippprinter.h | 3 ++ src/ippraster.cpp | 57 +++++++++++++++++++++++ src/ippraster.h | 39 ++++++++++++++++ 5 files changed, 202 insertions(+), 10 deletions(-) create mode 100644 src/ippraster.cpp create mode 100644 src/ippraster.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index ac04c3e..66e8ec0 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -26,10 +26,12 @@ SOURCES += src/harbour-seaprint.cpp \ src/bytestream.cpp \ src/ippmsg.cpp \ src/ippprinter.cpp \ - src/mimer.cpp + src/mimer.cpp \ + src/ippraster.cpp DISTFILES += qml/harbour-seaprint.qml \ + ../harbour-splay/qml/pages/ChannelItem.qml \ qml/cover/CoverPage.qml \ qml/components/*.qml \ qml/pages/*.qml \ @@ -63,4 +65,5 @@ HEADERS += \ src/bytestream.h \ src/ippmsg.h \ src/ippprinter.h \ - src/mimer.h + src/mimer.h \ + src/ippraster.h diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 6d0e3c2..3a29273 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,6 +1,7 @@ #include "ippprinter.h" -#include "ioprepender.h" +#include "ippraster.h" #include +#include IppPrinter::IppPrinter() { @@ -196,6 +197,71 @@ void IppPrinter::ignoreKnownSslErrors(QNetworkReply *reply, const QListignoreSslErrors(errors); } +void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile) +{ + QNetworkRequest request; + + request.setUrl(httpUrl()); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + + QProcess* muraster = new QProcess(this); + muraster->setProgram("/home/nemo/stuff/bin/muraster"); + muraster->setArguments({"-F", "pgm", filename}); + + + QProcess* ppm2pwg = new QProcess(this); + ppm2pwg->setProgram("/home/nemo/repos/pwg/ppm2pwg"); + QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; + + bool apple = false; + if(apple) + { + env.append("URF=true"); + } + + qDebug() << "Prepend file env done"; + + ppm2pwg->setEnvironment(env); + + muraster->setStandardOutputProcess(ppm2pwg); + ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + + connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater())); + + qDebug() << "All connected"; + + + muraster->start(); + ppm2pwg->start(); + + qDebug() << "Starting"; + + + if(!muraster->waitForStarted()) + { + qDebug() << "muraster died"; + return; + } + if(!ppm2pwg->waitForStarted()) + { + qDebug() << "ppm2pwg died"; + return; + } + qDebug() << "All started"; + + ppm2pwg->waitForFinished(); + + qDebug() << "Finished"; + +// IppRaster* raster = new IppRaster(ppm2pwg); +// raster->open(QIODevice::ReadOnly); +// request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true); + _print_nam->post(request, tempfile); + qDebug() << "posted"; +} void IppPrinter::print(QJsonObject attrs, QString filename){ @@ -210,11 +276,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ } QFileInfo fileinfo(file); - QNetworkRequest request; - - request.setUrl(httpUrl()); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); QJsonObject o = opAttrs(); o.insert("job-name", QJsonObject {{"tag", IppMsg::NameWithoutLanguage}, {"value", fileinfo.fileName()}}); @@ -236,8 +297,37 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ QByteArray filedata = file.readAll(); contents = contents.append(filedata); - _print_nam->post(request, contents); - file.close(); + + // TODO: do this only conditionally, and to the raster suppoerted/preferred + bool transcode = true; + if(transcode) + { + file.close(); + QTemporaryFile* tempfile = new QTemporaryFile(); + tempfile->open(); + tempfile->write(contents); + qDebug() << tempfile->fileName(); + tempfile->close(); + + QtConcurrent::run(this, &IppPrinter::doWork, filename, tempfile); + + } + else { + + QNetworkRequest request; + + request.setUrl(httpUrl()); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + + QByteArray filedata = file.readAll(); + contents = contents.append(filedata); + file.close(); + + _print_nam->post(request, contents); + } + + return; } bool IppPrinter::getJobs() { diff --git a/src/ippprinter.h b/src/ippprinter.h index 5464bc4..2df7e79 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -48,6 +48,9 @@ public slots: void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); + void doWork(QString filename, QTemporaryFile* tempfile); + + private: QUrl _url; QUrl httpUrl(); diff --git a/src/ippraster.cpp b/src/ippraster.cpp new file mode 100644 index 0000000..03ba815 --- /dev/null +++ b/src/ippraster.cpp @@ -0,0 +1,57 @@ +#include "ippraster.h" + +IppRaster::IppRaster(QIODevice *underlyingDevice) + : underlyingDevice(underlyingDevice) +{ + connect(underlyingDevice, SIGNAL(readyRead()), this, SLOT(doDataAvail())); + connect(underlyingDevice, SIGNAL(readChannelFinished()), this, SLOT(doReadFinished())); +} + +bool IppRaster::open(QIODevice::OpenMode mode) +{ + qDebug() << "open"; + + bool underlyingOk; + if (underlyingDevice->isOpen()) + underlyingOk = (underlyingDevice->openMode() == mode); + else + underlyingOk = underlyingDevice->open(mode); + + if (underlyingOk) { + setOpenMode(mode); + qDebug() << "open true"; + emit readyRead(); + return true; + } + qDebug() << underlyingOk << underlyingDevice->openMode() << underlyingDevice->isOpen() << mode << "borked"; + return false; +} + +void IppRaster::close() +{ + qDebug() << "close"; + underlyingDevice->close(); +} + +bool IppRaster::seek(qint64 pos) +{ + qDebug() << "seek"; + + return false; +} + +bool IppRaster::atEnd() const +{ + qDebug() << "atend"; + return underlyingDevice->atEnd(); +} + +qint64 IppRaster::readData(char *data, qint64 maxlen) +{ + qDebug() << "read" << maxlen; + return underlyingDevice->read(data, maxlen); +} +qint64 IppRaster::writeData(const char *data, qint64 len) +{ + return underlyingDevice->write(data, len); +} diff --git a/src/ippraster.h b/src/ippraster.h new file mode 100644 index 0000000..da228c9 --- /dev/null +++ b/src/ippraster.h @@ -0,0 +1,39 @@ +#ifndef IPPRASTER_H +#define IPPRASTER_H + +#include +#include + + +class IppRaster : public QIODevice +{ + Q_OBJECT + +public: + IppRaster(QIODevice *underlyingDevice); + ~IppRaster() {qDebug() << "deleted";} + + bool open(QIODevice::OpenMode mode) override; + void close() override; + bool seek(qint64) override; + bool atEnd() const override; + + qint64 readData(char *data, qint64 maxlen) override; + qint64 writeData(const char *data, qint64 len) override; + + bool isSequential() const override {return false;} + qint64 bytesAvailable() const override {return underlyingDevice->bytesAvailable();} + qint64 size() const override {return underlyingDevice->size();} + + bool waitForReadyRead(int msecs) {return true;} + + public slots: + void doDataAvail() {emit readyRead();} + void doReadFinished() {emit readChannelFinished();} + + +private: + QIODevice* underlyingDevice; +}; + +#endif From 218f74d41ee0edb18e08d72f8ba27ab76fc8bda8 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 30 Apr 2020 18:45:43 +0200 Subject: [PATCH 21/94] ippdiscovery: resolve unknown targets If a target entry was included in an answer, but not its IP, query about that target. --- src/ippdiscovery.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ippdiscovery.cpp b/src/ippdiscovery.cpp index 440f48b..34f8557 100644 --- a/src/ippdiscovery.cpp +++ b/src/ippdiscovery.cpp @@ -150,7 +150,8 @@ void IppDiscovery::readPendingDatagrams() QHostAddress sender; quint16 senderPort; - QStringList ipp_ptrs; + QStringList new_ipp_ptrs; + QStringList new_targets; socket->readDatagram((char*)(resp.raw()), size, &sender, &senderPort); sender = QHostAddress(sender.toIPv4Address()); @@ -182,7 +183,7 @@ void IppDiscovery::readPendingDatagrams() QString tmpname = get_addr(resp).join("."); if(aaddr.endsWith("_ipp._tcp.local")) { - ipp_ptrs.append(tmpname); + new_ipp_ptrs.append(tmpname); } } else if(atype == TXT) @@ -206,6 +207,7 @@ void IppDiscovery::readPendingDatagrams() QString target = get_addr(resp).join("."); _ports[aaddr] = port; _targets[aaddr] = target; + new_targets.append(target); } else if(atype == A) { @@ -227,25 +229,35 @@ void IppDiscovery::readPendingDatagrams() qDebug() << e.what(); return; } - qDebug() << "new ipp ptrs" << ipp_ptrs; + qDebug() << "new ipp ptrs" << new_ipp_ptrs; qDebug() << "ipp ptrs" << _ipp; qDebug() << "rps" << _rps; qDebug() << "ports" << _ports; + qDebug() << "new targets" << new_targets; qDebug() << "targets" << _targets; qDebug() << "AAs" << _AAs; qDebug() << "AAAAs" << _AAAAs; - for(QStringList::Iterator it = ipp_ptrs.begin(); it != ipp_ptrs.end(); it++) + for(QStringList::Iterator it = new_ipp_ptrs.begin(); it != new_ipp_ptrs.end(); it++) { if(!_ipp.contains(*it)) { _ipp.append(*it); } - if(!_ports.contains(*it) || !_targets.contains(*it) || !_rps.contains(*it)) + // If pointer does not resolve to a target or is missing information, query about it + if( !_targets.contains(*it) || !_ports.contains(*it) || !_rps.contains(*it)) { // if the PTR doesn't already resolve, ask for everything about it sendQuery(ALL, it->split('.')); } } + for(QStringList::Iterator it = new_targets.begin(); it != new_targets.end(); it++) + { + // If target does not resolve to an address, query about it + if(!_AAs.contains(*it)) + { + sendQuery(ALL, it->split('.')); + } + } } this->update(); From 9f50c1b393f9fbf30b7f494266e0aa402462b9b8 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 30 Apr 2020 19:11:08 +0200 Subject: [PATCH 22/94] 0.4.4 --- rpm/harbour-seaprint.spec | 2 +- rpm/harbour-seaprint.yaml | 2 +- translations/harbour-seaprint-fr.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index a64c0e7..2d3cf55 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,7 +9,7 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4.3 +Version: 0.4.4 Release: 2 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index 484f31d..c6b8059 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,6 +1,6 @@ Name: harbour-seaprint Summary: SeaPrint -Version: 0.4.3 +Version: 0.4.4 Release: 2 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 3fc98e6..b87cf77 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -173,7 +173,7 @@ Cancelling job failed - Échec de l'annulation de la tâche d'impression + Échec de l'annulation de la tâche d'impression From 0e038759cf62b611603947c418e00c203bc53012 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 30 Apr 2020 22:00:42 +0200 Subject: [PATCH 23/94] Unbork job settings --- src/ippmsg.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index a0afc91..654fe22 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -197,7 +197,7 @@ QByteArray IppMsg::encode(Operation op) ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]); } } - for(QJsonArray::iterator ait = _jobAttrs.begin(); ait != _jobAttrs.begin(); ait++) + for(QJsonArray::iterator ait = _jobAttrs.begin(); ait != _jobAttrs.end(); ait++) { ipp << quint8(2); QJsonObject tmpObj = ait->toObject(); From f063b57fdf5ed948b64e64d6bf49bbba5c095252 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 30 Apr 2020 22:20:31 +0200 Subject: [PATCH 24/94] Initial support for media (size) selection --- qml/pages/PrinterPage.qml | 2 + qml/pages/utils.js | 213 +++++++++++++++++++++++++ translations/harbour-seaprint-de.ts | 4 + translations/harbour-seaprint-es.ts | 4 + translations/harbour-seaprint-fr.ts | 4 + translations/harbour-seaprint-zh_CN.ts | 4 + translations/harbour-seaprint.ts | 4 + 7 files changed, 235 insertions(+) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index bff96b6..a89ad2d 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -46,6 +46,7 @@ Page { ListModel { id:mod ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} + ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} // ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} @@ -104,6 +105,7 @@ Page { break case 0x32: case 0x23: + case 0x44: loader.setSource("../components/ChoiceSetting.qml", {name: name, prettyName: prettyName, diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 76ce63c..107b962 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -108,6 +108,15 @@ function ippName(name, value) units=qsTr("dots/cm") } return ""+value.x+"x"+value.y+units; + case "media": + if(media.hasOwnProperty(value)) + { + return media[value]; + } + else + { + return value; + } } return value; } @@ -116,3 +125,207 @@ function endsWith(ending, string) { return string.lastIndexOf(ending) == (string.length - ending.length); } + + +var media = + {"asme_f_28x40in": "28 x 40″", + "choice_iso_a4_210x297mm_na_letter_8.5x11in": "A4 or US Letter", + "iso_2a0_1189x1682mm": "2a0", + "iso_a0_841x1189mm": "A0", + "iso_a0x3_1189x2523mm": "A0x3", + "iso_a10_26x37mm": "A10", + "iso_a1_594x841mm": "A1", + "iso_a1x3_841x1783mm": "A1x3", + "iso_a1x4_841x2378mm": "A1x4", + "iso_a2_420x594mm": "A2", + "iso_a2x3_594x1261mm": "A2x3", + "iso_a2x4_594x1682mm": "A2x4", + "iso_a2x5_594x2102mm": "A2x5", + "iso_a3-extra_322x445mm": "A3 (Extra)", + "iso_a3_297x420mm": "A3", + "iso_a3x3_420x891mm": "A3x3", + "iso_a3x4_420x1189mm": "A3x4", + "iso_a3x5_420x1486mm": "A3x5", + "iso_a3x6_420x1783mm": "A3x6", + "iso_a3x7_420x2080mm": "A3x7", + "iso_a4-extra_235.5x322.3mm": "A4 (Extra)", + "iso_a4-tab_225x297mm": "A4 (Tab)", + "iso_a4_210x297mm": "A4", + "iso_a4x3_297x630mm": "A4x3", + "iso_a4x4_297x841mm": "A4x4", + "iso_a4x5_297x1051mm": "A4x5", + "iso_a4x6_297x1261mm": "A4x6", + "iso_a4x7_297x1471mm": "A4x7", + "iso_a4x8_297x1682mm": "A4x8", + "iso_a4x9_297x1892mm": "A4x9", + "iso_a5-extra_174x235mm": "A5 (Extra)", + "iso_a5_148x210mm": "A5", + "iso_a6_105x148mm": "A6", + "iso_a7_74x105mm": "A7", + "iso_a8_52x74mm": "A8", + "iso_a9_37x52mm": "A9", + "iso_b0_1000x1414mm": "B0", + "iso_b10_31x44mm": "B10", + "iso_b1_707x1000mm": "B1", + "iso_b2_500x707mm": "B2", + "iso_b3_353x500mm": "B3", + "iso_b4_250x353mm": "B4", + "iso_b5-extra_201x276mm": "B5 (Extra)", + "iso_b5_176x250mm": "Envelope B5", + "iso_b6_125x176mm": "B6", + "iso_b6c4_125x324mm": "Envelope B6/C4", + "iso_b7_88x125mm": "B7", + "iso_b8_62x88mm": "B8", + "iso_b9_44x62mm": "B9", + "iso_c0_917x1297mm": "CEnvelope 0", + "iso_c10_28x40mm": "CEnvelope 10", + "iso_c1_648x917mm": "CEnvelope 1", + "iso_c2_458x648mm": "CEnvelope 2", + "iso_c3_324x458mm": "CEnvelope 3", + "iso_c4_229x324mm": "CEnvelope 4", + "iso_c5_162x229mm": "CEnvelope 5", + "iso_c6_114x162mm": "CEnvelope 6", + "iso_c6c5_114x229mm": "CEnvelope 6c5", + "iso_c7_81x114mm": "CEnvelope 7", + "iso_c7c6_81x162mm": "CEnvelope 7c6", + "iso_c8_57x81mm": "CEnvelope 8", + "iso_c9_40x57mm": "CEnvelope 9", + "iso_dl_110x220mm": "Envelope DL", + "iso_id-1_53.98x85.6mm": "Id-1", + "iso_id-3_88x125mm": "Id-3", + "iso_ra0_860x1220mm": "ISO RA0", + "iso_ra1_610x860mm": "ISO RA1", + "iso_ra2_430x610mm": "ISO RA2", + "iso_ra3_305x430mm": "ISO RA3", + "iso_ra4_215x305mm": "ISO RA4", + "iso_sra0_900x1280mm": "ISO SRA0", + "iso_sra1_640x900mm": "ISO SRA1", + "iso_sra2_450x640mm": "ISO SRA2", + "iso_sra3_320x450mm": "ISO SRA3", + "iso_sra4_225x320mm": "ISO SRA4", + "jis_b0_1030x1456mm": "JIS B0", + "jis_b10_32x45mm": "JIS B10", + "jis_b1_728x1030mm": "JIS B1", + "jis_b2_515x728mm": "JIS B2", + "jis_b3_364x515mm": "JIS B3", + "jis_b4_257x364mm": "JIS B4", + "jis_b5_182x257mm": "JIS B5", + "jis_b6_128x182mm": "JIS B6", + "jis_b7_91x128mm": "JIS B7", + "jis_b8_64x91mm": "JIS B8", + "jis_b9_45x64mm": "JIS B9", + "jis_exec_216x330mm": "JIS Executive", + "jpn_chou2_111.1x146mm": "Envelope Chou 2", + "jpn_chou3_120x235mm": "Envelope Chou 3", + "jpn_chou40_90x225mm": "Envelope Chou 40", + "jpn_chou4_90x205mm": "Envelope Chou 4", + "jpn_hagaki_100x148mm": "Hagaki", + "jpn_kahu_240x322.1mm": "Envelope Kahu", + "jpn_kaku1_270x382mm": "270 x 382mm", + "jpn_kaku2_240x332mm": "Envelope Kahu 2", + "jpn_kaku3_216x277mm": "216 x 277mm", + "jpn_kaku4_197x267mm": "197 x 267mm", + "jpn_kaku5_190x240mm": "190 x 240mm", + "jpn_kaku7_142x205mm": "142 x 205mm", + "jpn_kaku8_119x197mm": "119 x 197mm", + "jpn_oufuku_148x200mm": "Oufuku Reply Postcard", + "jpn_you4_105x235mm": "Envelope You 4", + "na_10x11_10x11in": "10 x 11″", + "na_10x13_10x13in": "10 x 13″", + "na_10x14_10x14in": "10 x 14″", + "na_10x15_10x15in": "10 x 15″", + "na_11x12_11x12in": "11 x 12″", + "na_11x15_11x15in": "11 x 15″", + "na_12x19_12x19in": "12 x 19″", + "na_5x7_5x7in": "5 x 7″", + "na_6x9_6x9in": "6 x 9″", + "na_7x9_7x9in": "7 x 9″", + "na_9x11_9x11in": "9 x 11″", + "na_a2_4.375x5.75in": "Envelope A2", + "na_arch-a_9x12in": "9 x 12″", + "na_arch-b_12x18in": "12 x 18″", + "na_arch-c_18x24in": "18 x 24″", + "na_arch-d_24x36in": "24 x 36″", + "na_arch-e2_26x38in": "26 x 38″", + "na_arch-e3_27x39in": "27 x 39″", + "na_arch-e_36x48in": "36 x 48″", + "na_b-plus_12x19.17in": "12 x 19.17″", + "na_c5_6.5x9.5in": "Envelope C5", + "na_c_17x22in": "17 x 22″", + "na_d_22x34in": "22 x 34″", + "na_e_34x44in": "34 x 44″", + "na_edp_11x14in": "11 x 14″", + "na_eur-edp_12x14in": "12 x 14″", + "na_executive_7.25x10.5in": "Executive", + "na_f_44x68in": "44 x 68″", + "na_fanfold-eur_8.5x12in": "European Fanfold", + "na_fanfold-us_11x14.875in": "US Fanfold", + "na_foolscap_8.5x13in": "Foolscap", + "na_govt-legal_8x13in": "8 x 13″", + "na_govt-letter_8x10in": "8 x 10″", + "na_index-3x5_3x5in": "3 x 5″", + "na_index-4x6-ext_6x8in": "6 x 8″", + "na_index-4x6_4x6in": "4 x 6″", + "na_index-5x8_5x8in": "5 x 8″", + "na_invoice_5.5x8.5in": "Statement", + "na_ledger_11x17in": "11 x 17″", + "na_legal-extra_9.5x15in": "US Legal (Extra)", + "na_legal_8.5x14in": "US Legal", + "na_letter-extra_9.5x12in": "US Letter (Extra)", + "na_letter-plus_8.5x12.69in": "US Letter (Plus)", + "na_letter_8.5x11in": "US Letter", + "na_monarch_3.875x7.5in": "Envelope Monarch", + "na_number-10_4.125x9.5in": "Envelope #10", + "na_number-11_4.5x10.375in": "Envelope #11", + "na_number-12_4.75x11in": "Envelope #12", + "na_number-14_5x11.5in": "Envelope #14", + "na_number-9_3.875x8.875in": "Envelope #9", + "na_oficio_8.5x13.4in": "8.5 x 13.4″", + "na_personal_3.625x6.5in": "Envelope Personal", + "na_quarto_8.5x10.83in": "Quarto", + "na_super-a_8.94x14in": "8.94 x 14″", + "na_super-b_13x19in": "13 x 19″", + "na_wide-format_30x42in": "30 x 42″", + "oe_12x16_12x16in": "12 x 16″", + "oe_14x17_14x17in": "14 x 17″", + "oe_18x22_18x22in": "18 x 22″", + "oe_a2plus_17x24in": "17 x 24″", + "oe_business-card_2x3.5in": "2 x 3.5″", + "oe_photo-10r_10x12in": "10 x 12″", + "oe_photo-20r_20x24in": "20 x 24″", + "oe_photo-l_3.5x5in": "3.5 x 5″", + "oe_photo-s10r_10x15in": "10 x 15″", + "oe_square-photo_4x4in": "4 x 4″", + "oe_square-photo_5x5in": "5 x 5″", + "om_16k_184x260mm": "184 x 260mm", + "om_16k_195x270mm": "195 x 270mm", + "om_business-card_55x85mm": "55 x 85mm", + "om_business-card_55x91mm": "55 x 91mm", + "om_card_54x86mm": "54 x 86mm", + "om_dai-pa-kai_275x395mm": "275 x 395mm", + "om_dsc-photo_89x119mm": "89 x 119mm", + "om_folio-sp_215x315mm": "Folio", + "om_folio_210x330mm": "Folio (Special)", + "om_invite_220x220mm": "Envelope Invitation", + "om_italian_110x230mm": "Envelope Italian", + "om_juuro-ku-kai_198x275mm": "198 x 275mm", + "om_large-photo_200x300": "200 x 300", + "om_medium-photo_130x180mm": "130 x 180mm", + "om_pa-kai_267x389mm": "267 x 389mm", + "om_postfix_114x229mm": "Envelope Postfix", + "om_small-photo_100x150mm": "100 x 150mm", + "om_square-photo_89x89mm": "89 x 89mm", + "om_wide-photo_100x200mm": "100 x 200mm", + "prc_10_324x458mm": "Envelope Chinese #10", + "prc_16k_146x215mm": "Chinese 16k", + "prc_1_102x165mm": "Envelope Chinese #1", + "prc_2_102x176mm": "Envelope Chinese #2", + "prc_32k_97x151mm": "Chinese 32k", + "prc_3_125x176mm": "Envelope Chinese #3", + "prc_4_110x208mm": "Envelope Chinese #4", + "prc_5_110x220mm": "Envelope Chinese #5", + "prc_6_120x320mm": "Envelope Chinese #6", + "prc_7_160x230mm": "Envelope Chinese #7", + "prc_8_120x309mm": "Envelope Chinese #8", + "roc_16k_7.75x10.75in": "ROC 16k", + "roc_8k_10.75x15.5in": "ROC 8k"} diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 89eb17b..e11067d 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -210,6 +210,10 @@ Print failed: + + Print media + + utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 922ac40..9c103c3 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -210,6 +210,10 @@ Print failed: Impresión fallida: + + Print media + + utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index b87cf77..a34c6bb 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -210,6 +210,10 @@ Print failed: Échec de l'impression : + + Print media + + utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 0d93959..13bdc73 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -210,6 +210,10 @@ Print failed: 打印失败: + + Print media + + utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index afc7692..01239fb 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -210,6 +210,10 @@ Print failed: + + Print media + + utils From 93b79cf37f0ae8455394881844d2e071cfc9fe29 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 30 Apr 2020 23:05:46 +0200 Subject: [PATCH 25/94] Add gallery file selection --- qml/pages/FirstPage.qml | 44 +++++++++++++++++++++----- translations/harbour-seaprint-de.ts | 12 +++---- translations/harbour-seaprint-es.ts | 12 +++---- translations/harbour-seaprint-fr.ts | 12 +++---- translations/harbour-seaprint-zh_CN.ts | 12 +++---- translations/harbour-seaprint.ts | 12 +++---- 6 files changed, 56 insertions(+), 48 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 9635101..dcb76f4 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -255,22 +255,41 @@ Page { DockedPanel { id: fileDock open: true - height: fileButton.height*2 + height: fileLabel.height+folderButton.height+3*Theme.paddingLarge width: parent.width dock: Dock.Bottom - ValueButton { - id: fileButton + Label { + id: fileLabel width: parent.width - anchors.verticalCenter: parent.verticalCenter - label: qsTr("Choose file") - value: selectedFile != "" ? selectedFile : qsTr("None") - onClicked: pageStack.push(filePickerPage) + anchors.top: parent.top + anchors.topMargin: Theme.paddingLarge + leftPadding: Theme.paddingMedium + color: Theme.highlightColor + text: selectedFile != "" ? selectedFile : qsTr("No file selected") + } + + Row { + width: parent.width + anchors.bottom: parent.bottom + anchors.bottomMargin: Theme.paddingLarge + IconButton { + id: folderButton + icon.source: "image://theme/icon-m-file-folder" + width: parent.width/2 + onClicked: pageStack.push(filePickerPage) + } + IconButton { + icon.source: "image://theme/icon-m-file-image" + width: parent.width/2 + onClicked: pageStack.push(imagePickerPage) + } + } Component { id: filePickerPage FilePickerPage { - title: fileButton.label + title: qsTr("Choose file") showSystemFiles: false nameFilters: ["*.pdf", "*.jpg", "*.jpeg", "*.ps"] @@ -280,5 +299,14 @@ Page { } } } + Component { + id: imagePickerPage + ImagePickerPage { + onSelectedContentPropertiesChanged: { + page.selectedFile = selectedContentProperties.filePath + page.selectedFileType = Mimer.get_type(selectedContentProperties.filePath) + } + } + } } } diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index e11067d..025f610 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -112,14 +112,6 @@ No file selected - - Choose file - - - - None - - View jobs @@ -144,6 +136,10 @@ No compatible formats supported + + Choose file + + JobsPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 9c103c3..f16f573 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -112,14 +112,6 @@ No file selected Ningún archivo seleccionado - - Choose file - Elegir archivo - - - None - Ninguno - View jobs Ver trabajos @@ -144,6 +136,10 @@ No compatible formats supported No hay formatos compatibles + + Choose file + Elegir archivo + JobsPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index a34c6bb..8e5b2a6 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -112,14 +112,6 @@ No file selected Aucun fichier sélectionné - - Choose file - Choisir un fichier - - - None - Aucun - View jobs Voir les travaux @@ -144,6 +136,10 @@ No compatible formats supported Aucun format compatible supporté + + Choose file + Choisir un fichier + JobsPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 13bdc73..0f3f8b2 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -112,14 +112,6 @@ No file selected 没有找到文件 - - Choose file - 选择文件 - - - None - - View jobs 查看作业 @@ -144,6 +136,10 @@ No compatible formats supported 不支持相关格式 + + Choose file + 选择文件 + JobsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 01239fb..4c3c91d 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -112,14 +112,6 @@ No file selected - - Choose file - - - - None - - View jobs @@ -144,6 +136,10 @@ No compatible formats supported + + Choose file + + JobsPage From 27cc5a38e575fff42c03c74828d6ebf22c277ab6 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 11:21:03 +0200 Subject: [PATCH 26/94] Fix messages when there is no job-state-message at all --- qml/pages/PrinterPage.qml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index a89ad2d..2ea9a46 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -15,8 +15,13 @@ Page { Connections { target: printer onJobAttrsFinished: { - var msg = printer.jobAttrs["job-state-message"] && printer.jobAttrs["job-state-message"].value != "" - ? printer.jobAttrs["job-state-message"].value : Utils.ippName("job-state", printer.jobAttrs["job-state"].value) + var msg = "" + if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") { + msg = printer.jobAttrs["job-state-message"].value + } + else if (printer.jobAttrs.hasOwnProperty("job-state")) { + msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value) + } if(status == true) { notifier.notify(qsTr("Print success: ") + msg) pageStack.pop() //or replace? From 35cadccd1b87eaba15cf33794c831abfff6d0c32 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 13:49:17 +0200 Subject: [PATCH 27/94] Sorta, kinda works --- src/ippprinter.cpp | 16 +++++++++++----- src/ippprinter.h | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 3a29273..5e30ad2 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -23,6 +23,7 @@ IppPrinter::IppPrinter() connect(_job_cancel_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged); + qRegisterMetaType("QTemporaryFile*"); } IppPrinter::~IppPrinter() { @@ -229,7 +230,7 @@ void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile) connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); - connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater())); + //connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater())); qDebug() << "All connected"; @@ -259,10 +260,18 @@ void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile) // IppRaster* raster = new IppRaster(ppm2pwg); // raster->open(QIODevice::ReadOnly); // request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true); - _print_nam->post(request, tempfile); + QMetaObject::invokeMethod(this, "doPost", Qt::QueuedConnection, + Q_ARG(QNetworkRequest, request), Q_ARG(QTemporaryFile*, tempfile) ); qDebug() << "posted"; } +void IppPrinter::doPost(QNetworkRequest request, QTemporaryFile* data) +{ + data->open(); + _print_nam->post(request, data); + +} + void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << "printing" << filename << attrs; @@ -294,9 +303,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ IppMsg job = IppMsg(o, attrs); QByteArray contents = job.encode(IppMsg::PrintJob); - QByteArray filedata = file.readAll(); - contents = contents.append(filedata); - // TODO: do this only conditionally, and to the raster suppoerted/preferred bool transcode = true; diff --git a/src/ippprinter.h b/src/ippprinter.h index 2df7e79..884949b 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -49,7 +49,7 @@ public slots: void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); void doWork(QString filename, QTemporaryFile* tempfile); - + void doPost(QNetworkRequest request, QTemporaryFile* data); private: QUrl _url; From 5568452a791be43750ec81d8aba57bc91317d2b9 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 15:02:29 +0200 Subject: [PATCH 28/94] Move conversion to a proper worker thread --- harbour-seaprint.pro | 2 + src/convertworker.cpp | 62 +++++++++++++++++++++++++ src/convertworker.h | 19 ++++++++ src/ippprinter.cpp | 104 +++++++++++------------------------------- src/ippprinter.h | 10 +++- 5 files changed, 118 insertions(+), 79 deletions(-) create mode 100644 src/convertworker.cpp create mode 100644 src/convertworker.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 66e8ec0..edddf15 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -22,6 +22,7 @@ VERSION_H = \ write_file($$$$OUT_PWD/seaprint_version.h, VERSION_H) SOURCES += src/harbour-seaprint.cpp \ + src/convertworker.cpp \ src/ippdiscovery.cpp \ src/bytestream.cpp \ src/ippmsg.cpp \ @@ -61,6 +62,7 @@ TRANSLATIONS += translations/harbour-seaprint-de.ts \ translations/harbour-seaprint-es.ts HEADERS += \ + src/convertworker.h \ src/ippdiscovery.h \ src/bytestream.h \ src/ippmsg.h \ diff --git a/src/convertworker.cpp b/src/convertworker.cpp new file mode 100644 index 0000000..4d3e8c1 --- /dev/null +++ b/src/convertworker.cpp @@ -0,0 +1,62 @@ +#include "convertworker.h" + +void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile) +{ + + QProcess* muraster = new QProcess(this); + muraster->setProgram("/home/nemo/stuff/bin/muraster"); + muraster->setArguments({"-F", "pgm", filename}); + + + QProcess* ppm2pwg = new QProcess(this); + ppm2pwg->setProgram("/home/nemo/repos/pwg/ppm2pwg"); + QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; + + bool apple = false; + if(apple) + { + env.append("URF=true"); + } + + qDebug() << "Prepend file env done"; + + ppm2pwg->setEnvironment(env); + + muraster->setStandardOutputProcess(ppm2pwg); + ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + + connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); + + qDebug() << "All connected"; + + + muraster->start(); + ppm2pwg->start(); + + qDebug() << "Starting"; + + + if(!muraster->waitForStarted()) + { + qDebug() << "muraster died"; + tempfile->deleteLater(); + emit failed(); + return; + } + if(!ppm2pwg->waitForStarted()) + { + qDebug() << "ppm2pwg died"; + tempfile->deleteLater(); + emit failed(); + return; + } + qDebug() << "All started"; + + ppm2pwg->waitForFinished(); + + qDebug() << "Finished"; + + emit done(request, tempfile); + qDebug() << "posted"; +} diff --git a/src/convertworker.h b/src/convertworker.h new file mode 100644 index 0000000..bce308a --- /dev/null +++ b/src/convertworker.h @@ -0,0 +1,19 @@ +#ifndef CONVERTWORKER_H +#define CONVERTWORKER_H +#include +#include + +class ConvertWorker : public QObject +{ + Q_OBJECT + +public slots: + void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile); + //convertImage(); + +signals: + void done(QNetworkRequest request, QTemporaryFile* data); + void failed(); +}; + +#endif // CONVERTWORKER_H diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 5e30ad2..922cdb9 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,7 +1,6 @@ #include "ippprinter.h" #include "ippraster.h" #include -#include IppPrinter::IppPrinter() { @@ -24,6 +23,17 @@ IppPrinter::IppPrinter() QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged); qRegisterMetaType("QTemporaryFile*"); + + _worker = new ConvertWorker; + _worker->moveToThread(&_workerThread); + + connect(&_workerThread, &QThread::finished, _worker, &QObject::deleteLater); + + connect(this, &IppPrinter::doConvertPdf, _worker, &ConvertWorker::convertPdf); + connect(_worker, &ConvertWorker::done, this, &IppPrinter::convertDone); + connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed); + + _workerThread.start(); } IppPrinter::~IppPrinter() { @@ -198,80 +208,21 @@ void IppPrinter::ignoreKnownSslErrors(QNetworkReply *reply, const QListignoreSslErrors(errors); } -void IppPrinter::doWork(QString filename, QTemporaryFile* tempfile) -{ - QNetworkRequest request; - - request.setUrl(httpUrl()); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); - - QProcess* muraster = new QProcess(this); - muraster->setProgram("/home/nemo/stuff/bin/muraster"); - muraster->setArguments({"-F", "pgm", filename}); - - - QProcess* ppm2pwg = new QProcess(this); - ppm2pwg->setProgram("/home/nemo/repos/pwg/ppm2pwg"); - QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; - - bool apple = false; - if(apple) - { - env.append("URF=true"); - } - - qDebug() << "Prepend file env done"; - - ppm2pwg->setEnvironment(env); - - muraster->setStandardOutputProcess(ppm2pwg); - ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); - - connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); - connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); - //connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), tempfile, SLOT(deleteLater())); - - qDebug() << "All connected"; - - - muraster->start(); - ppm2pwg->start(); - - qDebug() << "Starting"; - - - if(!muraster->waitForStarted()) - { - qDebug() << "muraster died"; - return; - } - if(!ppm2pwg->waitForStarted()) - { - qDebug() << "ppm2pwg died"; - return; - } - qDebug() << "All started"; - - ppm2pwg->waitForFinished(); - - qDebug() << "Finished"; - -// IppRaster* raster = new IppRaster(ppm2pwg); -// raster->open(QIODevice::ReadOnly); -// request.setAttribute(QNetworkRequest::DoNotBufferUploadDataAttribute, true); - QMetaObject::invokeMethod(this, "doPost", Qt::QueuedConnection, - Q_ARG(QNetworkRequest, request), Q_ARG(QTemporaryFile*, tempfile) ); - qDebug() << "posted"; -} - -void IppPrinter::doPost(QNetworkRequest request, QTemporaryFile* data) +void IppPrinter::convertDone(QNetworkRequest request, QTemporaryFile* data) { + connect(_print_nam, SIGNAL(finished(QNetworkReply*)), data, SLOT(deleteLater())); data->open(); _print_nam->post(request, data); } +void IppPrinter::convertFailed() +{ + _jobAttrs = QJsonObject(); + _jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Internal error"}}); + emit jobAttrsChanged(); + emit jobFinished(false); +} void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << "printing" << filename << attrs; @@ -304,6 +255,12 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ QByteArray contents = job.encode(IppMsg::PrintJob); + QNetworkRequest request; + + request.setUrl(httpUrl()); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + // TODO: do this only conditionally, and to the raster suppoerted/preferred bool transcode = true; if(transcode) @@ -315,17 +272,10 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << tempfile->fileName(); tempfile->close(); - QtConcurrent::run(this, &IppPrinter::doWork, filename, tempfile); - + emit doConvertPdf(request, filename, tempfile); } else { - QNetworkRequest request; - - request.setUrl(httpUrl()); - request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); - QByteArray filedata = file.readAll(); contents = contents.append(filedata); file.close(); diff --git a/src/ippprinter.h b/src/ippprinter.h index 884949b..b187c7f 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -4,6 +4,7 @@ #include #include #include "ippmsg.h" +#include "convertworker.h" class IppPrinter : public QObject { @@ -36,6 +37,8 @@ signals: void jobFinished(bool status); void cancelStatus(bool status); + void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile); + public slots: void print(QJsonObject attrs, QString file); @@ -48,8 +51,8 @@ public slots: void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); - void doWork(QString filename, QTemporaryFile* tempfile); - void doPost(QNetworkRequest request, QTemporaryFile* data); + void convertDone(QNetworkRequest request, QTemporaryFile* data); + void convertFailed(); private: QUrl _url; @@ -66,6 +69,9 @@ private: QJsonObject _jobAttrs; QJsonArray _jobs; + QThread _workerThread; + ConvertWorker* _worker; + }; #endif // IPPPRINTER_H From 002af8c5f869cdb3c314386b7466abdc01b2fde7 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 17:32:38 +0200 Subject: [PATCH 29/94] Clean up random files added by QtCreator --- harbour-seaprint.pro | 7 ++---- src/ippprinter.cpp | 1 - src/ippraster.cpp | 57 -------------------------------------------- src/ippraster.h | 39 ------------------------------ 4 files changed, 2 insertions(+), 102 deletions(-) delete mode 100644 src/ippraster.cpp delete mode 100644 src/ippraster.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index edddf15..82bdc61 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -27,12 +27,10 @@ SOURCES += src/harbour-seaprint.cpp \ src/bytestream.cpp \ src/ippmsg.cpp \ src/ippprinter.cpp \ - src/mimer.cpp \ - src/ippraster.cpp + src/mimer.cpp DISTFILES += qml/harbour-seaprint.qml \ - ../harbour-splay/qml/pages/ChannelItem.qml \ qml/cover/CoverPage.qml \ qml/components/*.qml \ qml/pages/*.qml \ @@ -67,5 +65,4 @@ HEADERS += \ src/bytestream.h \ src/ippmsg.h \ src/ippprinter.h \ - src/mimer.h \ - src/ippraster.h + src/mimer.h diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 922cdb9..375980b 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,5 +1,4 @@ #include "ippprinter.h" -#include "ippraster.h" #include IppPrinter::IppPrinter() diff --git a/src/ippraster.cpp b/src/ippraster.cpp deleted file mode 100644 index 03ba815..0000000 --- a/src/ippraster.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include "ippraster.h" - -IppRaster::IppRaster(QIODevice *underlyingDevice) - : underlyingDevice(underlyingDevice) -{ - connect(underlyingDevice, SIGNAL(readyRead()), this, SLOT(doDataAvail())); - connect(underlyingDevice, SIGNAL(readChannelFinished()), this, SLOT(doReadFinished())); -} - -bool IppRaster::open(QIODevice::OpenMode mode) -{ - qDebug() << "open"; - - bool underlyingOk; - if (underlyingDevice->isOpen()) - underlyingOk = (underlyingDevice->openMode() == mode); - else - underlyingOk = underlyingDevice->open(mode); - - if (underlyingOk) { - setOpenMode(mode); - qDebug() << "open true"; - emit readyRead(); - return true; - } - qDebug() << underlyingOk << underlyingDevice->openMode() << underlyingDevice->isOpen() << mode << "borked"; - return false; -} - -void IppRaster::close() -{ - qDebug() << "close"; - underlyingDevice->close(); -} - -bool IppRaster::seek(qint64 pos) -{ - qDebug() << "seek"; - - return false; -} - -bool IppRaster::atEnd() const -{ - qDebug() << "atend"; - return underlyingDevice->atEnd(); -} - -qint64 IppRaster::readData(char *data, qint64 maxlen) -{ - qDebug() << "read" << maxlen; - return underlyingDevice->read(data, maxlen); -} -qint64 IppRaster::writeData(const char *data, qint64 len) -{ - return underlyingDevice->write(data, len); -} diff --git a/src/ippraster.h b/src/ippraster.h deleted file mode 100644 index da228c9..0000000 --- a/src/ippraster.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef IPPRASTER_H -#define IPPRASTER_H - -#include -#include - - -class IppRaster : public QIODevice -{ - Q_OBJECT - -public: - IppRaster(QIODevice *underlyingDevice); - ~IppRaster() {qDebug() << "deleted";} - - bool open(QIODevice::OpenMode mode) override; - void close() override; - bool seek(qint64) override; - bool atEnd() const override; - - qint64 readData(char *data, qint64 maxlen) override; - qint64 writeData(const char *data, qint64 len) override; - - bool isSequential() const override {return false;} - qint64 bytesAvailable() const override {return underlyingDevice->bytesAvailable();} - qint64 size() const override {return underlyingDevice->size();} - - bool waitForReadyRead(int msecs) {return true;} - - public slots: - void doDataAvail() {emit readyRead();} - void doReadFinished() {emit readChannelFinished();} - - -private: - QIODevice* underlyingDevice; -}; - -#endif From 1be1bb7cf5cfc2d4f7c7cfad31196be209ea9448 Mon Sep 17 00:00:00 2001 From: A Date: Fri, 1 May 2020 18:28:18 +0200 Subject: [PATCH 30/94] Create harbour-seaprint-pl.ts Polish translation --- translations/harbour-seaprint-pl.ts | 292 ++++++++++++++++++++++++++++ 1 file changed, 292 insertions(+) create mode 100644 translations/harbour-seaprint-pl.ts diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts new file mode 100644 index 0000000..23fc47d --- /dev/null +++ b/translations/harbour-seaprint-pl.ts @@ -0,0 +1,292 @@ + + + + + AboutPage + + GitHub repository + Repozytorium GitHub + + + Report an Issue + Raportuj błąd + + + About + O SeaPrint + + + Network printing for Sailfish OS. + Drukowanie sieciowe dla SailfishOS + + + Icons + Ikony + + + Icon made by Gregguh. + Ikona stworzona przez Gregguh. + + + General contributions + Główni developerzy + + + Translations + Tłumaczenia + + + Chinese + Chiński + + + Licensing + Licencjonowanie + + + Source code is available at GitHub. Translations, bug reports and other contributions are welcome! + Źródła dostępne na GitHub. Tłumaczenia,raportowanie błędów i inna pomoc mile widziane! + + + SeaPrint licencing is still TBD, but will be some flavor of open. + Licencjonowanie SeaPrint jest jeszcze nieustalone, ale będzie jakąś odmianą wolnej licencji. + + + French + Francuski + + + Code and Testing - Rudi Timmermans + Kod i Testowanie - Rudi Timmermans + + + Spanish + Hiszpański + + + + AddPrinterDialog + + Add printer + Dodaj drukarkę + + + On WiFI: + Na WIFI: + + + Found: + Znalezione: + + + No printer found + Nie znaleziono drukarek + + + Unknown + Nieznana drukarka + + + + CoverPage + + SeaPrint + SeaPrint + + + + FirstPage + + Add by URL + Dodaj za pomocą URL + + + URL + URL + + + Refresh + Odśwież + + + No file selected + Nie wybrano pliku + + + View jobs + Wyświetl zadania + + + Remove printer + Usuń drukarkę + + + Removing printer + Usuwanie drukarki + + + About SeaPrint + O SeaPrint + + + Unknown + Nieznany + + + No compatible formats supported + Brak obsługiwanych kompatybilnych formatów + + + Choose file + Wybierz plik + + + + JobsPage + + Refresh + Odśwież + + + jobs + zadania + + + Untitled job + Zadania bez nazwy + + + Cancel job + Anuluj zadanie + + + Cancelling job + usuwanie zadania + + + job + zadanie + + + Cancelling job failed + Nieudane usuwanie zadania + + + + PrinterPage + + Print + Drukuj + + + Sides + Strony + + + Copies + Kopie + + + Color mode + Tryb koloru + + + Quality + Jakość + + + Resolution + Rozdzielczość + + + Print success: + Drukowanie udane: + + + Print failed: + Nieudane drukowanie: + + + Print media + Drukuj multimedia + + + + utils + + pending + oczekiwanie + + + pending-held + w toku + + + processing + procesowanie + + + processing-stopped + procesowanie zatrzymane + + + canceled + anulowano + + + aborted + przerwano + + + completed + ukończone + + + unknown state + nieznany stan + + + draft + szkic + + + normal + normalny + + + high + wysoka + + + unknown quality + nieznana jakość + + + portrait + portretowy + + + landscape + horyzontalny + + + reverse landscape + odwrócony horyzontalny + + + reverse portrait + odwrócony horyzontalny + + + unknown orientation + nieznany układ + + + dpi + dpi + + + dots/cm + punkty/cm + + From cd0c785dc94b5baf6d889fe5d59a4f1b672b75c3 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 20:56:44 +0200 Subject: [PATCH 31/94] Remve non-existing include --- src/ippprinter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 2c49dc0..8149c5d 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,5 +1,4 @@ #include "ippprinter.h" -#include "ioprepender.h" #include IppPrinter::IppPrinter() From b705cc28ea3e0731d22e797e6ca45f603c477d09 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 1 May 2020 20:54:33 +0200 Subject: [PATCH 32/94] add ppm2pwg as a submodule --- .gitmodules | 3 +++ harbour-seaprint.pro | 11 +++++++++++ ppm2pwg | 1 + src/convertworker.cpp | 5 ++++- 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 .gitmodules create mode 160000 ppm2pwg diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..16d56a3 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ppm2pwg"] + path = ppm2pwg + url = https://github.com/attah/ppm2pwg.git diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 82bdc61..89554b7 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -66,3 +66,14 @@ HEADERS += \ src/ippmsg.h \ src/ippprinter.h \ src/mimer.h + + +QMAKE_EXTRA_TARGETS += PPM2PWG +PRE_TARGETDEPS += PPM2PWG +PPM2PWG.commands = make -C $$PWD/ppm2pwg +PPM2PWG.clean_commands = git submodule foreach git clean -fdxq +PPM2PWG.path = /usr/share/harbour-seaprint/ +PPM2PWG.files += $$PWD/ppm2pwg/ppm2pwg + +INSTALLS += PPM2PWG +QMAKE_INSTALL_FILE = install -m 755 -p diff --git a/ppm2pwg b/ppm2pwg new file mode 160000 index 0000000..a3ea2da --- /dev/null +++ b/ppm2pwg @@ -0,0 +1 @@ +Subproject commit a3ea2da52a0b8432ba7e6ec59451ae3887b1a111 diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 4d3e8c1..dd5f599 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -1,4 +1,5 @@ #include "convertworker.h" +#include void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile) { @@ -9,7 +10,9 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo QProcess* ppm2pwg = new QProcess(this); - ppm2pwg->setProgram("/home/nemo/repos/pwg/ppm2pwg"); + qDebug() << SailfishApp::pathTo("ppm2pwg").toString(); + QString Ppm2pwgPath = SailfishApp::pathTo("ppm2pwg").toString().remove("file://"); + ppm2pwg->setProgram(Ppm2pwgPath); QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; bool apple = false; From 69fa9e52fb98dd8d74f5251128f0db160524e0df Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 2 May 2020 18:14:33 +0200 Subject: [PATCH 33/94] Change to poppler for pdf conversion --- src/convertworker.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index dd5f599..271f805 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -4,13 +4,12 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile) { - QProcess* muraster = new QProcess(this); - muraster->setProgram("/home/nemo/stuff/bin/muraster"); - muraster->setArguments({"-F", "pgm", filename}); + QProcess* pdftoppm = new QProcess(this); + pdftoppm->setProgram("pdftoppm"); + pdftoppm->setArguments({"-gray", "-rx", "300", "-ry", "300", filename}); QProcess* ppm2pwg = new QProcess(this); - qDebug() << SailfishApp::pathTo("ppm2pwg").toString(); QString Ppm2pwgPath = SailfishApp::pathTo("ppm2pwg").toString().remove("file://"); ppm2pwg->setProgram(Ppm2pwgPath); QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; @@ -25,24 +24,24 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setEnvironment(env); - muraster->setStandardOutputProcess(ppm2pwg); + pdftoppm->setStandardOutputProcess(ppm2pwg); ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); - connect(muraster, SIGNAL(finished(int, QProcess::ExitStatus)), muraster, SLOT(deleteLater())); + connect(pdftoppm, SIGNAL(finished(int, QProcess::ExitStatus)), pdftoppm, SLOT(deleteLater())); connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); qDebug() << "All connected"; - muraster->start(); + pdftoppm->start(); ppm2pwg->start(); qDebug() << "Starting"; - if(!muraster->waitForStarted()) + if(!pdftoppm->waitForStarted()) { - qDebug() << "muraster died"; + qDebug() << "pdftoppm died"; tempfile->deleteLater(); emit failed(); return; From cd31098279bcbd4319bf637c1229b3f25f7648e9 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 3 May 2020 14:13:44 +0200 Subject: [PATCH 34/94] Add basic conversion heuristics --- qml/pages/utils.js | 2 +- src/convertworker.cpp | 4 ++-- src/convertworker.h | 3 ++- src/ippprinter.cpp | 41 +++++++++++++++++++++++++++++++++++------ src/ippprinter.h | 16 +++++++++++++++- 5 files changed, 55 insertions(+), 11 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 107b962..aed7d4a 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -3,7 +3,7 @@ function supported_formats(printer) var formats = printer.attrs["document-format-supported"].value; var mimetypes = []; var supported = []; - if(has(formats, "application/pdf")) + if(has(formats, "application/pdf") || as(formats, "application/pwg-raster") || has(formats, "application/urf") ) { mimetypes.push("application/pdf"); supported.push("PDF"); diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 271f805..eb0405a 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -1,7 +1,8 @@ #include "convertworker.h" #include -void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile) +void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, + bool apple, QTemporaryFile* tempfile) { QProcess* pdftoppm = new QProcess(this); @@ -14,7 +15,6 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setProgram(Ppm2pwgPath); QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; - bool apple = false; if(apple) { env.append("URF=true"); diff --git a/src/convertworker.h b/src/convertworker.h index bce308a..6454840 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -8,7 +8,8 @@ class ConvertWorker : public QObject Q_OBJECT public slots: - void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile); + void convertPdf(QNetworkRequest request, QString filename, + bool apple, QTemporaryFile* tempfile); //convertImage(); signals: diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 375980b..335a46a 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,5 +1,6 @@ #include "ippprinter.h" #include +#include "mimer.h" IppPrinter::IppPrinter() { @@ -260,9 +261,37 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); - // TODO: do this only conditionally, and to the raster suppoerted/preferred - bool transcode = true; - if(transcode) + + Mimer* mimer = Mimer::instance(); + QString mimeType = mimer->get_type(filename); + ConvertFrom from = NotConvertable; + ConvertTarget target = NoConvert; + + if(mimeType == "application/pdf") + { + from = Pdf; + } + else if (mimeType.contains("image")) { +// from = Image; TODO: handle image conversions + } + + QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); + + qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); + + if(from == Pdf) + { + if(supportedMimeTypes.contains("image/pwg-raster")) + { + target = PwgConvert; + } + else if (supportedMimeTypes.contains("image/urf")) + { + target = UrfConvert; + } + } + + if(from == Pdf && target != NoConvert) { file.close(); QTemporaryFile* tempfile = new QTemporaryFile(); @@ -271,10 +300,10 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << tempfile->fileName(); tempfile->close(); - emit doConvertPdf(request, filename, tempfile); + emit doConvertPdf(request, filename, target==UrfConvert, tempfile); } - else { - + else + { QByteArray filedata = file.readAll(); contents = contents.append(filedata); file.close(); diff --git a/src/ippprinter.h b/src/ippprinter.h index b187c7f..4d3f55c 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -28,6 +28,20 @@ public: Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool cancelJob(qint32 jobId); + enum ConvertTarget + { + NoConvert, + PwgConvert, + UrfConvert + }; + + enum ConvertFrom + { + NotConvertable, + Pdf, + Image + }; + signals: void urlChanged(); void attrsChanged(); @@ -37,7 +51,7 @@ signals: void jobFinished(bool status); void cancelStatus(bool status); - void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile); + void doConvertPdf(QNetworkRequest request, QString filename, bool urf, QTemporaryFile* tempfile); public slots: void print(QJsonObject attrs, QString file); From 8b1c063f48d043169f2bbee506ee12ea723cf48c Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 3 May 2020 14:26:55 +0200 Subject: [PATCH 35/94] 0.4.5 --- qml/pages/PrinterPage.qml | 2 +- rpm/harbour-seaprint.spec | 4 ++-- translations/harbour-seaprint-de.ts | 4 ---- translations/harbour-seaprint-es.ts | 4 ---- translations/harbour-seaprint-fr.ts | 4 ---- translations/harbour-seaprint-zh_CN.ts | 4 ---- translations/harbour-seaprint.ts | 4 ---- 7 files changed, 3 insertions(+), 23 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 2ea9a46..eb54ff9 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -51,7 +51,7 @@ Page { ListModel { id:mod ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} - ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} +// ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} // ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index 2d3cf55..4d05046 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,8 +9,8 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4.4 -Release: 2 +Version: 0.4.5 +Release: 1 Group: Qt/Qt License: LICENSE URL: http://example.org/ diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 025f610..98d5b06 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -206,10 +206,6 @@ Print failed: - - Print media - - utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index f16f573..ee45ead 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -206,10 +206,6 @@ Print failed: Impresión fallida: - - Print media - - utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 8e5b2a6..714c3e1 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -206,10 +206,6 @@ Print failed: Échec de l'impression : - - Print media - - utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 0f3f8b2..5909123 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -206,10 +206,6 @@ Print failed: 打印失败: - - Print media - - utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 4c3c91d..4a02c1b 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -206,10 +206,6 @@ Print failed: - - Print media - - utils From 4519f0a13e7b59225fb391f44d3fb1203812ed10 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 5 May 2020 20:07:21 +0200 Subject: [PATCH 36/94] move ppm2pwg to inside seaprint --- harbour-seaprint.pro | 25 +- ppm2pwg | 2 +- src/bytestream.cpp | 553 --------------------------------------- src/bytestream.h | 189 ------------- src/convertworker.cpp | 5 +- src/harbour-seaprint.cpp | 9 + src/ippprinter.cpp | 2 +- 7 files changed, 24 insertions(+), 761 deletions(-) delete mode 100644 src/bytestream.cpp delete mode 100644 src/bytestream.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 89554b7..c8fa873 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -24,11 +24,11 @@ write_file($$$$OUT_PWD/seaprint_version.h, VERSION_H) SOURCES += src/harbour-seaprint.cpp \ src/convertworker.cpp \ src/ippdiscovery.cpp \ - src/bytestream.cpp \ src/ippmsg.cpp \ src/ippprinter.cpp \ - src/mimer.cpp - + src/mimer.cpp \ + ppm2pwg/ppm2pwg.cpp \ + ppm2pwg/bytestream/bytestream.cpp DISTFILES += qml/harbour-seaprint.qml \ qml/cover/CoverPage.qml \ @@ -62,18 +62,13 @@ TRANSLATIONS += translations/harbour-seaprint-de.ts \ HEADERS += \ src/convertworker.h \ src/ippdiscovery.h \ - src/bytestream.h \ src/ippmsg.h \ src/ippprinter.h \ - src/mimer.h + src/mimer.h \ + ppm2pwg/pwg_pghdr_codable.h \ + ppm2pwg/urf_pghdr_codable.h \ + ppm2pwg/bytestream/bytestream.h \ + ppm2pwg/bytestream/codable.h - -QMAKE_EXTRA_TARGETS += PPM2PWG -PRE_TARGETDEPS += PPM2PWG -PPM2PWG.commands = make -C $$PWD/ppm2pwg -PPM2PWG.clean_commands = git submodule foreach git clean -fdxq -PPM2PWG.path = /usr/share/harbour-seaprint/ -PPM2PWG.files += $$PWD/ppm2pwg/ppm2pwg - -INSTALLS += PPM2PWG -QMAKE_INSTALL_FILE = install -m 755 -p +INCLUDEPATH += ppm2pwg \ + ppm2pwg/bytestream diff --git a/ppm2pwg b/ppm2pwg index a3ea2da..ec851c5 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit a3ea2da52a0b8432ba7e6ec59451ae3887b1a111 +Subproject commit ec851c5286fecfdded0bdf76453362a1829cc5c8 diff --git a/src/bytestream.cpp b/src/bytestream.cpp deleted file mode 100644 index 4cf97cd..0000000 --- a/src/bytestream.cpp +++ /dev/null @@ -1,553 +0,0 @@ -#include "bytestream.h" -#include -#include -#include -using namespace std; - -Bytestream::Bytestream() -{ - _size = 0; - _pos = 0; - _noOfNextBytes = 0; - _noOfNextBytesValid = false; - _endianness = BigEndian; -} - -Bytestream::Bytestream(size_t len) -{ - _size = len; - _data = new uint8_t[_size]; - memset(_data, 0, _size); - _pos = 0; - _noOfNextBytes = 0; - _noOfNextBytesValid = false; - _endianness = BigEndian; -} - -Bytestream::Bytestream(const void* data, size_t len) -{ - _size = len; - _data = new uint8_t[_size]; - memcpy(_data, data, _size); - _pos = 0; - _noOfNextBytes = 0; - _noOfNextBytesValid = false; - _endianness = BigEndian; -} -Bytestream::Bytestream(const void* data, size_t len, Endianness e) -{ - _size = len; - _data = new uint8_t[_size]; - memcpy(_data, data, _size); - _pos = 0; - _noOfNextBytes = 0; - _noOfNextBytesValid = false; - _endianness = e; -} - -Bytestream::Bytestream(const Bytestream& rhs) -{ - _size = rhs._size; - _data = new uint8_t[_size]; - memcpy(_data, rhs._data, _size); - _pos = rhs._pos; - _noOfNextBytes = 0; - _noOfNextBytesValid = false; - _endianness = rhs._endianness; -} - -Bytestream::~Bytestream() -{ - if(_size != 0) - { - delete _data; - } -} - -bool Bytestream::operator==(const Bytestream& other) const -{ - if(_size != other.size()) - { - return false; - } - return memcmp(_data, other.raw(), _size) == 0; -} -bool Bytestream::operator!=(const Bytestream& other) const -{ - if(_size != other.size()) - { - return true; - } - return memcmp(_data, other.raw(), _size) != 0; -} - -Bytestream& Bytestream::operator=(const Bytestream& other) -{ - if(_size != 0) - { - delete _data; - } - _pos = other.pos(); - _size = other.size(); - _data = new uint8_t[_size]; - memcpy(_data, other.raw(), _size); - return *this; -} - -template -T bswap(T u) -{ - uint8_t* const p = reinterpret_cast(&u); - for (size_t i = 0; i < sizeof(T) / 2; i++) - { - std::swap(p[i], p[sizeof(T) - i - 1]); - } - return u; -} - -#define GET(type, shorthand, len) GET_(type##len##_t, shorthand##len, len) -#define GET_(type, shortType, len) \ - type Bytestream::get##shortType() \ - {type tmp; getBytes(&tmp, sizeof(type));\ - if(needsSwap()){tmp=bswap(tmp);} return tmp;} - -GET(uint, U, 8) -GET(uint, U, 16) -GET(uint, U, 32) -GET(uint, U, 64) -GET(int, S, 8) -GET(int, S, 16) -GET(int, S, 32) -GET(int, S, 64) -GET(float, F, 32) -GET(float, F, 64) - -std::string Bytestream::getString() -{ - if(!_noOfNextBytesValid) - { - throw invalid_argument("No length given"); - } - char* cs = new char[_noOfNextBytes+1]; - cs[_noOfNextBytes] = 0; - getBytes(cs, _noOfNextBytes); - string s = std::string(cs, _noOfNextBytes); - delete cs; - return s; -} -Bytestream Bytestream::getBytestream() -{ - if(!_noOfNextBytesValid) - { - throw invalid_argument("No length given"); - } - uint8_t* cs = new uint8_t[_noOfNextBytes]; - getBytes(cs, _noOfNextBytes); - Bytestream other = Bytestream(cs, _noOfNextBytes); - delete cs; - return other; -} -std::string Bytestream::getString(size_t len) -{ - if(_noOfNextBytesValid && len != _noOfNextBytes) - { - throw logic_error("Desired lengths does not match"); - } - else if(!_noOfNextBytesValid) - { - setNoOfNextBytes(len); - } - return getString(); -} -Bytestream Bytestream::getBytestream(size_t len) -{ - if(!_noOfNextBytesValid && len != _noOfNextBytes) - { - throw logic_error("Desired lengths does not match"); - } - setNoOfNextBytes(len); - return getBytestream(); -} - -void Bytestream::getBytes(void* cs, size_t len) - { - _before(len); - memcpy(cs, &(_data[_pos]), len); - _after(len); -} - - -#define PEEK(type, shorthand, len) PEEK_(type##len##_t, shorthand##len, len) -#define PEEK_(type, shortType, len) \ - type Bytestream::peek##shortType() \ - {type tmp; getBytes(&tmp, sizeof(type));\ - if(needsSwap()){tmp=bswap(tmp);} (*this) -= sizeof(type); return tmp;} - -PEEK(uint, U, 8) -PEEK(uint, U, 16) -PEEK(uint, U, 32) -PEEK(uint, U, 64) -PEEK(int, S, 8) -PEEK(int, S, 16) -PEEK(int, S, 32) -PEEK(int, S, 64) -PEEK(float, F, 32) -PEEK(float, F, 64) - -std::string Bytestream::peekString() -{ - if(!_noOfNextBytesValid) - { - throw invalid_argument("No length given"); - } - char* cs = new char[_noOfNextBytes+1]; - cs[_noOfNextBytes] = 0; - getBytes(cs, _noOfNextBytes); - string s = std::string(cs, _noOfNextBytes); - delete cs; - (*this) -= _noOfNextBytes; - return s; -} -Bytestream Bytestream::peekBytestream() -{ - if(!_noOfNextBytesValid) - { - throw invalid_argument("No length given"); - } - uint8_t* cs = new uint8_t[_noOfNextBytes]; - getBytes(cs, _noOfNextBytes); - Bytestream other = Bytestream(cs, _noOfNextBytes); - delete cs; - (*this) -= _noOfNextBytes; - return other; -} -std::string Bytestream::peekString(size_t len) -{ - if(_noOfNextBytesValid && len != _noOfNextBytes) - { - throw logic_error("Desired lengths does not match"); - } - else if(!_noOfNextBytesValid) - { - setNoOfNextBytes(len); - } - return peekString(); -} -Bytestream Bytestream::peekBytestream(size_t len) -{ - if(!_noOfNextBytesValid && len != _noOfNextBytes) - { - throw logic_error("Desired lengths does not match"); - } - setNoOfNextBytes(len); - return peekBytestream(); -} - -#define NEXT(type, shorthand, len) NEXT_(type##len##_t, shorthand##len) -#define NEXT_(type, shortType) \ - bool Bytestream::next##shortType(type u) \ - {if(u == get##shortType())\ - {return true;} \ - else\ - {(*this) -= sizeof(type);\ - return false;}} - -NEXT(uint, U, 8) -NEXT(uint, U, 16) -NEXT(uint, U, 32) -NEXT(uint, U, 64) -NEXT(int, S, 8) -NEXT(int, S, 16) -NEXT(int, S, 32) -NEXT(int, S, 64) -NEXT(float, F, 32) -NEXT(float, F, 64) - -bool Bytestream::nextString(const std::string& s) -{ - if(_noOfNextBytesValid && getNoOfNextBytes() != s.length()) - { - throw logic_error("Desired length does not match const length"); - } - else if(!_noOfNextBytesValid) - { - setNoOfNextBytes(s.length()); - } - - size_t noOfNextBytes = getNoOfNextBytes(); - - if(noOfNextBytes > remaining()) - { - invalidateNoOfNextBytes(); - return false; - } - - if(getString() == s) - { - return true; - } - else - { - (*this) -= noOfNextBytes; - return false; - } -} -bool Bytestream::nextBytestream(const Bytestream& other) -{ - if(_noOfNextBytesValid && getNoOfNextBytes() != other.size()) - { - throw logic_error("Desired length does not match const length"); - } - else if(!_noOfNextBytesValid) - { - setNoOfNextBytes(other.size()); - } - - size_t noOfNextBytes = getNoOfNextBytes(); - - if(noOfNextBytes > remaining()) - { - invalidateNoOfNextBytes(); - return false; - } - - if(getBytestream() == other) - { - return true; - } - else - { - (*this) -= noOfNextBytes; - return false; - } -} - -#define PUT(type, shorthand, len) PUT_(type##len##_t, shorthand##len, len) -#define PUT_(type, shortType, len) \ - void Bytestream::put##shortType(type u) \ - {if(needsSwap()){u=bswap(u);} \ - putBytes(&u, sizeof(u));} - -PUT(uint, U, 8) -PUT(uint, U, 16) -PUT(uint, U, 32) -PUT(uint, U, 64) -PUT(int, S, 8) -PUT(int, S, 16) -PUT(int, S, 32) -PUT(int, S, 64) -PUT(float, F, 32) -PUT(float, F, 64) - -void Bytestream::putString(const std::string& s) -{ - putBytes(s.c_str(), s.length()); -} -void Bytestream::putBytestream(const Bytestream& other) -{ - putBytes(other.raw(), other.size()); -} - -void Bytestream::putBytes(const void* c, size_t len) -{ - uint8_t* old = _data; - _data = new uint8_t[_size+len]; - - if (_size != 0) - { - memcpy(_data, old, _size); - delete old; - } - memcpy((_data+_size), c, len); - _size += len; -} - -void Bytestream::setNoOfNextBytes(size_t n) -{ - _noOfNextBytes = n; - _noOfNextBytesValid = true; -} - -void Bytestream::invalidateNoOfNextBytes() -{ - _noOfNextBytes = 0; - _noOfNextBytesValid = false; -} - - -void Bytestream::_before(size_t bytesToRead) -{ - if(bytesToRead > remaining()) - { - invalidateNoOfNextBytes(); - throw out_of_range("Tried to read past end"); - } -} - -void Bytestream::_after(size_t bytesRead) -{ - _pos += bytesRead; - _noOfNextBytesValid = false; -} - -Bytestream Bytestream::operator[](size_t i) -{ - Bytestream tmp(_data+i, _size-i); - return tmp; -} - -Bytestream& Bytestream::operator+=(size_t i) -{ - if((_pos+i) > _size) - { - invalidateNoOfNextBytes(); - throw out_of_range("Tried to address data past end"); - } - _pos += i; - return *this; -} - -Bytestream& Bytestream::operator-=(size_t i) -{ - _pos -= i; - return *this; -} - -Bytestream& Bytestream::operator/(int i) -{ - setNoOfNextBytes(i); - return *this; -} - -#define PUTOP(type, shorthand, len) PUTOP_(type##len##_t, shorthand##len) -#define PUTOP_(type, shortType) \ - Bytestream& Bytestream::operator<<(const type& u) \ - {put##shortType(u); return *this;} - -PUTOP(uint, U, 8) -PUTOP(uint, U, 16) -PUTOP(uint, U, 32) -PUTOP(uint, U, 64) -PUTOP(int, S, 8) -PUTOP(int, S, 16) -PUTOP(int, S, 32) -PUTOP(int, S, 64) -PUTOP(float, F, 32) -PUTOP(float, F, 64) - -Bytestream& Bytestream::operator<<(const std::string& s) -{ - putString(s); - return *this; -} -Bytestream& Bytestream::operator<<(const Bytestream& other) -{ - putBytestream(other); - return *this; -} - -#define GETOP(type, shorthand, len) GETOP_(type##len##_t, shorthand##len) -#define GETOP_(type, shortType) \ - Bytestream& Bytestream::operator>>(type& u) \ - {u = get##shortType(); return *this;} - -GETOP(uint, U, 8) -GETOP(uint, U, 16) -GETOP(uint, U, 32) -GETOP(uint, U, 64) -GETOP(int, S, 8) -GETOP(int, S, 16) -GETOP(int, S, 32) -GETOP(int, S, 64) -GETOP(float, F, 32) -GETOP(float, F, 64) - -Bytestream& Bytestream::operator>>(std::string& s) -{ - s = getString(); - return *this; -} -Bytestream& Bytestream::operator>>(Bytestream& other) -{ - other = getBytestream(); - return *this; -} - -#define GETOP_CONST(type, shorthand, len) \ - GETOP_CONST_(type##len##_t, shorthand##len) -#define GETOP_CONST_(type, shortType) \ - Bytestream& Bytestream::operator>>(const type& u) \ - {type v = get##shortType();\ - if(u!=v) {(*this) -= sizeof(type);\ - throw Badmatch("Does not match const", v, u);}\ - else{return *this;}} - -GETOP_CONST(uint, U, 8) -GETOP_CONST(uint, U, 16) -GETOP_CONST(uint, U, 32) -GETOP_CONST(uint, U, 64) -GETOP_CONST(int, S, 8) -GETOP_CONST(int, S, 16) -GETOP_CONST(int, S, 32) -GETOP_CONST(int, S, 64) -GETOP_CONST(float, F, 32) -GETOP_CONST(float, F, 64) - -Bytestream& Bytestream::operator>>(const std::string& s) -{ - if (_noOfNextBytesValid && getNoOfNextBytes() != s.length()) - { - throw logic_error("Desired length does not match const length"); - } - else if(!_noOfNextBytesValid) - { - setNoOfNextBytes(s.length()); - } - std::string sv = getString(); - if(sv != s) - { - (*this) -= s.length(); - throw Badmatch("Does not match const", sv, s); - } - return *this; -} - -#define NEXTOP(type, shorthand, len) NEXTOP_(type##len##_t, shorthand##len) -#define NEXTOP_(type, shortType) \ - bool Bytestream::operator>>=(const type& u) \ - {return next##shortType(u);} - -NEXTOP(uint, U, 8) -NEXTOP(uint, U, 16) -NEXTOP(uint, U, 32) -NEXTOP(uint, U, 64) -NEXTOP(int, S, 8) -NEXTOP(int, S, 16) -NEXTOP(int, S, 32) -NEXTOP(int, S, 64) -NEXTOP(float, F, 32) -NEXTOP(float, F, 64) -bool Bytestream::operator>>=(const std::string& s) -{ - return nextString(s); -} -bool Bytestream::operator>>=(const Bytestream& other) -{ - return nextBytestream(other); -} - -#if __BYTE_ORDER == __LITTLE_ENDIAN -bool Bytestream::needsSwap() -{ - return _endianness != Endianness::NativeEndian - && _endianness != Endianness::LittleEndian; -} -#elif __BYTE_ORDER == __BIG_ENDIAN -bool Bytestream::needsSwap() -{ - return _endianness != Endianness::NativeEndian - && _endianness != Endianness::BigEndian; -} -#else -#error -#endif diff --git a/src/bytestream.h b/src/bytestream.h deleted file mode 100644 index 709aea8..0000000 --- a/src/bytestream.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef BYTESTREAM_H -#define BYTESTREAM_H -#include -#include -#include -#ifndef __STDC_IEC_559__ -#error "Double must be IEEE 754" -#endif -#define float32_t float -#define float64_t double -class Bytestream -{ -public: - - class Badmatch : public std::invalid_argument::invalid_argument - { - public: - Badmatch(std::string s, std::string v, std::string u) : - invalid_argument(s+": "+v+" != "+u) {} - template - Badmatch(std::string s, T v, T u) : - invalid_argument(s+": "+std::to_string(v)+" != "+std::to_string(u)) {} - - }; - - enum Endianness { - NativeEndian, - BigEndian, - LittleEndian - }; - - Bytestream(); - Bytestream(size_t len); - Bytestream(const void* data, size_t len); - Bytestream(const void* data, size_t len, Endianness e); - Bytestream(const Bytestream& rhs); - ~Bytestream(); - - bool operator==(const Bytestream& other) const; - bool operator!=(const Bytestream& other) const; - - Bytestream& operator=(const Bytestream& other); - - uint8_t* raw() const {return _data;} - size_t size() const {return _size;} - size_t pos() const {return _pos;} - size_t remaining() const {return _size - _pos;} - bool atEnd() const {return _pos >= _size;} - void setPos(size_t pos) {_pos = pos;} - Endianness getEndianness() {return _endianness;} - void setEndianness(Endianness e) {_endianness = e;} - - uint8_t getU8(); - uint16_t getU16(); - uint32_t getU32(); - uint64_t getU64(); - int8_t getS8(); - int16_t getS16(); - int32_t getS32(); - int64_t getS64(); - float32_t getF32(); - float64_t getF64(); - std::string getString(); - Bytestream getBytestream(); - std::string getString(size_t len); - Bytestream getBytestream(size_t len); - void getBytes(void* cs, size_t len); - - uint8_t peekU8(); - uint16_t peekU16(); - uint32_t peekU32(); - uint64_t peekU64(); - int8_t peekS8(); - int16_t peekS16(); - int32_t peekS32(); - int64_t peekS64(); - float32_t peekF32(); - float64_t peekF64(); - std::string peekString(); - Bytestream peekBytestream(); - std::string peekString(size_t len); - Bytestream peekBytestream(size_t len); - - bool nextU8(uint8_t); - bool nextU16(uint16_t); - bool nextU32(uint32_t); - bool nextU64(uint64_t); - bool nextS8(int8_t); - bool nextS16(int16_t); - bool nextS32(int32_t); - bool nextS64(int64_t); - bool nextF32(float32_t); - bool nextF64(float64_t); - bool nextString(const std::string& bts); - bool nextBytestream(const Bytestream& bts); - - void putU8(uint8_t); - void putU16(uint16_t); - void putU32(uint32_t); - void putU64(uint64_t); - void putS8(int8_t); - void putS16(int16_t); - void putS32(int32_t); - void putS64(int64_t); - void putF32(float32_t); - void putF64(float64_t); - void putString(const std::string&); - void putBytestream(const Bytestream&); - void putBytes(const void* c, size_t len); - - void setNoOfNextBytes(size_t n); - void invalidateNoOfNextBytes(); - size_t getNoOfNextBytes() {return _noOfNextBytes;} - bool noOfNextBytesValid() const {return _noOfNextBytesValid;} - - Bytestream operator[](size_t i); - Bytestream& operator+=(size_t i); - Bytestream& operator-=(size_t i); - - Bytestream& operator/(int i); - - Bytestream& operator<<(const uint8_t& u); - Bytestream& operator<<(const uint16_t& u); - Bytestream& operator<<(const uint32_t& u); - Bytestream& operator<<(const uint64_t& u); - Bytestream& operator<<(const int8_t& u); - Bytestream& operator<<(const int16_t& u); - Bytestream& operator<<(const int32_t& u); - Bytestream& operator<<(const int64_t& u); - Bytestream& operator<<(const float32_t& u); - Bytestream& operator<<(const float64_t& u); - Bytestream& operator<<(const std::string& s); - Bytestream& operator<<(const Bytestream& other); - - Bytestream& operator>>(uint8_t& u); - Bytestream& operator>>(uint16_t& u); - Bytestream& operator>>(uint32_t& u); - Bytestream& operator>>(uint64_t& u); - Bytestream& operator>>(int8_t& u); - Bytestream& operator>>(int16_t& u); - Bytestream& operator>>(int32_t& u); - Bytestream& operator>>(int64_t& u); - Bytestream& operator>>(float32_t& u); - Bytestream& operator>>(float64_t& u); - Bytestream& operator>>(std::string& s); - Bytestream& operator>>(Bytestream& other); - - Bytestream& operator>>(const uint8_t& u); - Bytestream& operator>>(const uint16_t& u); - Bytestream& operator>>(const uint32_t& u); - Bytestream& operator>>(const uint64_t& u); - Bytestream& operator>>(const int8_t& u); - Bytestream& operator>>(const int16_t& u); - Bytestream& operator>>(const int32_t& u); - Bytestream& operator>>(const int64_t& u); - Bytestream& operator>>(const float32_t& u); - Bytestream& operator>>(const float64_t& u); - Bytestream& operator>>(const std::string& s); - - bool operator>>=(const uint8_t& u); - bool operator>>=(const uint16_t& u); - bool operator>>=(const uint32_t& u); - bool operator>>=(const uint64_t& u); - bool operator>>=(const int8_t& u); - bool operator>>=(const int16_t& u); - bool operator>>=(const int32_t& u); - bool operator>>=(const int64_t& u); - bool operator>>=(const float32_t& u); - bool operator>>=(const float64_t& u); - bool operator>>=(const std::string& s); - bool operator>>=(const Bytestream& other); - - -private: - uint8_t* _data; - size_t _size; - size_t _pos; - size_t _noOfNextBytes; - bool _noOfNextBytesValid; - - Endianness _endianness; - - bool needsSwap(); - - void _after(size_t bytesRead); - void _before(size_t bytesToRead); -}; - -#endif diff --git a/src/convertworker.cpp b/src/convertworker.cpp index eb0405a..678acb3 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -11,8 +11,9 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QProcess* ppm2pwg = new QProcess(this); - QString Ppm2pwgPath = SailfishApp::pathTo("ppm2pwg").toString().remove("file://"); - ppm2pwg->setProgram(Ppm2pwgPath); + // Yo dwag, I heard you like programs... + ppm2pwg->setProgram("harbour-seaprint"); + ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; if(apple) diff --git a/src/harbour-seaprint.cpp b/src/harbour-seaprint.cpp index 2cdd31f..2d4b1e5 100644 --- a/src/harbour-seaprint.cpp +++ b/src/harbour-seaprint.cpp @@ -6,6 +6,9 @@ #include #include +#define PPM2PWG_MAIN ppm2pwg_main +#include + template static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) { @@ -19,6 +22,12 @@ static QObject* singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngi int main(int argc, char *argv[]) { + if(argc >= 1 && QString("ppm2pwg") == argv[1]) + { + return ppm2pwg_main(argc-1, &(argv[1])); + } + + QGuiApplication* app = SailfishApp::application(argc, argv); app->setApplicationVersion(QStringLiteral(SEAPRINT_VERSION)); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 335a46a..a02b669 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -279,7 +279,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(from == Pdf) + if(from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/) { if(supportedMimeTypes.contains("image/pwg-raster")) { From a586dcca1a7540c5b9452d956251203e15d585fa Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Tue, 5 May 2020 20:36:01 +0200 Subject: [PATCH 37/94] Get dpi for pdf conversion from settings or defaults --- src/convertworker.cpp | 11 ++++++----- src/convertworker.h | 2 +- src/ippprinter.cpp | 16 +++++++++++++++- src/ippprinter.h | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 678acb3..27b81cc 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -2,27 +2,28 @@ #include void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, - bool apple, QTemporaryFile* tempfile) + bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile) { + QString HwResX_s = QString::number(HwResX); + QString HwResY_s = QString::number(HwResY); + QProcess* pdftoppm = new QProcess(this); pdftoppm->setProgram("pdftoppm"); - pdftoppm->setArguments({"-gray", "-rx", "300", "-ry", "300", filename}); + pdftoppm->setArguments({"-gray", "-rx", HwResX_s, "-ry", HwResY_s, filename}); QProcess* ppm2pwg = new QProcess(this); // Yo dwag, I heard you like programs... ppm2pwg->setProgram("harbour-seaprint"); ppm2pwg->setArguments({"ppm2pwg"}); - QStringList env; // {"PREPEND_FILE="+tempfile->fileName()}; + QStringList env = {"HWRES_X="+HwResX_s, "HWRES_Y="+HwResY_s}; if(apple) { env.append("URF=true"); } - qDebug() << "Prepend file env done"; - ppm2pwg->setEnvironment(env); pdftoppm->setStandardOutputProcess(ppm2pwg); diff --git a/src/convertworker.h b/src/convertworker.h index 6454840..70dc236 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -9,7 +9,7 @@ class ConvertWorker : public QObject public slots: void convertPdf(QNetworkRequest request, QString filename, - bool apple, QTemporaryFile* tempfile); + bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile); //convertImage(); signals: diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index a02b669..51ab74f 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -291,6 +291,20 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ } } + quint32 HwResX = 300; + quint32 HwResY = 300; + + if(attrs.contains("printer-resolution")) { + // TODO: check that units == 3, aka dpi + HwResX = attrs["printer-resolution"].toObject()["value"].toObject()["x"].toInt(); + HwResY = attrs["printer-resolution"].toObject()["value"].toObject()["y"].toInt(); + } + else + { + HwResX = _attrs["printer-resolution-default"].toObject()["value"].toObject()["x"].toInt(); + HwResY = _attrs["printer-resolution-default"].toObject()["value"].toObject()["y"].toInt(); + } + if(from == Pdf && target != NoConvert) { file.close(); @@ -300,7 +314,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << tempfile->fileName(); tempfile->close(); - emit doConvertPdf(request, filename, target==UrfConvert, tempfile); + emit doConvertPdf(request, filename, target==UrfConvert, HwResX, HwResY, tempfile); } else { diff --git a/src/ippprinter.h b/src/ippprinter.h index 4d3f55c..f36f848 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -51,7 +51,7 @@ signals: void jobFinished(bool status); void cancelStatus(bool status); - void doConvertPdf(QNetworkRequest request, QString filename, bool urf, QTemporaryFile* tempfile); + void doConvertPdf(QNetworkRequest request, QString filename, bool urf, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile); public slots: void print(QJsonObject attrs, QString file); From c1570bcb1b401097a8315ed9a2eec1ada4d60535 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Wed, 6 May 2020 20:46:41 +0200 Subject: [PATCH 38/94] Add a status page for convert/transfer --- harbour-seaprint.pro | 1 + qml/pages/BusyPage.qml | 32 ++++++++++++++++++++++++++ qml/pages/PrinterPage.qml | 22 +----------------- src/convertworker.cpp | 2 +- src/ippprinter.cpp | 12 ++++++++++ src/ippprinter.h | 6 +++++ translations/harbour-seaprint-de.ts | 19 ++++++++------- translations/harbour-seaprint-es.ts | 19 ++++++++------- translations/harbour-seaprint-fr.ts | 19 ++++++++------- translations/harbour-seaprint-zh_CN.ts | 19 ++++++++------- translations/harbour-seaprint.ts | 19 ++++++++------- 11 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 qml/pages/BusyPage.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index c8fa873..c6168aa 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -36,6 +36,7 @@ DISTFILES += qml/harbour-seaprint.qml \ qml/pages/*.qml \ qml/pages/*.js \ qml/pages/*svg \ + qml/pages/BusyPage.qml \ qml/pages/DebugPage.qml \ rpm/harbour-seaprint.changes.in \ rpm/harbour-seaprint.changes.run.in \ diff --git a/qml/pages/BusyPage.qml b/qml/pages/BusyPage.qml new file mode 100644 index 0000000..ed1d7cd --- /dev/null +++ b/qml/pages/BusyPage.qml @@ -0,0 +1,32 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "utils.js" as Utils + +Page { + property var printer + backNavigation: false + Connections { + target: printer + onJobFinished: { + var msg = "" + if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") { + msg = printer.jobAttrs["job-state-message"].value + } + else if (printer.jobAttrs.hasOwnProperty("job-state")) { + msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value) + } + if(status == true) { + notifier.notify(qsTr("Print success: ") + msg) + pageStack.pop() //or replace? + } + else { + notifier.notify(qsTr("Print failed: ") + msg) + } + } + } + + BusyLabel { + text: printer.busyMessage + running: true + } +} diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index f0b1692..b888f5d 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -12,26 +12,6 @@ Page { console.log(JSON.stringify(printer.attrs)) } - Connections { - target: printer - onJobFinished: { - var msg = "" - if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") { - msg = printer.jobAttrs["job-state-message"].value - } - else if (printer.jobAttrs.hasOwnProperty("job-state")) { - msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value) - } - if(status == true) { - notifier.notify(qsTr("Print success: ") + msg) - pageStack.pop() //or replace? - } - else { - notifier.notify(qsTr("Print failed: ") + msg) - } - } - } - // To enable PullDownMenu, place our content in a SilicaFlickable SilicaFlickable { anchors.fill: parent @@ -42,8 +22,8 @@ Page { text: qsTr("Print") onClicked: { console.log(JSON.stringify(jobParams)) + pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}) printer.print(jobParams, page.selectedFile) - } } } diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 27b81cc..b173779 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -14,7 +14,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QProcess* ppm2pwg = new QProcess(this); - // Yo dwag, I heard you like programs... + // Yo dawg, I heard you like programs... ppm2pwg->setProgram("harbour-seaprint"); ppm2pwg->setArguments({"ppm2pwg"}); QStringList env = {"HWRES_X="+HwResX_s, "HWRES_Y="+HwResY_s}; diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 51ab74f..d11346d 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -212,6 +212,9 @@ void IppPrinter::convertDone(QNetworkRequest request, QTemporaryFile* data) { connect(_print_nam, SIGNAL(finished(QNetworkReply*)), data, SLOT(deleteLater())); data->open(); + + setBusyMessage("Transferring"); + _print_nam->post(request, data); } @@ -314,6 +317,8 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << tempfile->fileName(); tempfile->close(); + setBusyMessage("Converting"); + emit doConvertPdf(request, filename, target==UrfConvert, HwResX, HwResY, tempfile); } else @@ -322,6 +327,8 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ contents = contents.append(filedata); file.close(); + setBusyMessage("Transferring"); + _print_nam->post(request, contents); } @@ -381,3 +388,8 @@ QUrl IppPrinter::httpUrl() { return url; } +void IppPrinter::setBusyMessage(QString msg) +{ + _busyMessage = msg; + emit busyMessageChanged(); +} diff --git a/src/ippprinter.h b/src/ippprinter.h index f36f848..e87ccd3 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -13,6 +13,7 @@ class IppPrinter : public QObject Q_PROPERTY(QJsonObject attrs MEMBER _attrs NOTIFY attrsChanged) Q_PROPERTY(QJsonObject jobAttrs MEMBER _jobAttrs NOTIFY jobAttrsChanged) Q_PROPERTY(QJsonArray jobs MEMBER _jobs NOTIFY jobsChanged) + Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged) public: @@ -53,6 +54,8 @@ signals: void doConvertPdf(QNetworkRequest request, QString filename, bool urf, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile); + void busyMessageChanged(); + public slots: void print(QJsonObject attrs, QString file); @@ -74,6 +77,8 @@ private: QJsonObject opAttrs(); + void setBusyMessage(QString msg); + QNetworkAccessManager* _nam; QNetworkAccessManager* _jobs_nam; QNetworkAccessManager* _job_cancel_nam; @@ -82,6 +87,7 @@ private: QJsonObject _attrs; QJsonObject _jobAttrs; QJsonArray _jobs; + QString _busyMessage; QThread _workerThread; ConvertWorker* _worker; diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 98d5b06..9c65b40 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -87,6 +87,17 @@ + + BusyPage + + Print success: + + + + Print failed: + + + CoverPage @@ -198,14 +209,6 @@ Resolution - - Print success: - - - - Print failed: - - utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index ee45ead..9548188 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -87,6 +87,17 @@ Desconocida + + BusyPage + + Print success: + Impresión correcta: + + + Print failed: + Impresión fallida: + + CoverPage @@ -198,14 +209,6 @@ Resolution Resolución - - Print success: - Impresión correcta: - - - Print failed: - Impresión fallida: - utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 714c3e1..17965e9 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -87,6 +87,17 @@ Inconnu + + BusyPage + + Print success: + Impression réussie : + + + Print failed: + Échec de l'impression : + + CoverPage @@ -198,14 +209,6 @@ Resolution Résolution - - Print success: - Impression réussie : - - - Print failed: - Échec de l'impression : - utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 5909123..1ab0d5e 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -87,6 +87,17 @@ 未知 + + BusyPage + + Print success: + 打印成功: + + + Print failed: + 打印失败: + + CoverPage @@ -198,14 +209,6 @@ Resolution 分辨率 - - Print success: - 打印成功: - - - Print failed: - 打印失败: - utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 4a02c1b..819ef1a 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -87,6 +87,17 @@ + + BusyPage + + Print success: + + + + Print failed: + + + CoverPage @@ -198,14 +209,6 @@ Resolution - - Print success: - - - - Print failed: - - utils From 323b5715e62c91cce4a3c4d8080426cc0c2f5058 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 8 May 2020 20:35:32 +0200 Subject: [PATCH 39/94] Update ppm2pwg, for better performance --- ppm2pwg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppm2pwg b/ppm2pwg index ec851c5..5a0e3b8 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit ec851c5286fecfdded0bdf76453362a1829cc5c8 +Subproject commit 5a0e3b86088ebe4e30fbd76eef70a20bc42048be From dd75832e8a5370c226639eb17a3f597bc595afe3 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 9 May 2020 14:05:34 +0200 Subject: [PATCH 40/94] Pop BusyPage on errors too --- qml/pages/BusyPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qml/pages/BusyPage.qml b/qml/pages/BusyPage.qml index ed1d7cd..3a32f14 100644 --- a/qml/pages/BusyPage.qml +++ b/qml/pages/BusyPage.qml @@ -15,9 +15,9 @@ Page { else if (printer.jobAttrs.hasOwnProperty("job-state")) { msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value) } + pageStack.pop() if(status == true) { notifier.notify(qsTr("Print success: ") + msg) - pageStack.pop() //or replace? } else { notifier.notify(qsTr("Print failed: ") + msg) From e898d15435a538db49d4f1fa07fcb653475ef55e Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 9 May 2020 14:24:51 +0200 Subject: [PATCH 41/94] Improve format logic --- qml/pages/FirstPage.qml | 12 +++++++----- qml/pages/utils.js | 9 ++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index dcb76f4..9d14cdc 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -137,6 +137,8 @@ Page { property int debugCount: 0 onClicked: { + console.log(Utils.supported_formats(printer).mimetypes, selectedFileType, Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1) + if(++debugCount == 5) { pageStack.push(Qt.resolvedUrl("DebugPage.qml"), {printer: printer}) @@ -182,20 +184,20 @@ Page { Label { id: name_label - color: canPrint ? Theme.primaryColor : Theme.secondaryColor + color: canPrint || selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor text: name } Label { id: mm_label - color: canPrint ? Theme.primaryColor : Theme.secondaryColor + color: canPrint || selectedFile == "" ? Theme.primaryColor : Theme.secondaryColor font.pixelSize: Theme.fontSizeExtraSmall text: printer.attrs["printer-make-and-model"].value } Label { id: uri_label - color: canPrint ? Theme.highlightColor : Theme.secondaryColor + color: canPrint || selectedFile == "" ? Theme.highlightColor : Theme.secondaryColor font.pixelSize: Theme.fontSizeTiny text: printer.url } @@ -211,13 +213,13 @@ Page { } Label { id: format_label - color: canPrint ? Theme.primaryColor : "red" + color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red" font.pixelSize: Theme.fontSizeExtraSmall text: Utils.supported_formats(printer).supported } Label { id: maybe_format_label - color: canPrint ? Theme.secondaryColor : "red" + color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.secondaryColor : "red" font.pixelSize: Theme.fontSizeExtraSmall font.italic: true text: Utils.supported_formats(printer).maybe diff --git a/qml/pages/utils.js b/qml/pages/utils.js index aed7d4a..485ae89 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -3,7 +3,7 @@ function supported_formats(printer) var formats = printer.attrs["document-format-supported"].value; var mimetypes = []; var supported = []; - if(has(formats, "application/pdf") || as(formats, "application/pwg-raster") || has(formats, "application/urf") ) + if(has(formats, "application/pdf") || has(formats, "image/pwg-raster") || has(formats, "image/urf") ) { mimetypes.push("application/pdf"); supported.push("PDF"); @@ -46,12 +46,7 @@ function supported_formats(printer) function has(arrayish, what) { - for(var i in arrayish) - { - if(arrayish[i] == what) - return true - } - return false + return arrayish.indexOf(what) != -1; } function ippName(name, value) From 2e02ad0bcffe726cf0e95b4c1177bd183e549c6d Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 9 May 2020 16:31:16 +0200 Subject: [PATCH 42/94] Update ppm2pwg --- ppm2pwg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppm2pwg b/ppm2pwg index 5a0e3b8..66939c8 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit 5a0e3b86088ebe4e30fbd76eef70a20bc42048be +Subproject commit 66939c8a9812d399f57753a14b8e96be68346281 From aa6daa1d77172516538318d1a00062668ee6fd0e Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 9 May 2020 20:39:50 +0200 Subject: [PATCH 43/94] Connect print job settings to ppm2pwg env --- src/convertworker.cpp | 53 +++++++++++++++++++++++++++++++++++-------- src/convertworker.h | 5 ++-- src/ippprinter.cpp | 47 +++++++++++++++++++++++++++----------- src/ippprinter.h | 5 +++- 4 files changed, 84 insertions(+), 26 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index b173779..b876454 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -1,28 +1,61 @@ #include "convertworker.h" #include -void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, - bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile) +void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { + env.append("HWRES_X="+QString::number(HwResX)); + env.append("HWRES_Y="+QString::number(HwResY)); - QString HwResX_s = QString::number(HwResX); - QString HwResY_s = QString::number(HwResY); + if(urf) + { + env.append("URF=true"); + } + + if(Quality >= 3 && Quality <= 5) + { + env.append("QUALITY="+QString::number(Quality)); + } + + env.append("DUPLEX="+QString::number(TwoSided)); + env.append("TUMBLE="+QString::number(Tumble)); + +} + +void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + bool urf, quint32 Colors, quint32 Quality, + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) +{ + if(urf) + { // URF only supports symmetric resolutions + if(HwResX < HwResY) + { + HwResY = HwResX; + } + else { + HwResX = HwResY; + } + } QProcess* pdftoppm = new QProcess(this); pdftoppm->setProgram("pdftoppm"); - pdftoppm->setArguments({"-gray", "-rx", HwResX_s, "-ry", HwResY_s, filename}); + QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)}; + if(Colors != 3) + { + Pdf2PpmArgs.append("-gray"); + } + Pdf2PpmArgs.append(filename); + pdftoppm->setArguments(Pdf2PpmArgs); QProcess* ppm2pwg = new QProcess(this); // Yo dawg, I heard you like programs... ppm2pwg->setProgram("harbour-seaprint"); ppm2pwg->setArguments({"ppm2pwg"}); - QStringList env = {"HWRES_X="+HwResX_s, "HWRES_Y="+HwResY_s}; - if(apple) - { - env.append("URF=true"); - } + QStringList env; + ppm2PwgEnv(env, urf, Quality, HwResX, HwResY, TwoSided, Tumble); + qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); diff --git a/src/convertworker.h b/src/convertworker.h index 70dc236..a500237 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -8,8 +8,9 @@ class ConvertWorker : public QObject Q_OBJECT public slots: - void convertPdf(QNetworkRequest request, QString filename, - bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile); + void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + bool urf, quint32 Colors, quint32 Quality, + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); //convertImage(); signals: diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index d11346d..06b233e 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -294,23 +294,32 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ } } - quint32 HwResX = 300; - quint32 HwResY = 300; + QJsonValue PrinterResolutionRef = getAttrOrDefault(attrs, "printer-resolution"); + quint32 HwResX = PrinterResolutionRef.toObject()["x"].toInt(); + quint32 HwResY = PrinterResolutionRef.toObject()["y"].toInt(); - if(attrs.contains("printer-resolution")) { - // TODO: check that units == 3, aka dpi - HwResX = attrs["printer-resolution"].toObject()["value"].toObject()["x"].toInt(); - HwResY = attrs["printer-resolution"].toObject()["value"].toObject()["y"].toInt(); - } - else - { - HwResX = _attrs["printer-resolution-default"].toObject()["value"].toObject()["x"].toInt(); - HwResY = _attrs["printer-resolution-default"].toObject()["value"].toObject()["y"].toInt(); - } + quint32 Quality = getAttrOrDefault(attrs, "print-quality").toInt(); + + QString PrintColorMode = getAttrOrDefault(attrs, "print-color-mode").toString(); + quint32 Colors = PrintColorMode=="color" ? 3 : PrintColorMode=="monochrome" ? 1 : 0; if(from == Pdf && target != NoConvert) { file.close(); + + QString Sides = getAttrOrDefault(attrs, "sides").toString(); + bool TwoSided = false; + bool Tumble = false; + if(Sides=="two-sided-long-edge") + { + TwoSided = true; + } + else if(Sides=="two-sided-short-edge") + { + TwoSided = true; + Tumble = true; + } + QTemporaryFile* tempfile = new QTemporaryFile(); tempfile->open(); tempfile->write(contents); @@ -319,7 +328,8 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ setBusyMessage("Converting"); - emit doConvertPdf(request, filename, target==UrfConvert, HwResX, HwResY, tempfile); + emit doConvertPdf(request, filename, tempfile, target==UrfConvert, Colors, Quality, + HwResX, HwResY, TwoSided, Tumble); } else { @@ -393,3 +403,14 @@ void IppPrinter::setBusyMessage(QString msg) _busyMessage = msg; emit busyMessageChanged(); } + +QJsonValue IppPrinter::getAttrOrDefault(QJsonObject jobAttrs, QString name) +{ + if(jobAttrs.contains(name)) + { + return jobAttrs[name].toObject()["value"]; + } + else { + return _attrs[name+"-default"].toObject()["value"]; + } +} diff --git a/src/ippprinter.h b/src/ippprinter.h index e87ccd3..93b4e01 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -52,7 +52,9 @@ signals: void jobFinished(bool status); void cancelStatus(bool status); - void doConvertPdf(QNetworkRequest request, QString filename, bool urf, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile); + void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + bool urf, quint32 Colors, quint32 Quality, + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); void busyMessageChanged(); @@ -78,6 +80,7 @@ private: QJsonObject opAttrs(); void setBusyMessage(QString msg); + QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name); QNetworkAccessManager* _nam; QNetworkAccessManager* _jobs_nam; From 16e6d8d7666b6890617d8aa092fdeb64ffb93fc8 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 11 May 2020 20:44:53 +0200 Subject: [PATCH 44/94] Add ConvertChecker --- harbour-seaprint.pro | 2 ++ qml/pages/AboutPage.qml | 11 ++++++- qml/pages/FirstPage.qml | 11 ++++--- qml/pages/utils.js | 4 +-- src/convertchecker.cpp | 40 ++++++++++++++++++++++++++ src/convertchecker.h | 26 +++++++++++++++++ src/harbour-seaprint.cpp | 2 ++ translations/harbour-seaprint-de.ts | 20 +++++++++++++ translations/harbour-seaprint-es.ts | 20 +++++++++++++ translations/harbour-seaprint-fr.ts | 20 +++++++++++++ translations/harbour-seaprint-zh_CN.ts | 20 +++++++++++++ translations/harbour-seaprint.ts | 20 +++++++++++++ 12 files changed, 189 insertions(+), 7 deletions(-) create mode 100644 src/convertchecker.cpp create mode 100644 src/convertchecker.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index c6168aa..cda5bbe 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -22,6 +22,7 @@ VERSION_H = \ write_file($$$$OUT_PWD/seaprint_version.h, VERSION_H) SOURCES += src/harbour-seaprint.cpp \ + src/convertchecker.cpp \ src/convertworker.cpp \ src/ippdiscovery.cpp \ src/ippmsg.cpp \ @@ -61,6 +62,7 @@ TRANSLATIONS += translations/harbour-seaprint-de.ts \ translations/harbour-seaprint-es.ts HEADERS += \ + src/convertchecker.h \ src/convertworker.h \ src/ippdiscovery.h \ src/ippmsg.h \ diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index 2a09416..8b86a12 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import seaprint.convertchecker 1.0 import "../components" Page { @@ -90,7 +91,15 @@ Page { font.pixelSize: Theme.fontSizeSmall text: qsTr("Chinese")+" - dashinfantry\n"+ qsTr("French")+" - ensag-dev, Quentí\n"+ - qsTr("Spanish")+" - carmenfdezb" + qsTr("Spanish")+" - carmenfdezb\n"+ + qsTr("Polish")+" - atlochowski" + } + + SectionHeader { text: qsTr("Optional dependencies") } + + AboutLabel { + font.pixelSize: Theme.fontSizeSmall + text: qsTr("pdftoppm (from poppler-utils)")+" - "+(ConvertChecker.pdf ? qsTr("Installed") : qsTr("Not installed")) } SectionHeader { text: qsTr("Licensing") } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 9d14cdc..cc58ec5 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import Sailfish.Pickers 1.0 import seaprint.ippdiscovery 1.0 +import seaprint.convertchecker 1.0 import seaprint.ippprinter 1.0 import seaprint.mimer 1.0 import "utils.js" as Utils @@ -45,6 +46,7 @@ Page { signal refreshed() Component.onCompleted: { + console.log("Can convert from PDF:", ConvertChecker.pdf) IppDiscovery.discover(); if(selectedFile != "") { @@ -100,7 +102,7 @@ Page { visible: false property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown") - property bool canPrint: Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1 + property bool canPrint: Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1 Connections { target: printer @@ -137,7 +139,8 @@ Page { property int debugCount: 0 onClicked: { - console.log(Utils.supported_formats(printer).mimetypes, selectedFileType, Utils.supported_formats(printer).mimetypes.indexOf(selectedFileType) != -1) + console.log(Utils.supported_formats(printer, ConvertChecker).mimetypes, selectedFileType, + Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1) if(++debugCount == 5) { @@ -215,14 +218,14 @@ Page { id: format_label color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red" font.pixelSize: Theme.fontSizeExtraSmall - text: Utils.supported_formats(printer).supported + text: Utils.supported_formats(printer, ConvertChecker).supported } Label { id: maybe_format_label color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.secondaryColor : "red" font.pixelSize: Theme.fontSizeExtraSmall font.italic: true - text: Utils.supported_formats(printer).maybe + text: Utils.supported_formats(printer, ConvertChecker).maybe } } diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 485ae89..17a0f79 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,9 +1,9 @@ -function supported_formats(printer) +function supported_formats(printer, ConvertChecker) { var formats = printer.attrs["document-format-supported"].value; var mimetypes = []; var supported = []; - if(has(formats, "application/pdf") || has(formats, "image/pwg-raster") || has(formats, "image/urf") ) + if(has(formats, "application/pdf") || (ConvertChecker.pdf && ( has(formats, "image/pwg-raster") || has(formats, "image/urf"))) ) { mimetypes.push("application/pdf"); supported.push("PDF"); diff --git a/src/convertchecker.cpp b/src/convertchecker.cpp new file mode 100644 index 0000000..7a8de48 --- /dev/null +++ b/src/convertchecker.cpp @@ -0,0 +1,40 @@ +#include "convertchecker.h" +#include + +ConvertChecker::ConvertChecker() +{ + _pdf = false; + QProcess* pdftoppm = new QProcess(this); + pdftoppm->setProgram("pdftoppm"); + pdftoppm->setArguments({"-h"}); + pdftoppm->start(); + if(pdftoppm->waitForFinished(2000)) + { + if(pdftoppm->exitStatus() == QProcess::NormalExit && pdftoppm->exitCode() == 0) + { + _pdf = true; + } + } +} + +ConvertChecker::~ConvertChecker() { + +} + +ConvertChecker* ConvertChecker::m_Instance = 0; + +ConvertChecker* ConvertChecker::instance() +{ + static QMutex mutex; + if (!m_Instance) + { + mutex.lock(); + + if (!m_Instance) + m_Instance = new ConvertChecker; + + mutex.unlock(); + } + + return m_Instance; +} diff --git a/src/convertchecker.h b/src/convertchecker.h new file mode 100644 index 0000000..986aebb --- /dev/null +++ b/src/convertchecker.h @@ -0,0 +1,26 @@ +#ifndef CONVERTCHECKER_H +#define CONVERTCHECKER_H +#include +#include + +class ConvertChecker : public QObject +{ + Q_OBJECT +public: + static ConvertChecker* instance(); + Q_PROPERTY(bool pdf MEMBER _pdf) + +signals: +protected: +private: + static ConvertChecker* m_Instance; + + ConvertChecker(); + ~ConvertChecker(); + ConvertChecker(const ConvertChecker &); + ConvertChecker& operator=(const ConvertChecker &); + + bool _pdf; +}; + +#endif // CONVERTCHECKER_H diff --git a/src/harbour-seaprint.cpp b/src/harbour-seaprint.cpp index 2d4b1e5..5b2252c 100644 --- a/src/harbour-seaprint.cpp +++ b/src/harbour-seaprint.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #define PPM2PWG_MAIN ppm2pwg_main #include @@ -34,6 +35,7 @@ int main(int argc, char *argv[]) qmlRegisterSingletonType("seaprint.ippdiscovery", 1, 0, "IppDiscovery", singletontype_provider); qmlRegisterSingletonType("seaprint.mimer", 1, 0, "Mimer", singletontype_provider); + qmlRegisterSingletonType("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider); qmlRegisterType("seaprint.ippprinter", 1, 0, "IppPrinter"); QQuickView* view = SailfishApp::createView(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 9c65b40..adccea9 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -63,6 +63,26 @@ Spanish + + Polish + + + + Optional dependencies + + + + pdftoppm (from poppler-utils) + + + + Installed + + + + Not installed + + AddPrinterDialog diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 9548188..de6bc41 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -63,6 +63,26 @@ Spanish Español + + Polish + + + + Optional dependencies + + + + pdftoppm (from poppler-utils) + + + + Installed + + + + Not installed + + AddPrinterDialog diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 17965e9..5cd01b3 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -63,6 +63,26 @@ Spanish Espagnol + + Polish + + + + Optional dependencies + + + + pdftoppm (from poppler-utils) + + + + Installed + + + + Not installed + + AddPrinterDialog diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 1ab0d5e..9770587 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -63,6 +63,26 @@ Spanish 西班牙语 + + Polish + + + + Optional dependencies + + + + pdftoppm (from poppler-utils) + + + + Installed + + + + Not installed + + AddPrinterDialog diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 819ef1a..ce589df 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -63,6 +63,26 @@ Spanish + + Polish + + + + Optional dependencies + + + + pdftoppm (from poppler-utils) + + + + Installed + + + + Not installed + + AddPrinterDialog From f7aba42af2d0d89eb9f1d5c3d29d3d30cadbed04 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Wed, 13 May 2020 19:53:44 +0200 Subject: [PATCH 45/94] Add image-to-raster conversions --- src/convertworker.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++ src/convertworker.h | 4 ++- src/ippprinter.cpp | 45 ++++++++++++++++------------ src/ippprinter.h | 3 ++ 4 files changed, 101 insertions(+), 19 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index b876454..c814b2d 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -97,3 +97,71 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo emit done(request, tempfile); qDebug() << "posted"; } + +void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY) +{ + quint32 Width = 210.0/25.4*HwResX; + quint32 Height = 297.0/25.4*HwResY; + + QImage inImage; + if(!inImage.load(filename)) + { + qDebug() << "failed to load"; + emit failed(); + return; + } + + if(inImage.width() > inImage.height()) + { + inImage = inImage.transformed(QMatrix().rotate(90.0)); + } + inImage = inImage.scaled(Width, Height, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QImage outImage = QImage(Width, Height, inImage.format()); + outImage.fill(Qt::white); + QPainter painter(&outImage); + painter.drawImage(0,0, inImage); + painter.end(); + + QTemporaryFile tmpImage; + tmpImage.open(); + qDebug() << "Raw image: " << tmpImage.fileName(); + outImage.save(tmpImage.fileName(), Colors == 1 ? "pgm" : "ppm"); + tmpImage.close(); + + QProcess* ppm2pwg = new QProcess(this); + // Yo dawg, I heard you like programs... + ppm2pwg->setProgram("harbour-seaprint"); + ppm2pwg->setArguments({"ppm2pwg"}); + + QStringList env; + ppm2PwgEnv(env, urf, Quality, HwResX, HwResY, false, false); + qDebug() << "ppm2pwg env is " << env; + + ppm2pwg->setEnvironment(env); + ppm2pwg->setStandardInputFile(tmpImage.fileName()); + ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); + + qDebug() << "All connected"; + ppm2pwg->start(); + + qDebug() << "Starting"; + + if(!ppm2pwg->waitForStarted()) + { + qDebug() << "ppm2pwg died"; + tempfile->deleteLater(); + emit failed(); + return; + } + qDebug() << "All started"; + + ppm2pwg->waitForFinished(); + + qDebug() << "Finished"; + + emit done(request, tempfile); + qDebug() << "posted"; +} diff --git a/src/convertworker.h b/src/convertworker.h index a500237..0246efd 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -11,7 +11,9 @@ public slots: void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); - //convertImage(); + + void convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY); signals: void done(QNetworkRequest request, QTemporaryFile* data); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 06b233e..d9ba839 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -30,6 +30,7 @@ IppPrinter::IppPrinter() connect(&_workerThread, &QThread::finished, _worker, &QObject::deleteLater); connect(this, &IppPrinter::doConvertPdf, _worker, &ConvertWorker::convertPdf); + connect(this, &IppPrinter::doConvertImage, _worker, &ConvertWorker::convertImage); connect(_worker, &ConvertWorker::done, this, &IppPrinter::convertDone); connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed); @@ -275,14 +276,14 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ from = Pdf; } else if (mimeType.contains("image")) { -// from = Image; TODO: handle image conversions + from = Image; } QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/) + if(from == Image || (from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/)) { if(supportedMimeTypes.contains("image/pwg-raster")) { @@ -303,23 +304,10 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ QString PrintColorMode = getAttrOrDefault(attrs, "print-color-mode").toString(); quint32 Colors = PrintColorMode=="color" ? 3 : PrintColorMode=="monochrome" ? 1 : 0; - if(from == Pdf && target != NoConvert) + if(target != NoConvert) { file.close(); - QString Sides = getAttrOrDefault(attrs, "sides").toString(); - bool TwoSided = false; - bool Tumble = false; - if(Sides=="two-sided-long-edge") - { - TwoSided = true; - } - else if(Sides=="two-sided-short-edge") - { - TwoSided = true; - Tumble = true; - } - QTemporaryFile* tempfile = new QTemporaryFile(); tempfile->open(); tempfile->write(contents); @@ -328,8 +316,29 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ setBusyMessage("Converting"); - emit doConvertPdf(request, filename, tempfile, target==UrfConvert, Colors, Quality, - HwResX, HwResY, TwoSided, Tumble); + if(from == Pdf ) + { + + QString Sides = getAttrOrDefault(attrs, "sides").toString(); + bool TwoSided = false; + bool Tumble = false; + if(Sides=="two-sided-long-edge") + { + TwoSided = true; + } + else if(Sides=="two-sided-short-edge") + { + TwoSided = true; + Tumble = true; + } + + emit doConvertPdf(request, filename, tempfile, target==UrfConvert, Colors, Quality, + HwResX, HwResY, TwoSided, Tumble); + } + else if (from == Image) + { + emit doConvertImage(request, filename, tempfile, target==UrfConvert, Colors, Quality, HwResX, HwResY); + } } else { diff --git a/src/ippprinter.h b/src/ippprinter.h index 93b4e01..5b64d4a 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -56,6 +56,9 @@ signals: bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); + void doConvertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, bool urf, + quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY); + void busyMessageChanged(); public slots: From ef9b222c3527c81d3bdc85ce127a184108900485 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Wed, 13 May 2020 20:18:20 +0200 Subject: [PATCH 46/94] vertically center images --- src/convertworker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index c814b2d..be11f88 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -120,7 +120,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem QImage outImage = QImage(Width, Height, inImage.format()); outImage.fill(Qt::white); QPainter painter(&outImage); - painter.drawImage(0,0, inImage); + painter.drawImage(0, (outImage.height()-inImage.height())/2, inImage); painter.end(); QTemporaryFile tmpImage; From 8c2274065150c91c331ff5b9aed2ce6417dd5cc1 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 14 May 2020 21:00:37 +0200 Subject: [PATCH 47/94] Enable translation of error messages from C++ --- src/convertworker.cpp | 8 ++++---- src/convertworker.h | 2 +- src/ippprinter.cpp | 7 +++---- src/ippprinter.h | 2 +- translations/harbour-seaprint-de.ts | 18 ++++++++++++++++++ translations/harbour-seaprint-es.ts | 18 ++++++++++++++++++ translations/harbour-seaprint-fr.ts | 18 ++++++++++++++++++ translations/harbour-seaprint-zh_CN.ts | 18 ++++++++++++++++++ translations/harbour-seaprint.ts | 18 ++++++++++++++++++ 9 files changed, 99 insertions(+), 10 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index be11f88..de6aa9c 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -78,14 +78,14 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo { qDebug() << "pdftoppm died"; tempfile->deleteLater(); - emit failed(); + emit failed(tr("Conversion error")); return; } if(!ppm2pwg->waitForStarted()) { qDebug() << "ppm2pwg died"; tempfile->deleteLater(); - emit failed(); + emit failed(tr("Conversion error")); return; } qDebug() << "All started"; @@ -108,7 +108,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem if(!inImage.load(filename)) { qDebug() << "failed to load"; - emit failed(); + emit failed(tr("Failed to load image")); return; } @@ -153,7 +153,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem { qDebug() << "ppm2pwg died"; tempfile->deleteLater(); - emit failed(); + emit failed(tr("Conversion error")); return; } qDebug() << "All started"; diff --git a/src/convertworker.h b/src/convertworker.h index 0246efd..ec8cdc3 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -17,7 +17,7 @@ public slots: signals: void done(QNetworkRequest request, QTemporaryFile* data); - void failed(); + void failed(QString message); }; #endif // CONVERTWORKER_H diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index d9ba839..d88bb09 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -97,7 +97,6 @@ void IppPrinter::refresh() { QNetworkRequest request; request.setUrl(httpUrl()); -// request.setRawHeader("User-Agent", "MyOwnBrowser 1.0"); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); @@ -220,10 +219,10 @@ void IppPrinter::convertDone(QNetworkRequest request, QTemporaryFile* data) } -void IppPrinter::convertFailed() +void IppPrinter::convertFailed(QString message) { _jobAttrs = QJsonObject(); - _jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Internal error"}}); + _jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", message}}); emit jobAttrsChanged(); emit jobFinished(false); } @@ -235,7 +234,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ bool file_ok = file.open(QIODevice::ReadOnly); if(!file_ok) { - emit jobFinished(false); + emit convertFailed(tr("Failed to open file")); return; } diff --git a/src/ippprinter.h b/src/ippprinter.h index 5b64d4a..b154e43 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -74,7 +74,7 @@ public slots: void ignoreKnownSslErrors(QNetworkReply *reply, const QList &errors); void convertDone(QNetworkRequest request, QTemporaryFile* data); - void convertFailed(); + void convertFailed(QString message); private: QUrl _url; diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index adccea9..a6ae0fb 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -118,6 +118,17 @@ + + ConvertWorker + + Conversion error + + + + Failed to load image + + + CoverPage @@ -172,6 +183,13 @@ + + IppPrinter + + Failed to open file + + + JobsPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index de6bc41..2efd2b2 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -118,6 +118,17 @@ Impresión fallida: + + ConvertWorker + + Conversion error + + + + Failed to load image + + + CoverPage @@ -172,6 +183,13 @@ Elegir archivo + + IppPrinter + + Failed to open file + + + JobsPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 5cd01b3..a3c24e7 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -118,6 +118,17 @@ Échec de l'impression : + + ConvertWorker + + Conversion error + + + + Failed to load image + + + CoverPage @@ -172,6 +183,13 @@ Choisir un fichier + + IppPrinter + + Failed to open file + + + JobsPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 9770587..b9d1038 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -118,6 +118,17 @@ 打印失败: + + ConvertWorker + + Conversion error + + + + Failed to load image + + + CoverPage @@ -172,6 +183,13 @@ 选择文件 + + IppPrinter + + Failed to open file + + + JobsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index ce589df..8af979a 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -118,6 +118,17 @@ + + ConvertWorker + + Conversion error + + + + Failed to load image + + + CoverPage @@ -172,6 +183,13 @@ + + IppPrinter + + Failed to open file + + + JobsPage From 04c46612c9e6d1f518d72faebac2191f3d6e2784 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 14 May 2020 21:05:23 +0200 Subject: [PATCH 48/94] Enable transparent sending of PDFs (was just disabled for experimenting with conversions) --- qml/pages/PrinterPage.qml | 3 ++- src/ippprinter.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index b888f5d..0161247 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -22,7 +22,8 @@ Page { text: qsTr("Print") onClicked: { console.log(JSON.stringify(jobParams)) - pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}) + pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, + PageStackAction.Immediate) printer.print(jobParams, page.selectedFile) } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index d88bb09..a0932a9 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -282,7 +282,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(from == Image || (from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/)) + if(from == Image || (from == Pdf && !supportedMimeTypes.contains("application/pdf"))) { if(supportedMimeTypes.contains("image/pwg-raster")) { From bd710831eb026cd3cca63e02ef0673dfacc20cae Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 15:17:42 +0200 Subject: [PATCH 49/94] Add paper sizes --- harbour-seaprint.pro | 3 +- qml/pages/PrinterPage.qml | 2 +- src/convertworker.cpp | 73 +++++++-- src/convertworker.h | 5 +- src/ippprinter.cpp | 15 +- src/ippprinter.h | 5 +- src/papersizes.h | 209 +++++++++++++++++++++++++ translations/harbour-seaprint-de.ts | 16 ++ translations/harbour-seaprint-es.ts | 16 ++ translations/harbour-seaprint-fr.ts | 16 ++ translations/harbour-seaprint-zh_CN.ts | 16 ++ translations/harbour-seaprint.ts | 16 ++ 12 files changed, 373 insertions(+), 19 deletions(-) create mode 100644 src/papersizes.h diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index cda5bbe..588e6ac 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -71,7 +71,8 @@ HEADERS += \ ppm2pwg/pwg_pghdr_codable.h \ ppm2pwg/urf_pghdr_codable.h \ ppm2pwg/bytestream/bytestream.h \ - ppm2pwg/bytestream/codable.h + ppm2pwg/bytestream/codable.h \ + src/papersizes.h INCLUDEPATH += ppm2pwg \ ppm2pwg/bytestream diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 0161247..a8e879b 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -32,7 +32,7 @@ Page { ListModel { id:mod ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} -// ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} + ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} // ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} diff --git a/src/convertworker.cpp b/src/convertworker.cpp index de6aa9c..5390260 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -1,7 +1,8 @@ #include "convertworker.h" #include +#include "papersizes.h" -void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, +void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { env.append("HWRES_X="+QString::number(HwResX)); @@ -17,13 +18,18 @@ void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, env.append("QUALITY="+QString::number(Quality)); } + if(PaperSize != "") + { + env.append("PAGE_SIZE_NAME="+PaperSize); + } + env.append("DUPLEX="+QString::number(TwoSided)); env.append("TUMBLE="+QString::number(Tumble)); } void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, + bool urf, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { if(urf) @@ -37,6 +43,35 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo } } + QString ShortPaperSize; + if(PaperSize == "iso_a4_210x297mm") + { + ShortPaperSize = "A4"; + } + else if (PaperSize == "iso_a3_297x420mm") + { + ShortPaperSize = "A3"; + } + else if (PaperSize == "na_letter_8.5x11in") + { + ShortPaperSize = "letter"; + } + else if (PaperSize == "na_legal_8.5x14in") + { + ShortPaperSize = "legal"; + } + else + { + qDebug() << "Unsupported PDF paper size" << PaperSize; + tempfile->deleteLater(); + emit failed(tr("Unsupported PDF paper size")); + return; + } + + QProcess* pdftocairo = new QProcess(this); + pdftocairo->setProgram("pdftocairo"); + pdftocairo->setArguments({"-pdf", "-paper", ShortPaperSize, filename, "-"}); + QProcess* pdftoppm = new QProcess(this); pdftoppm->setProgram("pdftoppm"); QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)}; @@ -44,7 +79,6 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo { Pdf2PpmArgs.append("-gray"); } - Pdf2PpmArgs.append(filename); pdftoppm->setArguments(Pdf2PpmArgs); @@ -54,26 +88,34 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, HwResX, HwResY, TwoSided, Tumble); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); + pdftocairo->setStandardOutputProcess(pdftoppm); pdftoppm->setStandardOutputProcess(ppm2pwg); ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + connect(pdftocairo, SIGNAL(finished(int, QProcess::ExitStatus)), pdftocairo, SLOT(deleteLater())); connect(pdftoppm, SIGNAL(finished(int, QProcess::ExitStatus)), pdftoppm, SLOT(deleteLater())); connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); qDebug() << "All connected"; - + pdftocairo->start(); pdftoppm->start(); ppm2pwg->start(); qDebug() << "Starting"; - + if(!pdftocairo->waitForStarted()) + { + qDebug() << "pdftocairo died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } if(!pdftoppm->waitForStarted()) { qDebug() << "pdftoppm died"; @@ -99,10 +141,21 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo } void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY) + bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + quint32 HwResX, quint32 HwResY) { - quint32 Width = 210.0/25.4*HwResX; - quint32 Height = 297.0/25.4*HwResY; + if(!PaperSizes.contains(PaperSize)) + { + qDebug() << "Unsupported paper size" << PaperSize; + tempfile->deleteLater(); + emit failed(tr("Unsupported paper size")); + return; + } + QPair wh = PaperSizes[PaperSize]; + quint32 Width = qRound(wh.first/25.4*HwResX); + quint32 Height = qRound(wh.second/25.4*HwResY); + + qDebug() << "Size is" << Width << "x" << Height; QImage inImage; if(!inImage.load(filename)) @@ -135,7 +188,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, HwResX, HwResY, false, false); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); diff --git a/src/convertworker.h b/src/convertworker.h index ec8cdc3..43e124a 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -9,11 +9,12 @@ class ConvertWorker : public QObject public slots: void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, + bool urf, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); void convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY); + bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + quint32 HwResX, quint32 HwResY); signals: void done(QNetworkRequest request, QTemporaryFile* data); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index a0932a9..8a73c19 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -1,6 +1,7 @@ #include "ippprinter.h" #include #include "mimer.h" +#include "papersizes.h" IppPrinter::IppPrinter() { @@ -282,7 +283,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(from == Image || (from == Pdf && !supportedMimeTypes.contains("application/pdf"))) + if(from == Image || (from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/)) { if(supportedMimeTypes.contains("image/pwg-raster")) { @@ -303,6 +304,13 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ QString PrintColorMode = getAttrOrDefault(attrs, "print-color-mode").toString(); quint32 Colors = PrintColorMode=="color" ? 3 : PrintColorMode=="monochrome" ? 1 : 0; + QString PaperSize = getAttrOrDefault(attrs, "media").toString(); + if(!PaperSizes.contains(PaperSize)) + { + emit convertFailed(tr("Unsupported print media")); + return; + } + if(target != NoConvert) { file.close(); @@ -332,11 +340,12 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ } emit doConvertPdf(request, filename, tempfile, target==UrfConvert, Colors, Quality, - HwResX, HwResY, TwoSided, Tumble); + PaperSize, HwResX, HwResY, TwoSided, Tumble); } else if (from == Image) { - emit doConvertImage(request, filename, tempfile, target==UrfConvert, Colors, Quality, HwResX, HwResY); + emit doConvertImage(request, filename, tempfile, target==UrfConvert, Colors, Quality, + PaperSize, HwResX, HwResY); } } else diff --git a/src/ippprinter.h b/src/ippprinter.h index b154e43..01eeb46 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -53,11 +53,12 @@ signals: void cancelStatus(bool status); void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, + bool urf, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); void doConvertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, bool urf, - quint32 Colors, quint32 Quality, quint32 HwResX, quint32 HwResY); + quint32 Colors, quint32 Quality, QString PaperSize, + quint32 HwResX, quint32 HwResY); void busyMessageChanged(); diff --git a/src/papersizes.h b/src/papersizes.h new file mode 100644 index 0000000..d810a82 --- /dev/null +++ b/src/papersizes.h @@ -0,0 +1,209 @@ +#ifndef PAPERSIZES_H +#define PAPERSIZES_H +#include +#include + +static QMap> PaperSizes = + {{"asme_f_28x40in", {71.12, 101.60}}, + {"iso_2a0_1189x1682mm", {1189.00, 1682.00}}, + {"iso_a0_841x1189mm", {841.00, 1189.00}}, + {"iso_a0x3_1189x2523mm", {1189.00, 2523.00}}, + {"iso_a10_26x37mm", {26.00, 37.00}}, + {"iso_a1_594x841mm", {594.00, 841.00}}, + {"iso_a1x3_841x1783mm", {841.00, 1783.00}}, + {"iso_a1x4_841x2378mm", {841.00, 2378.00}}, + {"iso_a2_420x594mm", {420.00, 594.00}}, + {"iso_a2x3_594x1261mm", {594.00, 1261.00}}, + {"iso_a2x4_594x1682mm", {594.00, 1682.00}}, + {"iso_a2x5_594x2102mm", {594.00, 2102.00}}, + {"iso_a3-extra_322x445mm", {322.00, 445.00}}, + {"iso_a3_297x420mm", {297.00, 420.00}}, + {"iso_a3x3_420x891mm", {420.00, 891.00}}, + {"iso_a3x4_420x1189mm", {420.00, 1189.00}}, + {"iso_a3x5_420x1486mm", {420.00, 1486.00}}, + {"iso_a3x6_420x1783mm", {420.00, 1783.00}}, + {"iso_a3x7_420x2080mm", {420.00, 2080.00}}, + {"iso_a4-extra_235.5x322.3mm", {235.50, 322.30}}, + {"iso_a4-tab_225x297mm", {225.00, 297.00}}, + {"iso_a4_210x297mm", {210.00, 297.00}}, + {"iso_a4x3_297x630mm", {297.00, 630.00}}, + {"iso_a4x4_297x841mm", {297.00, 841.00}}, + {"iso_a4x5_297x1051mm", {297.00, 1051.00}}, + {"iso_a4x6_297x1261mm", {297.00, 1261.00}}, + {"iso_a4x7_297x1471mm", {297.00, 1471.00}}, + {"iso_a4x8_297x1682mm", {297.00, 1682.00}}, + {"iso_a4x9_297x1892mm", {297.00, 1892.00}}, + {"iso_a5-extra_174x235mm", {174.00, 235.00}}, + {"iso_a5_148x210mm", {148.00, 210.00}}, + {"iso_a6_105x148mm", {105.00, 148.00}}, + {"iso_a7_74x105mm", {74.00, 105.00}}, + {"iso_a8_52x74mm", {52.00, 74.00}}, + {"iso_a9_37x52mm", {37.00, 52.00}}, + {"iso_b0_1000x1414mm", {1000.00, 1414.00}}, + {"iso_b10_31x44mm", {31.00, 44.00}}, + {"iso_b1_707x1000mm", {707.00, 1000.00}}, + {"iso_b2_500x707mm", {500.00, 707.00}}, + {"iso_b3_353x500mm", {353.00, 500.00}}, + {"iso_b4_250x353mm", {250.00, 353.00}}, + {"iso_b5-extra_201x276mm", {201.00, 276.00}}, + {"iso_b5_176x250mm", {176.00, 250.00}}, + {"iso_b6_125x176mm", {125.00, 176.00}}, + {"iso_b6c4_125x324mm", {125.00, 324.00}}, + {"iso_b7_88x125mm", {88.00, 125.00}}, + {"iso_b8_62x88mm", {62.00, 88.00}}, + {"iso_b9_44x62mm", {44.00, 62.00}}, + {"iso_c0_917x1297mm", {917.00, 1297.00}}, + {"iso_c10_28x40mm", {28.00, 40.00}}, + {"iso_c1_648x917mm", {648.00, 917.00}}, + {"iso_c2_458x648mm", {458.00, 648.00}}, + {"iso_c3_324x458mm", {324.00, 458.00}}, + {"iso_c4_229x324mm", {229.00, 324.00}}, + {"iso_c5_162x229mm", {162.00, 229.00}}, + {"iso_c6_114x162mm", {114.00, 162.00}}, + {"iso_c6c5_114x229mm", {114.00, 229.00}}, + {"iso_c7_81x114mm", {81.00, 114.00}}, + {"iso_c7c6_81x162mm", {81.00, 162.00}}, + {"iso_c8_57x81mm", {57.00, 81.00}}, + {"iso_c9_40x57mm", {40.00, 57.00}}, + {"iso_dl_110x220mm", {110.00, 220.00}}, + {"iso_id-1_53.98x85.6mm", {53.98, 85.60}}, + {"iso_id-3_88x125mm", {88.00, 125.00}}, + {"iso_ra0_860x1220mm", {860.00, 1220.00}}, + {"iso_ra1_610x860mm", {610.00, 860.00}}, + {"iso_ra2_430x610mm", {430.00, 610.00}}, + {"iso_ra3_305x430mm", {305.00, 430.00}}, + {"iso_ra4_215x305mm", {215.00, 305.00}}, + {"iso_sra0_900x1280mm", {900.00, 1280.00}}, + {"iso_sra1_640x900mm", {640.00, 900.00}}, + {"iso_sra2_450x640mm", {450.00, 640.00}}, + {"iso_sra3_320x450mm", {320.00, 450.00}}, + {"iso_sra4_225x320mm", {225.00, 320.00}}, + {"jis_b0_1030x1456mm", {1030.00, 1456.00}}, + {"jis_b10_32x45mm", {32.00, 45.00}}, + {"jis_b1_728x1030mm", {728.00, 1030.00}}, + {"jis_b2_515x728mm", {515.00, 728.00}}, + {"jis_b3_364x515mm", {364.00, 515.00}}, + {"jis_b4_257x364mm", {257.00, 364.00}}, + {"jis_b5_182x257mm", {182.00, 257.00}}, + {"jis_b6_128x182mm", {128.00, 182.00}}, + {"jis_b7_91x128mm", {91.00, 128.00}}, + {"jis_b8_64x91mm", {64.00, 91.00}}, + {"jis_b9_45x64mm", {45.00, 64.00}}, + {"jis_exec_216x330mm", {216.00, 330.00}}, + {"jpn_chou2_111.1x146mm", {111.10, 146.00}}, + {"jpn_chou3_120x235mm", {120.00, 235.00}}, + {"jpn_chou40_90x225mm", {90.00, 225.00}}, + {"jpn_chou4_90x205mm", {90.00, 205.00}}, + {"jpn_hagaki_100x148mm", {100.00, 148.00}}, + {"jpn_kahu_240x322.1mm", {240.00, 322.10}}, + {"jpn_kaku1_270x382mm", {270.00, 382.00}}, + {"jpn_kaku2_240x332mm", {240.00, 332.00}}, + {"jpn_kaku3_216x277mm", {216.00, 277.00}}, + {"jpn_kaku4_197x267mm", {197.00, 267.00}}, + {"jpn_kaku5_190x240mm", {190.00, 240.00}}, + {"jpn_kaku7_142x205mm", {142.00, 205.00}}, + {"jpn_kaku8_119x197mm", {119.00, 197.00}}, + {"jpn_oufuku_148x200mm", {148.00, 200.00}}, + {"jpn_you4_105x235mm", {105.00, 235.00}}, + {"na_10x11_10x11in", {25.40, 27.94}}, + {"na_10x13_10x13in", {25.40, 33.02}}, + {"na_10x14_10x14in", {25.40, 35.56}}, + {"na_10x15_10x15in", {25.40, 38.10}}, + {"na_11x12_11x12in", {27.94, 30.48}}, + {"na_11x15_11x15in", {27.94, 38.10}}, + {"na_12x19_12x19in", {30.48, 48.26}}, + {"na_5x7_5x7in", {12.70, 17.78}}, + {"na_6x9_6x9in", {15.24, 22.86}}, + {"na_7x9_7x9in", {17.78, 22.86}}, + {"na_9x11_9x11in", {22.86, 27.94}}, + {"na_a2_4.375x5.75in", {11.11, 14.61}}, + {"na_arch-a_9x12in", {22.86, 30.48}}, + {"na_arch-b_12x18in", {30.48, 45.72}}, + {"na_arch-c_18x24in", {45.72, 60.96}}, + {"na_arch-d_24x36in", {60.96, 91.44}}, + {"na_arch-e2_26x38in", {66.04, 96.52}}, + {"na_arch-e3_27x39in", {68.58, 99.06}}, + {"na_arch-e_36x48in", {91.44, 121.92}}, + {"na_b-plus_12x19.17in", {30.48, 48.69}}, + {"na_c5_6.5x9.5in", {16.51, 24.13}}, + {"na_c_17x22in", {43.18, 55.88}}, + {"na_d_22x34in", {55.88, 86.36}}, + {"na_e_34x44in", {86.36, 111.76}}, + {"na_edp_11x14in", {27.94, 35.56}}, + {"na_eur-edp_12x14in", {30.48, 35.56}}, + {"na_executive_7.25x10.5in", {18.41, 26.67}}, + {"na_f_44x68in", {111.76, 172.72}}, + {"na_fanfold-eur_8.5x12in", {21.59, 30.48}}, + {"na_fanfold-us_11x14.875in", {27.94, 37.78}}, + {"na_foolscap_8.5x13in", {21.59, 33.02}}, + {"na_govt-legal_8x13in", {20.32, 33.02}}, + {"na_govt-letter_8x10in", {20.32, 25.40}}, + {"na_index-3x5_3x5in", {7.62, 12.70}}, + {"na_index-4x6-ext_6x8in", {15.24, 20.32}}, + {"na_index-4x6_4x6in", {10.16, 15.24}}, + {"na_index-5x8_5x8in", {12.70, 20.32}}, + {"na_invoice_5.5x8.5in", {13.97, 21.59}}, + {"na_ledger_11x17in", {27.94, 43.18}}, + {"na_legal-extra_9.5x15in", {24.13, 38.10}}, + {"na_legal_8.5x14in", {21.59, 35.56}}, + {"na_letter-extra_9.5x12in", {24.13, 30.48}}, + {"na_letter-plus_8.5x12.69in", {21.59, 32.23}}, + {"na_letter_8.5x11in", {21.59, 27.94}}, + {"na_monarch_3.875x7.5in", {9.84, 19.05}}, + {"na_number-10_4.125x9.5in", {10.48, 24.13}}, + {"na_number-11_4.5x10.375in", {11.43, 26.35}}, + {"na_number-12_4.75x11in", {12.06, 27.94}}, + {"na_number-14_5x11.5in", {12.70, 29.21}}, + {"na_number-9_3.875x8.875in", {9.84, 22.54}}, + {"na_oficio_8.5x13.4in", {21.59, 34.04}}, + {"na_personal_3.625x6.5in", {9.21, 16.51}}, + {"na_quarto_8.5x10.83in", {21.59, 27.51}}, + {"na_super-a_8.94x14in", {22.71, 35.56}}, + {"na_super-b_13x19in", {33.02, 48.26}}, + {"na_wide-format_30x42in", {76.20, 106.68}}, + {"oe_12x16_12x16in", {30.48, 40.64}}, + {"oe_14x17_14x17in", {35.56, 43.18}}, + {"oe_18x22_18x22in", {45.72, 55.88}}, + {"oe_a2plus_17x24in", {43.18, 60.96}}, + {"oe_business-card_2x3.5in", {5.08, 8.89}}, + {"oe_photo-10r_10x12in", {25.40, 30.48}}, + {"oe_photo-20r_20x24in", {50.80, 60.96}}, + {"oe_photo-l_3.5x5in", {8.89, 12.70}}, + {"oe_photo-s10r_10x15in", {25.40, 38.10}}, + {"oe_square-photo_4x4in", {10.16, 10.16}}, + {"oe_square-photo_5x5in", {12.70, 12.70}}, + {"om_16k_184x260mm", {184.00, 260.00}}, + {"om_16k_195x270mm", {195.00, 270.00}}, + {"om_business-card_55x85mm", {55.00, 85.00}}, + {"om_business-card_55x91mm", {55.00, 91.00}}, + {"om_card_54x86mm", {54.00, 86.00}}, + {"om_dai-pa-kai_275x395mm", {275.00, 395.00}}, + {"om_dsc-photo_89x119mm", {89.00, 119.00}}, + {"om_folio-sp_215x315mm", {215.00, 315.00}}, + {"om_folio_210x330mm", {210.00, 330.00}}, + {"om_invite_220x220mm", {220.00, 220.00}}, + {"om_italian_110x230mm", {110.00, 230.00}}, + {"om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, + {"om_large-photo_200x300", {200.00, 3.00}}, + {"om_medium-photo_130x180mm", {130.00, 180.00}}, + {"om_pa-kai_267x389mm", {267.00, 389.00}}, + {"om_postfix_114x229mm", {114.00, 229.00}}, + {"om_small-photo_100x150mm", {100.00, 150.00}}, + {"om_square-photo_89x89mm", {89.00, 89.00}}, + {"om_wide-photo_100x200mm", {100.00, 200.00}}, + {"prc_10_324x458mm", {324.00, 458.00}}, + {"prc_16k_146x215mm", {146.00, 215.00}}, + {"prc_1_102x165mm", {102.00, 165.00}}, + {"prc_2_102x176mm", {102.00, 176.00}}, + {"prc_32k_97x151mm", {97.00, 151.00}}, + {"prc_3_125x176mm", {125.00, 176.00}}, + {"prc_4_110x208mm", {110.00, 208.00}}, + {"prc_5_110x220mm", {110.00, 220.00}}, + {"prc_6_120x320mm", {120.00, 320.00}}, + {"prc_7_160x230mm", {160.00, 230.00}}, + {"prc_8_120x309mm", {120.00, 309.00}}, + {"roc_16k_7.75x10.75in", {19.68, 27.30}}, + {"roc_8k_10.75x15.5in", {27.30, 39.37}}}; + + +#endif // PAPERSIZES_H diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index a6ae0fb..37a3078 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -128,6 +128,14 @@ Failed to load image + + Unsupported PDF paper size + + + + Unsupported paper size + + CoverPage @@ -189,6 +197,10 @@ Failed to open file + + Unsupported print media + + JobsPage @@ -247,6 +259,10 @@ Resolution + + Print media + + utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 2efd2b2..db42f13 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -128,6 +128,14 @@ Failed to load image + + Unsupported PDF paper size + + + + Unsupported paper size + + CoverPage @@ -189,6 +197,10 @@ Failed to open file + + Unsupported print media + + JobsPage @@ -247,6 +259,10 @@ Resolution Resolución + + Print media + + utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index a3c24e7..64b24e4 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -128,6 +128,14 @@ Failed to load image + + Unsupported PDF paper size + + + + Unsupported paper size + + CoverPage @@ -189,6 +197,10 @@ Failed to open file + + Unsupported print media + + JobsPage @@ -247,6 +259,10 @@ Resolution Résolution + + Print media + + utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index b9d1038..6fba3d7 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -128,6 +128,14 @@ Failed to load image + + Unsupported PDF paper size + + + + Unsupported paper size + + CoverPage @@ -189,6 +197,10 @@ Failed to open file + + Unsupported print media + + JobsPage @@ -247,6 +259,10 @@ Resolution 分辨率 + + Print media + + utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 8af979a..6ae5903 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -128,6 +128,14 @@ Failed to load image + + Unsupported PDF paper size + + + + Unsupported paper size + + CoverPage @@ -189,6 +197,10 @@ Failed to open file + + Unsupported print media + + JobsPage @@ -247,6 +259,10 @@ Resolution + + Print media + + utils From 0d94f8a4f6adc1418f48e980dfcd019beff4d61b Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 15:23:07 +0200 Subject: [PATCH 50/94] Make image support unconditional --- qml/pages/utils.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 17a0f79..ca0c8f5 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -13,11 +13,11 @@ function supported_formats(printer, ConvertChecker) mimetypes.push("application/postscript"); supported.push("Postscript"); } - if(has(formats, "image/jpeg")) - { - mimetypes.push("image/jpeg"); - supported.push("JPEG"); - } + + mimetypes.push("image/jpeg"); + supported.push("JPEG"); + mimetypes.push("image/png"); + supported.push("PNG"); //var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";"); var maybe = [] From 2da5baad591c48f5cb086e646d192b71ed30c4cc Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 15:33:22 +0200 Subject: [PATCH 51/94] Nevermind, only consider images supported if raster formats are supported --- qml/pages/utils.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index ca0c8f5..5c51925 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -14,11 +14,13 @@ function supported_formats(printer, ConvertChecker) supported.push("Postscript"); } - mimetypes.push("image/jpeg"); - supported.push("JPEG"); - mimetypes.push("image/png"); - supported.push("PNG"); - + if ( has(formats, "image/pwg-raster") || has(formats, "image/urf")) + { + mimetypes.push("image/jpeg"); + supported.push("JPEG"); + mimetypes.push("image/png"); + supported.push("PNG"); + } //var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";"); var maybe = [] var info = printer.attrs["printer-info"] ? printer.attrs["printer-info"].value.split(";") : []; From 7f4786fe946745b83387c31e6521729ad5045e97 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 15:35:41 +0200 Subject: [PATCH 52/94] 0.5... ish? --- rpm/harbour-seaprint.spec | 2 +- rpm/harbour-seaprint.yaml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rpm/harbour-seaprint.spec b/rpm/harbour-seaprint.spec index 4d05046..0d4cada 100644 --- a/rpm/harbour-seaprint.spec +++ b/rpm/harbour-seaprint.spec @@ -9,7 +9,7 @@ Name: harbour-seaprint # << macros Summary: SeaPrint -Version: 0.4.5 +Version: 0.5 Release: 1 Group: Qt/Qt License: LICENSE diff --git a/rpm/harbour-seaprint.yaml b/rpm/harbour-seaprint.yaml index c6b8059..9c46975 100644 --- a/rpm/harbour-seaprint.yaml +++ b/rpm/harbour-seaprint.yaml @@ -1,7 +1,7 @@ Name: harbour-seaprint Summary: SeaPrint -Version: 0.4.4 -Release: 2 +Version: 0.5 +Release: 1 # The contents of the Group field should be one of the groups listed here: # https://github.com/mer-tools/spectacle/blob/master/data/GROUPS Group: Qt/Qt From 33ff8597576670e0b729d3589103bf849020921e Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 16:03:42 +0200 Subject: [PATCH 53/94] Make forced raster conversions a dconf setting --- qml/pages/PrinterPage.qml | 10 +++++++++- src/ippprinter.cpp | 9 +++++++-- src/ippprinter.h | 2 +- translations/harbour-seaprint-de.ts | 4 ++++ translations/harbour-seaprint-es.ts | 4 ++++ translations/harbour-seaprint-fr.ts | 4 ++++ translations/harbour-seaprint-zh_CN.ts | 4 ++++ translations/harbour-seaprint.ts | 4 ++++ 8 files changed, 37 insertions(+), 4 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index a8e879b..9dca3a5 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import "utils.js" as Utils +import Nemo.Configuration 1.0 Page { id: page @@ -8,6 +9,13 @@ Page { property var jobParams: new Object(); property string selectedFile + ConfigurationValue + { + id: alwaysConvert + key: "/apps/harbour-seaprint/settings/always_convert" + defaultValue: false + } + Component.onCompleted: { console.log(JSON.stringify(printer.attrs)) } @@ -24,7 +32,7 @@ Page { console.log(JSON.stringify(jobParams)) pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, PageStackAction.Immediate) - printer.print(jobParams, page.selectedFile) + printer.print(jobParams, page.selectedFile, alwaysConvert.value) } } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 8a73c19..86e52d3 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -228,7 +228,7 @@ void IppPrinter::convertFailed(QString message) emit jobFinished(false); } -void IppPrinter::print(QJsonObject attrs, QString filename){ +void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ qDebug() << "printing" << filename << attrs; QFile file(filename); @@ -283,7 +283,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(from == Image || (from == Pdf /*&& !supportedMimeTypes.contains("application/pdf")*/)) + if(alwaysConvert || from == Image || (from == Pdf && !supportedMimeTypes.contains("application/pdf"))) { if(supportedMimeTypes.contains("image/pwg-raster")) { @@ -347,6 +347,11 @@ void IppPrinter::print(QJsonObject attrs, QString filename){ emit doConvertImage(request, filename, tempfile, target==UrfConvert, Colors, Quality, PaperSize, HwResX, HwResY); } + else + { + emit convertFailed(tr("Cannot convert this file format")); + return; + } } else { diff --git a/src/ippprinter.h b/src/ippprinter.h index 01eeb46..aa2e83c 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -63,7 +63,7 @@ signals: void busyMessageChanged(); public slots: - void print(QJsonObject attrs, QString file); + void print(QJsonObject attrs, QString file, bool alwaysConvert); void onUrlChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 37a3078..6edc3c7 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -201,6 +201,10 @@ Unsupported print media + + Cannot convert this file format + + JobsPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index db42f13..8cd54a5 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -201,6 +201,10 @@ Unsupported print media + + Cannot convert this file format + + JobsPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 64b24e4..bca0d34 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -201,6 +201,10 @@ Unsupported print media + + Cannot convert this file format + + JobsPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 6fba3d7..9d0b14d 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -201,6 +201,10 @@ Unsupported print media + + Cannot convert this file format + + JobsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 6ae5903..60aa166 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -201,6 +201,10 @@ Unsupported print media + + Cannot convert this file format + + JobsPage From 7630e4e59a0785467af1dcfd53f87a5c26aa9538 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 16 May 2020 16:05:09 +0200 Subject: [PATCH 54/94] Update about page --- qml/pages/AboutPage.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qml/pages/AboutPage.qml b/qml/pages/AboutPage.qml index 8b86a12..0d26dec 100644 --- a/qml/pages/AboutPage.qml +++ b/qml/pages/AboutPage.qml @@ -62,7 +62,7 @@ Page { AboutLabel { font.pixelSize: Theme.fontSizeSmall color: Theme.primaryColor - text: "© 2019 Anton Thomasson" + text: "© 2019-2020 Anton Thomasson" } AboutLabel { @@ -99,7 +99,7 @@ Page { AboutLabel { font.pixelSize: Theme.fontSizeSmall - text: qsTr("pdftoppm (from poppler-utils)")+" - "+(ConvertChecker.pdf ? qsTr("Installed") : qsTr("Not installed")) + text: "poppler-utils - "+(ConvertChecker.pdf ? qsTr("Installed") : qsTr("Not installed")) } SectionHeader { text: qsTr("Licensing") } From ed217f8769ce7a701a4fea0ac9b874d307dc4417 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 17 May 2020 12:09:41 +0200 Subject: [PATCH 55/94] Fix paper sizes --- src/papersizes.h | 400 +++++++++++++++++++++++------------------------ 1 file changed, 200 insertions(+), 200 deletions(-) diff --git a/src/papersizes.h b/src/papersizes.h index d810a82..e0a43d3 100644 --- a/src/papersizes.h +++ b/src/papersizes.h @@ -4,206 +4,206 @@ #include static QMap> PaperSizes = - {{"asme_f_28x40in", {71.12, 101.60}}, - {"iso_2a0_1189x1682mm", {1189.00, 1682.00}}, - {"iso_a0_841x1189mm", {841.00, 1189.00}}, - {"iso_a0x3_1189x2523mm", {1189.00, 2523.00}}, - {"iso_a10_26x37mm", {26.00, 37.00}}, - {"iso_a1_594x841mm", {594.00, 841.00}}, - {"iso_a1x3_841x1783mm", {841.00, 1783.00}}, - {"iso_a1x4_841x2378mm", {841.00, 2378.00}}, - {"iso_a2_420x594mm", {420.00, 594.00}}, - {"iso_a2x3_594x1261mm", {594.00, 1261.00}}, - {"iso_a2x4_594x1682mm", {594.00, 1682.00}}, - {"iso_a2x5_594x2102mm", {594.00, 2102.00}}, - {"iso_a3-extra_322x445mm", {322.00, 445.00}}, - {"iso_a3_297x420mm", {297.00, 420.00}}, - {"iso_a3x3_420x891mm", {420.00, 891.00}}, - {"iso_a3x4_420x1189mm", {420.00, 1189.00}}, - {"iso_a3x5_420x1486mm", {420.00, 1486.00}}, - {"iso_a3x6_420x1783mm", {420.00, 1783.00}}, - {"iso_a3x7_420x2080mm", {420.00, 2080.00}}, - {"iso_a4-extra_235.5x322.3mm", {235.50, 322.30}}, - {"iso_a4-tab_225x297mm", {225.00, 297.00}}, - {"iso_a4_210x297mm", {210.00, 297.00}}, - {"iso_a4x3_297x630mm", {297.00, 630.00}}, - {"iso_a4x4_297x841mm", {297.00, 841.00}}, - {"iso_a4x5_297x1051mm", {297.00, 1051.00}}, - {"iso_a4x6_297x1261mm", {297.00, 1261.00}}, - {"iso_a4x7_297x1471mm", {297.00, 1471.00}}, - {"iso_a4x8_297x1682mm", {297.00, 1682.00}}, - {"iso_a4x9_297x1892mm", {297.00, 1892.00}}, - {"iso_a5-extra_174x235mm", {174.00, 235.00}}, - {"iso_a5_148x210mm", {148.00, 210.00}}, - {"iso_a6_105x148mm", {105.00, 148.00}}, - {"iso_a7_74x105mm", {74.00, 105.00}}, - {"iso_a8_52x74mm", {52.00, 74.00}}, - {"iso_a9_37x52mm", {37.00, 52.00}}, - {"iso_b0_1000x1414mm", {1000.00, 1414.00}}, - {"iso_b10_31x44mm", {31.00, 44.00}}, - {"iso_b1_707x1000mm", {707.00, 1000.00}}, - {"iso_b2_500x707mm", {500.00, 707.00}}, - {"iso_b3_353x500mm", {353.00, 500.00}}, - {"iso_b4_250x353mm", {250.00, 353.00}}, - {"iso_b5-extra_201x276mm", {201.00, 276.00}}, - {"iso_b5_176x250mm", {176.00, 250.00}}, - {"iso_b6_125x176mm", {125.00, 176.00}}, - {"iso_b6c4_125x324mm", {125.00, 324.00}}, - {"iso_b7_88x125mm", {88.00, 125.00}}, - {"iso_b8_62x88mm", {62.00, 88.00}}, - {"iso_b9_44x62mm", {44.00, 62.00}}, - {"iso_c0_917x1297mm", {917.00, 1297.00}}, - {"iso_c10_28x40mm", {28.00, 40.00}}, - {"iso_c1_648x917mm", {648.00, 917.00}}, - {"iso_c2_458x648mm", {458.00, 648.00}}, - {"iso_c3_324x458mm", {324.00, 458.00}}, - {"iso_c4_229x324mm", {229.00, 324.00}}, - {"iso_c5_162x229mm", {162.00, 229.00}}, - {"iso_c6_114x162mm", {114.00, 162.00}}, - {"iso_c6c5_114x229mm", {114.00, 229.00}}, - {"iso_c7_81x114mm", {81.00, 114.00}}, - {"iso_c7c6_81x162mm", {81.00, 162.00}}, - {"iso_c8_57x81mm", {57.00, 81.00}}, - {"iso_c9_40x57mm", {40.00, 57.00}}, - {"iso_dl_110x220mm", {110.00, 220.00}}, - {"iso_id-1_53.98x85.6mm", {53.98, 85.60}}, - {"iso_id-3_88x125mm", {88.00, 125.00}}, - {"iso_ra0_860x1220mm", {860.00, 1220.00}}, - {"iso_ra1_610x860mm", {610.00, 860.00}}, - {"iso_ra2_430x610mm", {430.00, 610.00}}, - {"iso_ra3_305x430mm", {305.00, 430.00}}, - {"iso_ra4_215x305mm", {215.00, 305.00}}, - {"iso_sra0_900x1280mm", {900.00, 1280.00}}, - {"iso_sra1_640x900mm", {640.00, 900.00}}, - {"iso_sra2_450x640mm", {450.00, 640.00}}, - {"iso_sra3_320x450mm", {320.00, 450.00}}, - {"iso_sra4_225x320mm", {225.00, 320.00}}, - {"jis_b0_1030x1456mm", {1030.00, 1456.00}}, - {"jis_b10_32x45mm", {32.00, 45.00}}, - {"jis_b1_728x1030mm", {728.00, 1030.00}}, - {"jis_b2_515x728mm", {515.00, 728.00}}, - {"jis_b3_364x515mm", {364.00, 515.00}}, - {"jis_b4_257x364mm", {257.00, 364.00}}, - {"jis_b5_182x257mm", {182.00, 257.00}}, - {"jis_b6_128x182mm", {128.00, 182.00}}, - {"jis_b7_91x128mm", {91.00, 128.00}}, - {"jis_b8_64x91mm", {64.00, 91.00}}, - {"jis_b9_45x64mm", {45.00, 64.00}}, - {"jis_exec_216x330mm", {216.00, 330.00}}, - {"jpn_chou2_111.1x146mm", {111.10, 146.00}}, - {"jpn_chou3_120x235mm", {120.00, 235.00}}, - {"jpn_chou40_90x225mm", {90.00, 225.00}}, - {"jpn_chou4_90x205mm", {90.00, 205.00}}, - {"jpn_hagaki_100x148mm", {100.00, 148.00}}, - {"jpn_kahu_240x322.1mm", {240.00, 322.10}}, - {"jpn_kaku1_270x382mm", {270.00, 382.00}}, - {"jpn_kaku2_240x332mm", {240.00, 332.00}}, - {"jpn_kaku3_216x277mm", {216.00, 277.00}}, - {"jpn_kaku4_197x267mm", {197.00, 267.00}}, - {"jpn_kaku5_190x240mm", {190.00, 240.00}}, - {"jpn_kaku7_142x205mm", {142.00, 205.00}}, - {"jpn_kaku8_119x197mm", {119.00, 197.00}}, - {"jpn_oufuku_148x200mm", {148.00, 200.00}}, - {"jpn_you4_105x235mm", {105.00, 235.00}}, - {"na_10x11_10x11in", {25.40, 27.94}}, - {"na_10x13_10x13in", {25.40, 33.02}}, - {"na_10x14_10x14in", {25.40, 35.56}}, - {"na_10x15_10x15in", {25.40, 38.10}}, - {"na_11x12_11x12in", {27.94, 30.48}}, - {"na_11x15_11x15in", {27.94, 38.10}}, - {"na_12x19_12x19in", {30.48, 48.26}}, - {"na_5x7_5x7in", {12.70, 17.78}}, - {"na_6x9_6x9in", {15.24, 22.86}}, - {"na_7x9_7x9in", {17.78, 22.86}}, - {"na_9x11_9x11in", {22.86, 27.94}}, - {"na_a2_4.375x5.75in", {11.11, 14.61}}, - {"na_arch-a_9x12in", {22.86, 30.48}}, - {"na_arch-b_12x18in", {30.48, 45.72}}, - {"na_arch-c_18x24in", {45.72, 60.96}}, - {"na_arch-d_24x36in", {60.96, 91.44}}, - {"na_arch-e2_26x38in", {66.04, 96.52}}, - {"na_arch-e3_27x39in", {68.58, 99.06}}, - {"na_arch-e_36x48in", {91.44, 121.92}}, - {"na_b-plus_12x19.17in", {30.48, 48.69}}, - {"na_c5_6.5x9.5in", {16.51, 24.13}}, - {"na_c_17x22in", {43.18, 55.88}}, - {"na_d_22x34in", {55.88, 86.36}}, - {"na_e_34x44in", {86.36, 111.76}}, - {"na_edp_11x14in", {27.94, 35.56}}, - {"na_eur-edp_12x14in", {30.48, 35.56}}, - {"na_executive_7.25x10.5in", {18.41, 26.67}}, - {"na_f_44x68in", {111.76, 172.72}}, - {"na_fanfold-eur_8.5x12in", {21.59, 30.48}}, - {"na_fanfold-us_11x14.875in", {27.94, 37.78}}, - {"na_foolscap_8.5x13in", {21.59, 33.02}}, - {"na_govt-legal_8x13in", {20.32, 33.02}}, - {"na_govt-letter_8x10in", {20.32, 25.40}}, - {"na_index-3x5_3x5in", {7.62, 12.70}}, - {"na_index-4x6-ext_6x8in", {15.24, 20.32}}, - {"na_index-4x6_4x6in", {10.16, 15.24}}, - {"na_index-5x8_5x8in", {12.70, 20.32}}, - {"na_invoice_5.5x8.5in", {13.97, 21.59}}, - {"na_ledger_11x17in", {27.94, 43.18}}, - {"na_legal-extra_9.5x15in", {24.13, 38.10}}, - {"na_legal_8.5x14in", {21.59, 35.56}}, - {"na_letter-extra_9.5x12in", {24.13, 30.48}}, - {"na_letter-plus_8.5x12.69in", {21.59, 32.23}}, - {"na_letter_8.5x11in", {21.59, 27.94}}, - {"na_monarch_3.875x7.5in", {9.84, 19.05}}, - {"na_number-10_4.125x9.5in", {10.48, 24.13}}, - {"na_number-11_4.5x10.375in", {11.43, 26.35}}, - {"na_number-12_4.75x11in", {12.06, 27.94}}, - {"na_number-14_5x11.5in", {12.70, 29.21}}, - {"na_number-9_3.875x8.875in", {9.84, 22.54}}, - {"na_oficio_8.5x13.4in", {21.59, 34.04}}, - {"na_personal_3.625x6.5in", {9.21, 16.51}}, - {"na_quarto_8.5x10.83in", {21.59, 27.51}}, - {"na_super-a_8.94x14in", {22.71, 35.56}}, - {"na_super-b_13x19in", {33.02, 48.26}}, - {"na_wide-format_30x42in", {76.20, 106.68}}, - {"oe_12x16_12x16in", {30.48, 40.64}}, - {"oe_14x17_14x17in", {35.56, 43.18}}, - {"oe_18x22_18x22in", {45.72, 55.88}}, - {"oe_a2plus_17x24in", {43.18, 60.96}}, - {"oe_business-card_2x3.5in", {5.08, 8.89}}, - {"oe_photo-10r_10x12in", {25.40, 30.48}}, - {"oe_photo-20r_20x24in", {50.80, 60.96}}, - {"oe_photo-l_3.5x5in", {8.89, 12.70}}, - {"oe_photo-s10r_10x15in", {25.40, 38.10}}, - {"oe_square-photo_4x4in", {10.16, 10.16}}, - {"oe_square-photo_5x5in", {12.70, 12.70}}, - {"om_16k_184x260mm", {184.00, 260.00}}, - {"om_16k_195x270mm", {195.00, 270.00}}, - {"om_business-card_55x85mm", {55.00, 85.00}}, - {"om_business-card_55x91mm", {55.00, 91.00}}, - {"om_card_54x86mm", {54.00, 86.00}}, - {"om_dai-pa-kai_275x395mm", {275.00, 395.00}}, - {"om_dsc-photo_89x119mm", {89.00, 119.00}}, - {"om_folio-sp_215x315mm", {215.00, 315.00}}, - {"om_folio_210x330mm", {210.00, 330.00}}, - {"om_invite_220x220mm", {220.00, 220.00}}, - {"om_italian_110x230mm", {110.00, 230.00}}, - {"om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, - {"om_large-photo_200x300", {200.00, 3.00}}, - {"om_medium-photo_130x180mm", {130.00, 180.00}}, - {"om_pa-kai_267x389mm", {267.00, 389.00}}, - {"om_postfix_114x229mm", {114.00, 229.00}}, - {"om_small-photo_100x150mm", {100.00, 150.00}}, - {"om_square-photo_89x89mm", {89.00, 89.00}}, - {"om_wide-photo_100x200mm", {100.00, 200.00}}, - {"prc_10_324x458mm", {324.00, 458.00}}, - {"prc_16k_146x215mm", {146.00, 215.00}}, - {"prc_1_102x165mm", {102.00, 165.00}}, - {"prc_2_102x176mm", {102.00, 176.00}}, - {"prc_32k_97x151mm", {97.00, 151.00}}, - {"prc_3_125x176mm", {125.00, 176.00}}, - {"prc_4_110x208mm", {110.00, 208.00}}, - {"prc_5_110x220mm", {110.00, 220.00}}, - {"prc_6_120x320mm", {120.00, 320.00}}, - {"prc_7_160x230mm", {160.00, 230.00}}, - {"prc_8_120x309mm", {120.00, 309.00}}, - {"roc_16k_7.75x10.75in", {19.68, 27.30}}, - {"roc_8k_10.75x15.5in", {27.30, 39.37}}}; + {{"media.asme_f_28x40in", {711.20, 1016.00}}, + {"media.iso_2a0_1189x1682mm", {1189.00, 1682.00}}, + {"media.iso_a0_841x1189mm", {841.00, 1189.00}}, + {"media.iso_a0x3_1189x2523mm", {1189.00, 2523.00}}, + {"media.iso_a10_26x37mm", {26.00, 37.00}}, + {"media.iso_a1_594x841mm", {594.00, 841.00}}, + {"media.iso_a1x3_841x1783mm", {841.00, 1783.00}}, + {"media.iso_a1x4_841x2378mm", {841.00, 2378.00}}, + {"media.iso_a2_420x594mm", {420.00, 594.00}}, + {"media.iso_a2x3_594x1261mm", {594.00, 1261.00}}, + {"media.iso_a2x4_594x1682mm", {594.00, 1682.00}}, + {"media.iso_a2x5_594x2102mm", {594.00, 2102.00}}, + {"media.iso_a3-extra_322x445mm", {322.00, 445.00}}, + {"media.iso_a3_297x420mm", {297.00, 420.00}}, + {"media.iso_a3x3_420x891mm", {420.00, 891.00}}, + {"media.iso_a3x4_420x1189mm", {420.00, 1189.00}}, + {"media.iso_a3x5_420x1486mm", {420.00, 1486.00}}, + {"media.iso_a3x6_420x1783mm", {420.00, 1783.00}}, + {"media.iso_a3x7_420x2080mm", {420.00, 2080.00}}, + {"media.iso_a4-extra_235.5x322.3m", {235.50, 322.30}}, + {"media.iso_a4-tab_225x297mm", {225.00, 297.00}}, + {"media.iso_a4_210x297mm", {210.00, 297.00}}, + {"media.iso_a4x3_297x630mm", {297.00, 630.00}}, + {"media.iso_a4x4_297x841mm", {297.00, 841.00}}, + {"media.iso_a4x5_297x1051mm", {297.00, 1051.00}}, + {"media.iso_a4x6_297x1261mm", {297.00, 1261.00}}, + {"media.iso_a4x7_297x1471mm", {297.00, 1471.00}}, + {"media.iso_a4x8_297x1682mm", {297.00, 1682.00}}, + {"media.iso_a4x9_297x1892mm", {297.00, 1892.00}}, + {"media.iso_a5-extra_174x235mm", {174.00, 235.00}}, + {"media.iso_a5_148x210mm", {148.00, 210.00}}, + {"media.iso_a6_105x148mm", {105.00, 148.00}}, + {"media.iso_a7_74x105mm", {74.00, 105.00}}, + {"media.iso_a8_52x74mm", {52.00, 74.00}}, + {"media.iso_a9_37x52mm", {37.00, 52.00}}, + {"media.iso_b0_1000x1414mm", {1000.00, 1414.00}}, + {"media.iso_b10_31x44mm", {31.00, 44.00}}, + {"media.iso_b1_707x1000mm", {707.00, 1000.00}}, + {"media.iso_b2_500x707mm", {500.00, 707.00}}, + {"media.iso_b3_353x500mm", {353.00, 500.00}}, + {"media.iso_b4_250x353mm", {250.00, 353.00}}, + {"media.iso_b5-extra_201x276mm", {201.00, 276.00}}, + {"media.iso_b5_176x250mm", {176.00, 250.00}}, + {"media.iso_b6_125x176mm", {125.00, 176.00}}, + {"media.iso_b6c4_125x324mm", {125.00, 324.00}}, + {"media.iso_b7_88x125mm", {88.00, 125.00}}, + {"media.iso_b8_62x88mm", {62.00, 88.00}}, + {"media.iso_b9_44x62mm", {44.00, 62.00}}, + {"media.iso_c0_917x1297mm", {917.00, 1297.00}}, + {"media.iso_c10_28x40mm", {28.00, 40.00}}, + {"media.iso_c1_648x917mm", {648.00, 917.00}}, + {"media.iso_c2_458x648mm", {458.00, 648.00}}, + {"media.iso_c3_324x458mm", {324.00, 458.00}}, + {"media.iso_c4_229x324mm", {229.00, 324.00}}, + {"media.iso_c5_162x229mm", {162.00, 229.00}}, + {"media.iso_c6_114x162mm", {114.00, 162.00}}, + {"media.iso_c6c5_114x229mm", {114.00, 229.00}}, + {"media.iso_c7_81x114mm", {81.00, 114.00}}, + {"media.iso_c7c6_81x162mm", {81.00, 162.00}}, + {"media.iso_c8_57x81mm", {57.00, 81.00}}, + {"media.iso_c9_40x57mm", {40.00, 57.00}}, + {"media.iso_dl_110x220mm", {110.00, 220.00}}, + {"media.iso_id-1_53.98x85.6mm", {53.98, 85.60}}, + {"media.iso_id-3_88x125mm", {88.00, 125.00}}, + {"media.iso_ra0_860x1220mm", {860.00, 1220.00}}, + {"media.iso_ra1_610x860mm", {610.00, 860.00}}, + {"media.iso_ra2_430x610mm", {430.00, 610.00}}, + {"media.iso_ra3_305x430mm", {305.00, 430.00}}, + {"media.iso_ra4_215x305mm", {215.00, 305.00}}, + {"media.iso_sra0_900x1280mm", {900.00, 1280.00}}, + {"media.iso_sra1_640x900mm", {640.00, 900.00}}, + {"media.iso_sra2_450x640mm", {450.00, 640.00}}, + {"media.iso_sra3_320x450mm", {320.00, 450.00}}, + {"media.iso_sra4_225x320mm", {225.00, 320.00}}, + {"media.jis_b0_1030x1456mm", {1030.00, 1456.00}}, + {"media.jis_b10_32x45mm", {32.00, 45.00}}, + {"media.jis_b1_728x1030mm", {728.00, 1030.00}}, + {"media.jis_b2_515x728mm", {515.00, 728.00}}, + {"media.jis_b3_364x515mm", {364.00, 515.00}}, + {"media.jis_b4_257x364mm", {257.00, 364.00}}, + {"media.jis_b5_182x257mm", {182.00, 257.00}}, + {"media.jis_b6_128x182mm", {128.00, 182.00}}, + {"media.jis_b7_91x128mm", {91.00, 128.00}}, + {"media.jis_b8_64x91mm", {64.00, 91.00}}, + {"media.jis_b9_45x64mm", {45.00, 64.00}}, + {"media.jis_exec_216x330mm", {216.00, 330.00}}, + {"media.jpn_chou2_111.1x146mm", {111.10, 146.00}}, + {"media.jpn_chou3_120x235mm", {120.00, 235.00}}, + {"media.jpn_chou40_90x225mm", {90.00, 225.00}}, + {"media.jpn_chou4_90x205mm", {90.00, 205.00}}, + {"media.jpn_hagaki_100x148mm", {100.00, 148.00}}, + {"media.jpn_kahu_240x322.1mm", {240.00, 322.10}}, + {"media.jpn_kaku1_270x382mm", {270.00, 382.00}}, + {"media.jpn_kaku2_240x332mm", {240.00, 332.00}}, + {"media.jpn_kaku3_216x277mm", {216.00, 277.00}}, + {"media.jpn_kaku4_197x267mm", {197.00, 267.00}}, + {"media.jpn_kaku5_190x240mm", {190.00, 240.00}}, + {"media.jpn_kaku7_142x205mm", {142.00, 205.00}}, + {"media.jpn_kaku8_119x197mm", {119.00, 197.00}}, + {"media.jpn_oufuku_148x200mm", {148.00, 200.00}}, + {"media.jpn_you4_105x235mm", {105.00, 235.00}}, + {"media.na_10x11_10x11in", {254.00, 279.40}}, + {"media.na_10x13_10x13in", {254.00, 330.20}}, + {"media.na_10x14_10x14in", {254.00, 355.60}}, + {"media.na_10x15_10x15in", {254.00, 381.00}}, + {"media.na_11x12_11x12in", {279.40, 304.80}}, + {"media.na_11x15_11x15in", {279.40, 381.00}}, + {"media.na_12x19_12x19in", {304.80, 482.60}}, + {"media.na_5x7_5x7in", {127.00, 177.80}}, + {"media.na_6x9_6x9in", {152.40, 228.60}}, + {"media.na_7x9_7x9in", {177.80, 228.60}}, + {"media.na_9x11_9x11in", {228.60, 279.40}}, + {"media.na_a2_4.375x5.75in", {111.12, 146.05}}, + {"media.na_arch-a_9x12in", {228.60, 304.80}}, + {"media.na_arch-b_12x18in", {304.80, 457.20}}, + {"media.na_arch-c_18x24in", {457.20, 609.60}}, + {"media.na_arch-d_24x36in", {609.60, 914.40}}, + {"media.na_arch-e2_26x38in", {660.40, 965.20}}, + {"media.na_arch-e3_27x39in", {685.80, 990.60}}, + {"media.na_arch-e_36x48in", {914.40, 1219.20}}, + {"media.na_b-plus_12x19.17in", {304.80, 486.92}}, + {"media.na_c5_6.5x9.5in", {165.10, 241.30}}, + {"media.na_c_17x22in", {431.80, 558.80}}, + {"media.na_d_22x34in", {558.80, 863.60}}, + {"media.na_e_34x44in", {863.60, 1117.60}}, + {"media.na_edp_11x14in", {279.40, 355.60}}, + {"media.na_eur-edp_12x14in", {304.80, 355.60}}, + {"media.na_executive_7.25x10.5in", {184.15, 266.70}}, + {"media.na_f_44x68in", {1117.60, 1727.20}}, + {"media.na_fanfold-eur_8.5x12in", {215.90, 304.80}}, + {"media.na_fanfold-us_11x14.875in", {279.40, 377.82}}, + {"media.na_foolscap_8.5x13in", {215.90, 330.20}}, + {"media.na_govt-legal_8x13in", {203.20, 330.20}}, + {"media.na_govt-letter_8x10in", {203.20, 254.00}}, + {"media.na_index-3x5_3x5in", {76.20, 127.00}}, + {"media.na_index-4x6-ext_6x8in", {152.40, 203.20}}, + {"media.na_index-4x6_4x6in", {101.60, 152.40}}, + {"media.na_index-5x8_5x8in", {127.00, 203.20}}, + {"media.na_invoice_5.5x8.5in", {139.70, 215.90}}, + {"media.na_ledger_11x17in", {279.40, 431.80}}, + {"media.na_legal-extra_9.5x15in", {241.30, 381.00}}, + {"media.na_legal_8.5x14in", {215.90, 355.60}}, + {"media.na_letter-extra_9.5x12in", {241.30, 304.80}}, + {"media.na_letter-plus_8.5x12.69in", {215.90, 322.33}}, + {"media.na_letter_8.5x11in", {215.90, 279.40}}, + {"media.na_monarch_3.875x7.5in", {98.42, 190.50}}, + {"media.na_number-10_4.125x9.5in", {104.77, 241.30}}, + {"media.na_number-11_4.5x10.375in", {114.30, 263.52}}, + {"media.na_number-12_4.75x11in", {120.65, 279.40}}, + {"media.na_number-14_5x11.5in", {127.00, 292.10}}, + {"media.na_number-9_3.875x8.875in", {98.42, 225.42}}, + {"media.na_oficio_8.5x13.4in", {215.90, 340.36}}, + {"media.na_personal_3.625x6.5in", {92.07, 165.10}}, + {"media.na_quarto_8.5x10.83in", {215.90, 275.08}}, + {"media.na_super-a_8.94x14in", {227.08, 355.60}}, + {"media.na_super-b_13x19in", {330.20, 482.60}}, + {"media.na_wide-format_30x42in", {762.00, 1066.80}}, + {"media.oe_12x16_12x16in", {304.80, 406.40}}, + {"media.oe_14x17_14x17in", {355.60, 431.80}}, + {"media.oe_18x22_18x22in", {457.20, 558.80}}, + {"media.oe_a2plus_17x24in", {431.80, 609.60}}, + {"media.oe_business-card_2x3.5in", {50.80, 88.90}}, + {"media.oe_photo-10r_10x12in", {254.00, 304.80}}, + {"media.oe_photo-20r_20x24in", {508.00, 609.60}}, + {"media.oe_photo-l_3.5x5in", {88.90, 127.00}}, + {"media.oe_photo-s10r_10x15in", {254.00, 381.00}}, + {"media.oe_square-photo_4x4in", {101.60, 101.60}}, + {"media.oe_square-photo_5x5in", {127.00, 127.00}}, + {"media.om_16k_184x260mm", {184.00, 260.00}}, + {"media.om_16k_195x270mm", {195.00, 270.00}}, + {"media.om_business-card_55x85mm", {55.00, 85.00}}, + {"media.om_business-card_55x91mm", {55.00, 91.00}}, + {"media.om_card_54x86mm", {54.00, 86.00}}, + {"media.om_dai-pa-kai_275x395mm", {275.00, 395.00}}, + {"media.om_dsc-photo_89x119mm", {89.00, 119.00}}, + {"media.om_folio-sp_215x315mm", {215.00, 315.00}}, + {"media.om_folio_210x330mm", {210.00, 330.00}}, + {"media.om_invite_220x220mm", {220.00, 220.00}}, + {"media.om_italian_110x230mm", {110.00, 230.00}}, + {"media.om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, + {"media.om_large-photo_200x300", {200.00, 300.00}}, + {"media.om_medium-photo_130x180mm", {130.00, 180.00}}, + {"media.om_pa-kai_267x389mm", {267.00, 389.00}}, + {"media.om_postfix_114x229mm", {114.00, 229.00}}, + {"media.om_small-photo_100x150mm", {100.00, 150.00}}, + {"media.om_square-photo_89x89mm", {89.00, 89.00}}, + {"media.om_wide-photo_100x200mm", {100.00, 200.00}}, + {"media.prc_10_324x458mm", {324.00, 458.00}}, + {"media.prc_16k_146x215mm", {146.00, 215.00}}, + {"media.prc_1_102x165mm", {102.00, 165.00}}, + {"media.prc_2_102x176mm", {102.00, 176.00}}, + {"media.prc_32k_97x151mm", {97.00, 151.00}}, + {"media.prc_3_125x176mm", {125.00, 176.00}}, + {"media.prc_4_110x208mm", {110.00, 208.00}}, + {"media.prc_5_110x220mm", {110.00, 220.00}}, + {"media.prc_6_120x320mm", {120.00, 320.00}}, + {"media.prc_7_160x230mm", {160.00, 230.00}}, + {"media.prc_8_120x309mm", {120.00, 309.00}}, + {"media.roc_16k_7.75x10.75in", {196.85, 273.05}}, + {"media.roc_8k_10.75x15.5in", {273.05, 393.70}}}; #endif // PAPERSIZES_H From 4e03601b5c731fb606c5b7a9f817569dce393732 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 17 May 2020 12:18:27 +0200 Subject: [PATCH 56/94] Actually fix paper sizes --- src/papersizes.h | 400 +++++++++++++++++++++++------------------------ 1 file changed, 200 insertions(+), 200 deletions(-) diff --git a/src/papersizes.h b/src/papersizes.h index e0a43d3..054b2a2 100644 --- a/src/papersizes.h +++ b/src/papersizes.h @@ -4,206 +4,206 @@ #include static QMap> PaperSizes = - {{"media.asme_f_28x40in", {711.20, 1016.00}}, - {"media.iso_2a0_1189x1682mm", {1189.00, 1682.00}}, - {"media.iso_a0_841x1189mm", {841.00, 1189.00}}, - {"media.iso_a0x3_1189x2523mm", {1189.00, 2523.00}}, - {"media.iso_a10_26x37mm", {26.00, 37.00}}, - {"media.iso_a1_594x841mm", {594.00, 841.00}}, - {"media.iso_a1x3_841x1783mm", {841.00, 1783.00}}, - {"media.iso_a1x4_841x2378mm", {841.00, 2378.00}}, - {"media.iso_a2_420x594mm", {420.00, 594.00}}, - {"media.iso_a2x3_594x1261mm", {594.00, 1261.00}}, - {"media.iso_a2x4_594x1682mm", {594.00, 1682.00}}, - {"media.iso_a2x5_594x2102mm", {594.00, 2102.00}}, - {"media.iso_a3-extra_322x445mm", {322.00, 445.00}}, - {"media.iso_a3_297x420mm", {297.00, 420.00}}, - {"media.iso_a3x3_420x891mm", {420.00, 891.00}}, - {"media.iso_a3x4_420x1189mm", {420.00, 1189.00}}, - {"media.iso_a3x5_420x1486mm", {420.00, 1486.00}}, - {"media.iso_a3x6_420x1783mm", {420.00, 1783.00}}, - {"media.iso_a3x7_420x2080mm", {420.00, 2080.00}}, - {"media.iso_a4-extra_235.5x322.3m", {235.50, 322.30}}, - {"media.iso_a4-tab_225x297mm", {225.00, 297.00}}, - {"media.iso_a4_210x297mm", {210.00, 297.00}}, - {"media.iso_a4x3_297x630mm", {297.00, 630.00}}, - {"media.iso_a4x4_297x841mm", {297.00, 841.00}}, - {"media.iso_a4x5_297x1051mm", {297.00, 1051.00}}, - {"media.iso_a4x6_297x1261mm", {297.00, 1261.00}}, - {"media.iso_a4x7_297x1471mm", {297.00, 1471.00}}, - {"media.iso_a4x8_297x1682mm", {297.00, 1682.00}}, - {"media.iso_a4x9_297x1892mm", {297.00, 1892.00}}, - {"media.iso_a5-extra_174x235mm", {174.00, 235.00}}, - {"media.iso_a5_148x210mm", {148.00, 210.00}}, - {"media.iso_a6_105x148mm", {105.00, 148.00}}, - {"media.iso_a7_74x105mm", {74.00, 105.00}}, - {"media.iso_a8_52x74mm", {52.00, 74.00}}, - {"media.iso_a9_37x52mm", {37.00, 52.00}}, - {"media.iso_b0_1000x1414mm", {1000.00, 1414.00}}, - {"media.iso_b10_31x44mm", {31.00, 44.00}}, - {"media.iso_b1_707x1000mm", {707.00, 1000.00}}, - {"media.iso_b2_500x707mm", {500.00, 707.00}}, - {"media.iso_b3_353x500mm", {353.00, 500.00}}, - {"media.iso_b4_250x353mm", {250.00, 353.00}}, - {"media.iso_b5-extra_201x276mm", {201.00, 276.00}}, - {"media.iso_b5_176x250mm", {176.00, 250.00}}, - {"media.iso_b6_125x176mm", {125.00, 176.00}}, - {"media.iso_b6c4_125x324mm", {125.00, 324.00}}, - {"media.iso_b7_88x125mm", {88.00, 125.00}}, - {"media.iso_b8_62x88mm", {62.00, 88.00}}, - {"media.iso_b9_44x62mm", {44.00, 62.00}}, - {"media.iso_c0_917x1297mm", {917.00, 1297.00}}, - {"media.iso_c10_28x40mm", {28.00, 40.00}}, - {"media.iso_c1_648x917mm", {648.00, 917.00}}, - {"media.iso_c2_458x648mm", {458.00, 648.00}}, - {"media.iso_c3_324x458mm", {324.00, 458.00}}, - {"media.iso_c4_229x324mm", {229.00, 324.00}}, - {"media.iso_c5_162x229mm", {162.00, 229.00}}, - {"media.iso_c6_114x162mm", {114.00, 162.00}}, - {"media.iso_c6c5_114x229mm", {114.00, 229.00}}, - {"media.iso_c7_81x114mm", {81.00, 114.00}}, - {"media.iso_c7c6_81x162mm", {81.00, 162.00}}, - {"media.iso_c8_57x81mm", {57.00, 81.00}}, - {"media.iso_c9_40x57mm", {40.00, 57.00}}, - {"media.iso_dl_110x220mm", {110.00, 220.00}}, - {"media.iso_id-1_53.98x85.6mm", {53.98, 85.60}}, - {"media.iso_id-3_88x125mm", {88.00, 125.00}}, - {"media.iso_ra0_860x1220mm", {860.00, 1220.00}}, - {"media.iso_ra1_610x860mm", {610.00, 860.00}}, - {"media.iso_ra2_430x610mm", {430.00, 610.00}}, - {"media.iso_ra3_305x430mm", {305.00, 430.00}}, - {"media.iso_ra4_215x305mm", {215.00, 305.00}}, - {"media.iso_sra0_900x1280mm", {900.00, 1280.00}}, - {"media.iso_sra1_640x900mm", {640.00, 900.00}}, - {"media.iso_sra2_450x640mm", {450.00, 640.00}}, - {"media.iso_sra3_320x450mm", {320.00, 450.00}}, - {"media.iso_sra4_225x320mm", {225.00, 320.00}}, - {"media.jis_b0_1030x1456mm", {1030.00, 1456.00}}, - {"media.jis_b10_32x45mm", {32.00, 45.00}}, - {"media.jis_b1_728x1030mm", {728.00, 1030.00}}, - {"media.jis_b2_515x728mm", {515.00, 728.00}}, - {"media.jis_b3_364x515mm", {364.00, 515.00}}, - {"media.jis_b4_257x364mm", {257.00, 364.00}}, - {"media.jis_b5_182x257mm", {182.00, 257.00}}, - {"media.jis_b6_128x182mm", {128.00, 182.00}}, - {"media.jis_b7_91x128mm", {91.00, 128.00}}, - {"media.jis_b8_64x91mm", {64.00, 91.00}}, - {"media.jis_b9_45x64mm", {45.00, 64.00}}, - {"media.jis_exec_216x330mm", {216.00, 330.00}}, - {"media.jpn_chou2_111.1x146mm", {111.10, 146.00}}, - {"media.jpn_chou3_120x235mm", {120.00, 235.00}}, - {"media.jpn_chou40_90x225mm", {90.00, 225.00}}, - {"media.jpn_chou4_90x205mm", {90.00, 205.00}}, - {"media.jpn_hagaki_100x148mm", {100.00, 148.00}}, - {"media.jpn_kahu_240x322.1mm", {240.00, 322.10}}, - {"media.jpn_kaku1_270x382mm", {270.00, 382.00}}, - {"media.jpn_kaku2_240x332mm", {240.00, 332.00}}, - {"media.jpn_kaku3_216x277mm", {216.00, 277.00}}, - {"media.jpn_kaku4_197x267mm", {197.00, 267.00}}, - {"media.jpn_kaku5_190x240mm", {190.00, 240.00}}, - {"media.jpn_kaku7_142x205mm", {142.00, 205.00}}, - {"media.jpn_kaku8_119x197mm", {119.00, 197.00}}, - {"media.jpn_oufuku_148x200mm", {148.00, 200.00}}, - {"media.jpn_you4_105x235mm", {105.00, 235.00}}, - {"media.na_10x11_10x11in", {254.00, 279.40}}, - {"media.na_10x13_10x13in", {254.00, 330.20}}, - {"media.na_10x14_10x14in", {254.00, 355.60}}, - {"media.na_10x15_10x15in", {254.00, 381.00}}, - {"media.na_11x12_11x12in", {279.40, 304.80}}, - {"media.na_11x15_11x15in", {279.40, 381.00}}, - {"media.na_12x19_12x19in", {304.80, 482.60}}, - {"media.na_5x7_5x7in", {127.00, 177.80}}, - {"media.na_6x9_6x9in", {152.40, 228.60}}, - {"media.na_7x9_7x9in", {177.80, 228.60}}, - {"media.na_9x11_9x11in", {228.60, 279.40}}, - {"media.na_a2_4.375x5.75in", {111.12, 146.05}}, - {"media.na_arch-a_9x12in", {228.60, 304.80}}, - {"media.na_arch-b_12x18in", {304.80, 457.20}}, - {"media.na_arch-c_18x24in", {457.20, 609.60}}, - {"media.na_arch-d_24x36in", {609.60, 914.40}}, - {"media.na_arch-e2_26x38in", {660.40, 965.20}}, - {"media.na_arch-e3_27x39in", {685.80, 990.60}}, - {"media.na_arch-e_36x48in", {914.40, 1219.20}}, - {"media.na_b-plus_12x19.17in", {304.80, 486.92}}, - {"media.na_c5_6.5x9.5in", {165.10, 241.30}}, - {"media.na_c_17x22in", {431.80, 558.80}}, - {"media.na_d_22x34in", {558.80, 863.60}}, - {"media.na_e_34x44in", {863.60, 1117.60}}, - {"media.na_edp_11x14in", {279.40, 355.60}}, - {"media.na_eur-edp_12x14in", {304.80, 355.60}}, - {"media.na_executive_7.25x10.5in", {184.15, 266.70}}, - {"media.na_f_44x68in", {1117.60, 1727.20}}, - {"media.na_fanfold-eur_8.5x12in", {215.90, 304.80}}, - {"media.na_fanfold-us_11x14.875in", {279.40, 377.82}}, - {"media.na_foolscap_8.5x13in", {215.90, 330.20}}, - {"media.na_govt-legal_8x13in", {203.20, 330.20}}, - {"media.na_govt-letter_8x10in", {203.20, 254.00}}, - {"media.na_index-3x5_3x5in", {76.20, 127.00}}, - {"media.na_index-4x6-ext_6x8in", {152.40, 203.20}}, - {"media.na_index-4x6_4x6in", {101.60, 152.40}}, - {"media.na_index-5x8_5x8in", {127.00, 203.20}}, - {"media.na_invoice_5.5x8.5in", {139.70, 215.90}}, - {"media.na_ledger_11x17in", {279.40, 431.80}}, - {"media.na_legal-extra_9.5x15in", {241.30, 381.00}}, - {"media.na_legal_8.5x14in", {215.90, 355.60}}, - {"media.na_letter-extra_9.5x12in", {241.30, 304.80}}, - {"media.na_letter-plus_8.5x12.69in", {215.90, 322.33}}, - {"media.na_letter_8.5x11in", {215.90, 279.40}}, - {"media.na_monarch_3.875x7.5in", {98.42, 190.50}}, - {"media.na_number-10_4.125x9.5in", {104.77, 241.30}}, - {"media.na_number-11_4.5x10.375in", {114.30, 263.52}}, - {"media.na_number-12_4.75x11in", {120.65, 279.40}}, - {"media.na_number-14_5x11.5in", {127.00, 292.10}}, - {"media.na_number-9_3.875x8.875in", {98.42, 225.42}}, - {"media.na_oficio_8.5x13.4in", {215.90, 340.36}}, - {"media.na_personal_3.625x6.5in", {92.07, 165.10}}, - {"media.na_quarto_8.5x10.83in", {215.90, 275.08}}, - {"media.na_super-a_8.94x14in", {227.08, 355.60}}, - {"media.na_super-b_13x19in", {330.20, 482.60}}, - {"media.na_wide-format_30x42in", {762.00, 1066.80}}, - {"media.oe_12x16_12x16in", {304.80, 406.40}}, - {"media.oe_14x17_14x17in", {355.60, 431.80}}, - {"media.oe_18x22_18x22in", {457.20, 558.80}}, - {"media.oe_a2plus_17x24in", {431.80, 609.60}}, - {"media.oe_business-card_2x3.5in", {50.80, 88.90}}, - {"media.oe_photo-10r_10x12in", {254.00, 304.80}}, - {"media.oe_photo-20r_20x24in", {508.00, 609.60}}, - {"media.oe_photo-l_3.5x5in", {88.90, 127.00}}, - {"media.oe_photo-s10r_10x15in", {254.00, 381.00}}, - {"media.oe_square-photo_4x4in", {101.60, 101.60}}, - {"media.oe_square-photo_5x5in", {127.00, 127.00}}, - {"media.om_16k_184x260mm", {184.00, 260.00}}, - {"media.om_16k_195x270mm", {195.00, 270.00}}, - {"media.om_business-card_55x85mm", {55.00, 85.00}}, - {"media.om_business-card_55x91mm", {55.00, 91.00}}, - {"media.om_card_54x86mm", {54.00, 86.00}}, - {"media.om_dai-pa-kai_275x395mm", {275.00, 395.00}}, - {"media.om_dsc-photo_89x119mm", {89.00, 119.00}}, - {"media.om_folio-sp_215x315mm", {215.00, 315.00}}, - {"media.om_folio_210x330mm", {210.00, 330.00}}, - {"media.om_invite_220x220mm", {220.00, 220.00}}, - {"media.om_italian_110x230mm", {110.00, 230.00}}, - {"media.om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, - {"media.om_large-photo_200x300", {200.00, 300.00}}, - {"media.om_medium-photo_130x180mm", {130.00, 180.00}}, - {"media.om_pa-kai_267x389mm", {267.00, 389.00}}, - {"media.om_postfix_114x229mm", {114.00, 229.00}}, - {"media.om_small-photo_100x150mm", {100.00, 150.00}}, - {"media.om_square-photo_89x89mm", {89.00, 89.00}}, - {"media.om_wide-photo_100x200mm", {100.00, 200.00}}, - {"media.prc_10_324x458mm", {324.00, 458.00}}, - {"media.prc_16k_146x215mm", {146.00, 215.00}}, - {"media.prc_1_102x165mm", {102.00, 165.00}}, - {"media.prc_2_102x176mm", {102.00, 176.00}}, - {"media.prc_32k_97x151mm", {97.00, 151.00}}, - {"media.prc_3_125x176mm", {125.00, 176.00}}, - {"media.prc_4_110x208mm", {110.00, 208.00}}, - {"media.prc_5_110x220mm", {110.00, 220.00}}, - {"media.prc_6_120x320mm", {120.00, 320.00}}, - {"media.prc_7_160x230mm", {160.00, 230.00}}, - {"media.prc_8_120x309mm", {120.00, 309.00}}, - {"media.roc_16k_7.75x10.75in", {196.85, 273.05}}, - {"media.roc_8k_10.75x15.5in", {273.05, 393.70}}}; + {{"asme_f_28x40in", {711.20, 1016.00}}, + {"iso_2a0_1189x1682mm", {1189.00, 1682.00}}, + {"iso_a0_841x1189mm", {841.00, 1189.00}}, + {"iso_a0x3_1189x2523mm", {1189.00, 2523.00}}, + {"iso_a10_26x37mm", {26.00, 37.00}}, + {"iso_a1_594x841mm", {594.00, 841.00}}, + {"iso_a1x3_841x1783mm", {841.00, 1783.00}}, + {"iso_a1x4_841x2378mm", {841.00, 2378.00}}, + {"iso_a2_420x594mm", {420.00, 594.00}}, + {"iso_a2x3_594x1261mm", {594.00, 1261.00}}, + {"iso_a2x4_594x1682mm", {594.00, 1682.00}}, + {"iso_a2x5_594x2102mm", {594.00, 2102.00}}, + {"iso_a3-extra_322x445mm", {322.00, 445.00}}, + {"iso_a3_297x420mm", {297.00, 420.00}}, + {"iso_a3x3_420x891mm", {420.00, 891.00}}, + {"iso_a3x4_420x1189mm", {420.00, 1189.00}}, + {"iso_a3x5_420x1486mm", {420.00, 1486.00}}, + {"iso_a3x6_420x1783mm", {420.00, 1783.00}}, + {"iso_a3x7_420x2080mm", {420.00, 2080.00}}, + {"iso_a4-extra_235.5x322.3m", {235.50, 322.30}}, + {"iso_a4-tab_225x297mm", {225.00, 297.00}}, + {"iso_a4_210x297mm", {210.00, 297.00}}, + {"iso_a4x3_297x630mm", {297.00, 630.00}}, + {"iso_a4x4_297x841mm", {297.00, 841.00}}, + {"iso_a4x5_297x1051mm", {297.00, 1051.00}}, + {"iso_a4x6_297x1261mm", {297.00, 1261.00}}, + {"iso_a4x7_297x1471mm", {297.00, 1471.00}}, + {"iso_a4x8_297x1682mm", {297.00, 1682.00}}, + {"iso_a4x9_297x1892mm", {297.00, 1892.00}}, + {"iso_a5-extra_174x235mm", {174.00, 235.00}}, + {"iso_a5_148x210mm", {148.00, 210.00}}, + {"iso_a6_105x148mm", {105.00, 148.00}}, + {"iso_a7_74x105mm", {74.00, 105.00}}, + {"iso_a8_52x74mm", {52.00, 74.00}}, + {"iso_a9_37x52mm", {37.00, 52.00}}, + {"iso_b0_1000x1414mm", {1000.00, 1414.00}}, + {"iso_b10_31x44mm", {31.00, 44.00}}, + {"iso_b1_707x1000mm", {707.00, 1000.00}}, + {"iso_b2_500x707mm", {500.00, 707.00}}, + {"iso_b3_353x500mm", {353.00, 500.00}}, + {"iso_b4_250x353mm", {250.00, 353.00}}, + {"iso_b5-extra_201x276mm", {201.00, 276.00}}, + {"iso_b5_176x250mm", {176.00, 250.00}}, + {"iso_b6_125x176mm", {125.00, 176.00}}, + {"iso_b6c4_125x324mm", {125.00, 324.00}}, + {"iso_b7_88x125mm", {88.00, 125.00}}, + {"iso_b8_62x88mm", {62.00, 88.00}}, + {"iso_b9_44x62mm", {44.00, 62.00}}, + {"iso_c0_917x1297mm", {917.00, 1297.00}}, + {"iso_c10_28x40mm", {28.00, 40.00}}, + {"iso_c1_648x917mm", {648.00, 917.00}}, + {"iso_c2_458x648mm", {458.00, 648.00}}, + {"iso_c3_324x458mm", {324.00, 458.00}}, + {"iso_c4_229x324mm", {229.00, 324.00}}, + {"iso_c5_162x229mm", {162.00, 229.00}}, + {"iso_c6_114x162mm", {114.00, 162.00}}, + {"iso_c6c5_114x229mm", {114.00, 229.00}}, + {"iso_c7_81x114mm", {81.00, 114.00}}, + {"iso_c7c6_81x162mm", {81.00, 162.00}}, + {"iso_c8_57x81mm", {57.00, 81.00}}, + {"iso_c9_40x57mm", {40.00, 57.00}}, + {"iso_dl_110x220mm", {110.00, 220.00}}, + {"iso_id-1_53.98x85.6mm", {53.98, 85.60}}, + {"iso_id-3_88x125mm", {88.00, 125.00}}, + {"iso_ra0_860x1220mm", {860.00, 1220.00}}, + {"iso_ra1_610x860mm", {610.00, 860.00}}, + {"iso_ra2_430x610mm", {430.00, 610.00}}, + {"iso_ra3_305x430mm", {305.00, 430.00}}, + {"iso_ra4_215x305mm", {215.00, 305.00}}, + {"iso_sra0_900x1280mm", {900.00, 1280.00}}, + {"iso_sra1_640x900mm", {640.00, 900.00}}, + {"iso_sra2_450x640mm", {450.00, 640.00}}, + {"iso_sra3_320x450mm", {320.00, 450.00}}, + {"iso_sra4_225x320mm", {225.00, 320.00}}, + {"jis_b0_1030x1456mm", {1030.00, 1456.00}}, + {"jis_b10_32x45mm", {32.00, 45.00}}, + {"jis_b1_728x1030mm", {728.00, 1030.00}}, + {"jis_b2_515x728mm", {515.00, 728.00}}, + {"jis_b3_364x515mm", {364.00, 515.00}}, + {"jis_b4_257x364mm", {257.00, 364.00}}, + {"jis_b5_182x257mm", {182.00, 257.00}}, + {"jis_b6_128x182mm", {128.00, 182.00}}, + {"jis_b7_91x128mm", {91.00, 128.00}}, + {"jis_b8_64x91mm", {64.00, 91.00}}, + {"jis_b9_45x64mm", {45.00, 64.00}}, + {"jis_exec_216x330mm", {216.00, 330.00}}, + {"jpn_chou2_111.1x146mm", {111.10, 146.00}}, + {"jpn_chou3_120x235mm", {120.00, 235.00}}, + {"jpn_chou40_90x225mm", {90.00, 225.00}}, + {"jpn_chou4_90x205mm", {90.00, 205.00}}, + {"jpn_hagaki_100x148mm", {100.00, 148.00}}, + {"jpn_kahu_240x322.1mm", {240.00, 322.10}}, + {"jpn_kaku1_270x382mm", {270.00, 382.00}}, + {"jpn_kaku2_240x332mm", {240.00, 332.00}}, + {"jpn_kaku3_216x277mm", {216.00, 277.00}}, + {"jpn_kaku4_197x267mm", {197.00, 267.00}}, + {"jpn_kaku5_190x240mm", {190.00, 240.00}}, + {"jpn_kaku7_142x205mm", {142.00, 205.00}}, + {"jpn_kaku8_119x197mm", {119.00, 197.00}}, + {"jpn_oufuku_148x200mm", {148.00, 200.00}}, + {"jpn_you4_105x235mm", {105.00, 235.00}}, + {"na_10x11_10x11in", {254.00, 279.40}}, + {"na_10x13_10x13in", {254.00, 330.20}}, + {"na_10x14_10x14in", {254.00, 355.60}}, + {"na_10x15_10x15in", {254.00, 381.00}}, + {"na_11x12_11x12in", {279.40, 304.80}}, + {"na_11x15_11x15in", {279.40, 381.00}}, + {"na_12x19_12x19in", {304.80, 482.60}}, + {"na_5x7_5x7in", {127.00, 177.80}}, + {"na_6x9_6x9in", {152.40, 228.60}}, + {"na_7x9_7x9in", {177.80, 228.60}}, + {"na_9x11_9x11in", {228.60, 279.40}}, + {"na_a2_4.375x5.75in", {111.12, 146.05}}, + {"na_arch-a_9x12in", {228.60, 304.80}}, + {"na_arch-b_12x18in", {304.80, 457.20}}, + {"na_arch-c_18x24in", {457.20, 609.60}}, + {"na_arch-d_24x36in", {609.60, 914.40}}, + {"na_arch-e2_26x38in", {660.40, 965.20}}, + {"na_arch-e3_27x39in", {685.80, 990.60}}, + {"na_arch-e_36x48in", {914.40, 1219.20}}, + {"na_b-plus_12x19.17in", {304.80, 486.92}}, + {"na_c5_6.5x9.5in", {165.10, 241.30}}, + {"na_c_17x22in", {431.80, 558.80}}, + {"na_d_22x34in", {558.80, 863.60}}, + {"na_e_34x44in", {863.60, 1117.60}}, + {"na_edp_11x14in", {279.40, 355.60}}, + {"na_eur-edp_12x14in", {304.80, 355.60}}, + {"na_executive_7.25x10.5in", {184.15, 266.70}}, + {"na_f_44x68in", {1117.60, 1727.20}}, + {"na_fanfold-eur_8.5x12in", {215.90, 304.80}}, + {"na_fanfold-us_11x14.875in", {279.40, 377.82}}, + {"na_foolscap_8.5x13in", {215.90, 330.20}}, + {"na_govt-legal_8x13in", {203.20, 330.20}}, + {"na_govt-letter_8x10in", {203.20, 254.00}}, + {"na_index-3x5_3x5in", {76.20, 127.00}}, + {"na_index-4x6-ext_6x8in", {152.40, 203.20}}, + {"na_index-4x6_4x6in", {101.60, 152.40}}, + {"na_index-5x8_5x8in", {127.00, 203.20}}, + {"na_invoice_5.5x8.5in", {139.70, 215.90}}, + {"na_ledger_11x17in", {279.40, 431.80}}, + {"na_legal-extra_9.5x15in", {241.30, 381.00}}, + {"na_legal_8.5x14in", {215.90, 355.60}}, + {"na_letter-extra_9.5x12in", {241.30, 304.80}}, + {"na_letter-plus_8.5x12.69in", {215.90, 322.33}}, + {"na_letter_8.5x11in", {215.90, 279.40}}, + {"na_monarch_3.875x7.5in", {98.42, 190.50}}, + {"na_number-10_4.125x9.5in", {104.77, 241.30}}, + {"na_number-11_4.5x10.375in", {114.30, 263.52}}, + {"na_number-12_4.75x11in", {120.65, 279.40}}, + {"na_number-14_5x11.5in", {127.00, 292.10}}, + {"na_number-9_3.875x8.875in", {98.42, 225.42}}, + {"na_oficio_8.5x13.4in", {215.90, 340.36}}, + {"na_personal_3.625x6.5in", {92.07, 165.10}}, + {"na_quarto_8.5x10.83in", {215.90, 275.08}}, + {"na_super-a_8.94x14in", {227.08, 355.60}}, + {"na_super-b_13x19in", {330.20, 482.60}}, + {"na_wide-format_30x42in", {762.00, 1066.80}}, + {"oe_12x16_12x16in", {304.80, 406.40}}, + {"oe_14x17_14x17in", {355.60, 431.80}}, + {"oe_18x22_18x22in", {457.20, 558.80}}, + {"oe_a2plus_17x24in", {431.80, 609.60}}, + {"oe_business-card_2x3.5in", {50.80, 88.90}}, + {"oe_photo-10r_10x12in", {254.00, 304.80}}, + {"oe_photo-20r_20x24in", {508.00, 609.60}}, + {"oe_photo-l_3.5x5in", {88.90, 127.00}}, + {"oe_photo-s10r_10x15in", {254.00, 381.00}}, + {"oe_square-photo_4x4in", {101.60, 101.60}}, + {"oe_square-photo_5x5in", {127.00, 127.00}}, + {"om_16k_184x260mm", {184.00, 260.00}}, + {"om_16k_195x270mm", {195.00, 270.00}}, + {"om_business-card_55x85mm", {55.00, 85.00}}, + {"om_business-card_55x91mm", {55.00, 91.00}}, + {"om_card_54x86mm", {54.00, 86.00}}, + {"om_dai-pa-kai_275x395mm", {275.00, 395.00}}, + {"om_dsc-photo_89x119mm", {89.00, 119.00}}, + {"om_folio-sp_215x315mm", {215.00, 315.00}}, + {"om_folio_210x330mm", {210.00, 330.00}}, + {"om_invite_220x220mm", {220.00, 220.00}}, + {"om_italian_110x230mm", {110.00, 230.00}}, + {"om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, + {"om_large-photo_200x300", {200.00, 3.00}}, + {"om_medium-photo_130x180mm", {130.00, 180.00}}, + {"om_pa-kai_267x389mm", {267.00, 389.00}}, + {"om_postfix_114x229mm", {114.00, 229.00}}, + {"om_small-photo_100x150mm", {100.00, 150.00}}, + {"om_square-photo_89x89mm", {89.00, 89.00}}, + {"om_wide-photo_100x200mm", {100.00, 200.00}}, + {"prc_10_324x458mm", {324.00, 458.00}}, + {"prc_16k_146x215mm", {146.00, 215.00}}, + {"prc_1_102x165mm", {102.00, 165.00}}, + {"prc_2_102x176mm", {102.00, 176.00}}, + {"prc_32k_97x151mm", {97.00, 151.00}}, + {"prc_3_125x176mm", {125.00, 176.00}}, + {"prc_4_110x208mm", {110.00, 208.00}}, + {"prc_5_110x220mm", {110.00, 220.00}}, + {"prc_6_120x320mm", {120.00, 320.00}}, + {"prc_7_160x230mm", {160.00, 230.00}}, + {"prc_8_120x309mm", {120.00, 309.00}}, + {"roc_16k_7.75x10.75in", {196.85, 273.05}}, + {"roc_8k_10.75x15.5in", {273.05, 393.70}}}; #endif // PAPERSIZES_H From ad14386b537d76d3720c5b6eaba898ebe1eb6566 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 17 May 2020 12:30:54 +0200 Subject: [PATCH 57/94] Show more error messages --- qml/pages/BusyPage.qml | 7 +++++-- translations/harbour-seaprint-de.ts | 8 ++++---- translations/harbour-seaprint-es.ts | 8 ++++---- translations/harbour-seaprint-fr.ts | 8 ++++---- translations/harbour-seaprint-zh_CN.ts | 8 ++++---- translations/harbour-seaprint.ts | 8 ++++---- 6 files changed, 25 insertions(+), 22 deletions(-) diff --git a/qml/pages/BusyPage.qml b/qml/pages/BusyPage.qml index 3a32f14..25fc3fc 100644 --- a/qml/pages/BusyPage.qml +++ b/qml/pages/BusyPage.qml @@ -8,11 +8,14 @@ Page { Connections { target: printer onJobFinished: { - var msg = "" + var msg = qsTr("Unknown") if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") { msg = printer.jobAttrs["job-state-message"].value } - else if (printer.jobAttrs.hasOwnProperty("job-state")) { + else if (printer.jobAttrs.hasOwnProperty("status-message") && printer.jobAttrs["status-message"].value != "") { + msg = printer.jobAttrs["status-message"].value + } + else if (printer.jobAttrs.hasOwnProperty("job-state") && printer.jobAttrs["job-state"].value != "") { msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value) } pageStack.pop() diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 6edc3c7..86bc120 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -71,10 +71,6 @@ Optional dependencies - - pdftoppm (from poppler-utils) - - Installed @@ -117,6 +113,10 @@ Print failed: + + Unknown + + ConvertWorker diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 8cd54a5..539425a 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -71,10 +71,6 @@ Optional dependencies - - pdftoppm (from poppler-utils) - - Installed @@ -117,6 +113,10 @@ Print failed: Impresión fallida: + + Unknown + + ConvertWorker diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index bca0d34..7e68313 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -71,10 +71,6 @@ Optional dependencies - - pdftoppm (from poppler-utils) - - Installed @@ -117,6 +113,10 @@ Print failed: Échec de l'impression : + + Unknown + Inconnu + ConvertWorker diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 9d0b14d..51da42c 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -71,10 +71,6 @@ Optional dependencies - - pdftoppm (from poppler-utils) - - Installed @@ -117,6 +113,10 @@ Print failed: 打印失败: + + Unknown + 未知 + ConvertWorker diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 60aa166..8813510 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -71,10 +71,6 @@ Optional dependencies - - pdftoppm (from poppler-utils) - - Installed @@ -117,6 +113,10 @@ Print failed: + + Unknown + + ConvertWorker From f7175298830357da388a4f4fde1d73409f91a729 Mon Sep 17 00:00:00 2001 From: Ville Nummela Date: Tue, 19 May 2020 17:06:56 +0300 Subject: [PATCH 58/94] IppMsg: Don't encode job attributes if there are none --- src/ippmsg.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index 654fe22..ad59572 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -199,12 +199,14 @@ QByteArray IppMsg::encode(Operation op) } for(QJsonArray::iterator ait = _jobAttrs.begin(); ait != _jobAttrs.end(); ait++) { - ipp << quint8(2); QJsonObject tmpObj = ait->toObject(); - for(QJsonObject::iterator it = tmpObj.begin(); it != tmpObj.end(); it++) - { - QJsonObject val = it.value().toObject(); - ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]); + if (!tmpObj.isEmpty()) { + ipp << quint8(2); + for(QJsonObject::iterator it = tmpObj.begin(); it != tmpObj.end(); it++) + { + QJsonObject val = it.value().toObject(); + ipp << encode_attr(val["tag"].toInt(), it.key(), val["value"]); + } } } From cd852a6e9f8167201980c85f1ce15caf2f704f47 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 20:21:09 +0200 Subject: [PATCH 59/94] Silence some string concatenation wanings --- src/ippprinter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 86e52d3..879fa18 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -99,7 +99,7 @@ void IppPrinter::refresh() { request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); QJsonObject o = opAttrs(); IppMsg msg = IppMsg(o); @@ -263,7 +263,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); Mimer* mimer = Mimer::instance(); @@ -382,7 +382,7 @@ bool IppPrinter::getJobs() { request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); _jobs_nam->post(request, contents); @@ -404,7 +404,7 @@ bool IppPrinter::cancelJob(qint32 jobId) { request.setUrl(httpUrl()); request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); - request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint "SEAPRINT_VERSION); + request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); _job_cancel_nam->post(request, contents); From 8e4d31be73767fc2bd0629a537d9f99f0b9560bd Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 20:47:27 +0200 Subject: [PATCH 60/94] IppPrinter: Add check for poorly advertised PDF support --- src/ippprinter.cpp | 22 +++++++++++++++++++++- src/ippprinter.h | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 879fa18..51c7426 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -228,6 +228,22 @@ void IppPrinter::convertFailed(QString message) emit jobFinished(false); } + +bool IppPrinter::hasPrinterDeviceIdCmd(QString cmd) +{ + QStringList printerDeviceId = _attrs["printer-device-id"].toObject()["value"].toString().split(";"); + for (QStringList::iterator it = printerDeviceId.begin(); it != printerDeviceId.end(); it++) + { + QStringList kv = it->split(":"); + if(kv.length()==2 && kv[0]=="CMD") + { + return kv[1].split(",").contains("PDF"); + } + } + return false; +} + + void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ qDebug() << "printing" << filename << attrs; @@ -283,7 +299,11 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - if(alwaysConvert || from == Image || (from == Pdf && !supportedMimeTypes.contains("application/pdf"))) + bool supportsPdf = supportedMimeTypes.contains("application/pdf") || hasPrinterDeviceIdCmd("PDF"); + + qDebug() << "supportsPdf" << supportsPdf; + + if(alwaysConvert || from == Image || (from == Pdf && !supportsPdf)) { if(supportedMimeTypes.contains("image/pwg-raster")) { diff --git a/src/ippprinter.h b/src/ippprinter.h index aa2e83c..34b76a4 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -29,6 +29,8 @@ public: Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool cancelJob(qint32 jobId); + bool hasPrinterDeviceIdCmd(QString cmd); + enum ConvertTarget { NoConvert, From 043ed36c070a3756be11a9d7fb0471ecb5cdbc9b Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 21:08:27 +0200 Subject: [PATCH 61/94] Update gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 5291a38..a3258b1 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ target_wrapper.* # QtCreator CMake CMakeLists.txt.user* + +# Automatically generated + +seaprint_version.h From a42dbbc68204ed6dbddc28139f6040215f2b8390 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 21:12:29 +0200 Subject: [PATCH 62/94] Make it possible to build in release mode --- src/convertworker.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 5390260..dc3dee2 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -1,6 +1,9 @@ #include "convertworker.h" #include #include "papersizes.h" +#include +#include +#include void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) From 2c1c6e4dc51eefd69d5a35ab260c11c60165219a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 21:56:47 +0200 Subject: [PATCH 63/94] Move URF resolution fix to IppPrinter ...so it can be sent in the attributes --- src/convertworker.cpp | 21 +++++++++++++-------- src/ippprinter.cpp | 17 +++++++++++++++++ translations/harbour-seaprint-de.ts | 4 ++++ translations/harbour-seaprint-es.ts | 4 ++++ translations/harbour-seaprint-fr.ts | 4 ++++ translations/harbour-seaprint-zh_CN.ts | 4 ++++ translations/harbour-seaprint.ts | 4 ++++ 7 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index dc3dee2..da082e7 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -35,15 +35,12 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo bool urf, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { - if(urf) + if(urf && (HwResX != HwResY)) { // URF only supports symmetric resolutions - if(HwResX < HwResY) - { - HwResY = HwResX; - } - else { - HwResX = HwResY; - } + qDebug() << "Unsupported URF resolution" << PaperSize; + tempfile->deleteLater(); + emit failed(tr("Unsupported resolution (dpi)")); + return; } QString ShortPaperSize; @@ -147,6 +144,14 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem bool urf, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY) { + if(urf && (HwResX != HwResY)) + { // URF only supports symmetric resolutions + qDebug() << "Unsupported URF resolution" << PaperSize; + tempfile->deleteLater(); + emit failed(tr("Unsupported resolution (dpi)")); + return; + } + if(!PaperSizes.contains(PaperSize)) { qDebug() << "Unsupported paper size" << PaperSize; diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 51c7426..ff17c05 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -319,6 +319,23 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ quint32 HwResX = PrinterResolutionRef.toObject()["x"].toInt(); quint32 HwResY = PrinterResolutionRef.toObject()["y"].toInt(); + if(target == UrfConvert) + { // Ensure symmetric resolution for URF + if(HwResX < HwResY) + { + HwResY = HwResX; + } + else + { + HwResX = HwResY; + } + QJsonObject tmpObj; + tmpObj["units"] = PrinterResolutionRef.toObject()["units"]; + tmpObj["x"] = (int)HwResX; + tmpObj["y"] = (int)HwResY; + attrs["printer-resolution"] = tmpObj; + } + quint32 Quality = getAttrOrDefault(attrs, "print-quality").toInt(); QString PrintColorMode = getAttrOrDefault(attrs, "print-color-mode").toString(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 86bc120..c36357f 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -136,6 +136,10 @@ Unsupported paper size + + Unsupported resolution (dpi) + + CoverPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 539425a..46aeab8 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -136,6 +136,10 @@ Unsupported paper size + + Unsupported resolution (dpi) + + CoverPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 7e68313..b112229 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -136,6 +136,10 @@ Unsupported paper size + + Unsupported resolution (dpi) + + CoverPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 51da42c..8a119d9 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -136,6 +136,10 @@ Unsupported paper size + + Unsupported resolution (dpi) + + CoverPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 8813510..a01287e 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -136,6 +136,10 @@ Unsupported paper size + + Unsupported resolution (dpi) + + CoverPage From d62f0c8a56bf241441253283c5395d5412014439 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 1 Jun 2020 22:05:43 +0200 Subject: [PATCH 64/94] Pretend status-message is a job attribue --- src/ippprinter.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index ff17c05..9dfe796 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -117,6 +117,11 @@ void IppPrinter::getPrinterAttributesFinished(QNetworkReply *reply) IppMsg resp(reply); qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getPrinterAttrs(); _attrs = resp.getPrinterAttrs(); + if(resp.getOpAttrs().keys().contains("status-message")) + { // Sometimes there are no response attributes at all, + // maybe status-message from the operation attributes is somewhat useful + _attrs["status-message"] = resp.getOpAttrs()["status-message"]; + } } catch(std::exception e) { From 1b1079b6797927ff625ba664cef0fc2b21010903 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Wed, 3 Jun 2020 20:42:18 +0200 Subject: [PATCH 65/94] Add transfer progress --- qml/pages/BusyPage.qml | 2 +- src/ippprinter.cpp | 21 ++++++++++++++++++--- src/ippprinter.h | 5 +++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/qml/pages/BusyPage.qml b/qml/pages/BusyPage.qml index 25fc3fc..a42fc3d 100644 --- a/qml/pages/BusyPage.qml +++ b/qml/pages/BusyPage.qml @@ -29,7 +29,7 @@ Page { } BusyLabel { - text: printer.busyMessage + text: printer.busyMessage+"\n"+printer.progress; running: true } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 9dfe796..cfaa209 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -10,10 +10,10 @@ IppPrinter::IppPrinter() _jobs_nam = new QNetworkAccessManager(this); _job_cancel_nam = new QNetworkAccessManager(this); - connect(_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(getPrinterAttributesFinished(QNetworkReply*))); + connect(_nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(getPrinterAttributesFinished(QNetworkReply*))); connect(_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); - connect(_print_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(printRequestFinished(QNetworkReply*))); + connect(_print_nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(printRequestFinished(QNetworkReply*))); connect(_print_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); connect(_jobs_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(getJobsRequestFinished(QNetworkReply*))); @@ -221,7 +221,9 @@ void IppPrinter::convertDone(QNetworkRequest request, QTemporaryFile* data) setBusyMessage("Transferring"); - _print_nam->post(request, data); + QNetworkReply* reply = _print_nam->post(request, data); + + connect(reply, &QNetworkReply::uploadProgress, this, &IppPrinter::setProgress); } @@ -252,6 +254,9 @@ bool IppPrinter::hasPrinterDeviceIdCmd(QString cmd) void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ qDebug() << "printing" << filename << attrs; + _progress = ""; + emit progressChanged(); + QFile file(filename); bool file_ok = file.open(QIODevice::ReadOnly); if(!file_ok) @@ -468,6 +473,16 @@ void IppPrinter::setBusyMessage(QString msg) emit busyMessageChanged(); } +void IppPrinter::setProgress(qint64 sent, qint64 total) +{ + if(total == 0) + return; + + _progress = QString::number(100*sent/total); + _progress += "%"; + emit progressChanged(); +} + QJsonValue IppPrinter::getAttrOrDefault(QJsonObject jobAttrs, QString name) { if(jobAttrs.contains(name)) diff --git a/src/ippprinter.h b/src/ippprinter.h index 34b76a4..26e1574 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -14,6 +14,7 @@ class IppPrinter : public QObject Q_PROPERTY(QJsonObject jobAttrs MEMBER _jobAttrs NOTIFY jobAttrsChanged) Q_PROPERTY(QJsonArray jobs MEMBER _jobs NOTIFY jobsChanged) Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged) + Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged) public: @@ -63,6 +64,7 @@ signals: quint32 HwResX, quint32 HwResY); void busyMessageChanged(); + void progressChanged(); public slots: void print(QJsonObject attrs, QString file, bool alwaysConvert); @@ -86,6 +88,8 @@ private: QJsonObject opAttrs(); void setBusyMessage(QString msg); + void setProgress(qint64 sent, qint64 total); + QJsonValue getAttrOrDefault(QJsonObject jobAttrs, QString name); QNetworkAccessManager* _nam; @@ -97,6 +101,7 @@ private: QJsonObject _jobAttrs; QJsonArray _jobs; QString _busyMessage; + QString _progress; QThread _workerThread; ConvertWorker* _worker; From 28bb06d18e33d8d670edd5f9e3fdf38bf08a5bd6 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Wed, 3 Jun 2020 20:42:46 +0200 Subject: [PATCH 66/94] Don't crash on decoding unsupported-attributes --- src/ippmsg.cpp | 8 +++++--- src/ippmsg.h | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ippmsg.cpp b/src/ippmsg.cpp index ad59572..a0da2f6 100644 --- a/src/ippmsg.cpp +++ b/src/ippmsg.cpp @@ -38,7 +38,7 @@ IppMsg::IppMsg(QNetworkReply* resp) while(!bts.atEnd()) { - if(bts.peekU8() <= IppTag::PrinterAttrs) { + if(bts.peekU8() <= IppTag::UnsupportedAttrs) { if(currentAttrType == IppTag::OpAttrs) { _opAttrs = attrs; @@ -49,6 +49,9 @@ IppMsg::IppMsg(QNetworkReply* resp) else if (currentAttrType == IppTag::PrinterAttrs) { _printerAttrs = attrs; } + else if (currentAttrType == IppTag::UnsupportedAttrs) { + qDebug() << "WARNING: unsupported attrs reported:" << attrs; + } if(bts >>= (uint8_t)IppTag::EndAttrs) { break; @@ -78,12 +81,12 @@ QString IppMsg::consume_attribute(QJsonObject& attrs, Bytestream& data, QString data/tmp_len >> tmp_str; name = tmp_str!="" ? tmp_str.c_str() : lastName; - switch (tag) { case OpAttrs: case JobAttrs: case EndAttrs: case PrinterAttrs: + case UnsupportedAttrs: Q_ASSERT(false); case Integer: case Enum: @@ -245,7 +248,6 @@ Bytestream IppMsg::encode_attr(quint8 tag, QString name, QJsonValueRef value) } case Resolution: { - qDebug() << value << value.toObject(); qint32 x = value.toObject()["x"].toInt(); qint32 y = value.toObject()["y"].toInt(); qint8 units = value.toObject()["units"].toInt(); diff --git a/src/ippmsg.h b/src/ippmsg.h index db160a9..6b31af9 100644 --- a/src/ippmsg.h +++ b/src/ippmsg.h @@ -19,6 +19,8 @@ public: JobAttrs = 0x02, EndAttrs = 0x03, PrinterAttrs = 0x04, + UnsupportedAttrs = 0x05, + Unsupported = 0x10, Integer = 0x21, Boolean = 0x22, Enum = 0x23, From 09fbb96a7ed34861bf3fee89c22a51dabad4c63a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 4 Jun 2020 21:31:46 +0200 Subject: [PATCH 67/94] Rework/expose format conversions --- qml/components/ChoiceSetting.qml | 9 +- qml/pages/PrinterPage.qml | 22 +++-- qml/pages/utils.js | 53 +++++++++++ src/convertworker.cpp | 127 ++++++++++++++++++------- src/convertworker.h | 4 +- src/ippprinter.cpp | 60 +++++------- src/ippprinter.h | 20 +--- translations/harbour-seaprint-de.ts | 44 +++++++++ translations/harbour-seaprint-es.ts | 44 +++++++++ translations/harbour-seaprint-fr.ts | 44 +++++++++ translations/harbour-seaprint-zh_CN.ts | 44 +++++++++ translations/harbour-seaprint.ts | 44 +++++++++ 12 files changed, 410 insertions(+), 105 deletions(-) diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 361e40d..ad0d577 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -4,6 +4,9 @@ import "../pages/utils.js" as Utils Setting { property var choices + property string mime_type + + property var limited_choices: Utils.limitChoices(name, choices, mime_type) ValueButton { enabled: valid @@ -17,12 +20,12 @@ Setting { id: menu enabled: valid Repeater { - model: choices + model: limited_choices MenuItem { - text: Utils.ippName(name, choices[index]) + text: Utils.ippName(name, limited_choices[index]) onClicked: { - choice = choices[index]; + choice = limited_choices[index]; } } } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 9dca3a5..0104f5b 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -1,5 +1,6 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import seaprint.mimer 1.0 import "utils.js" as Utils import Nemo.Configuration 1.0 @@ -39,14 +40,15 @@ Page { ListModel { id:mod - ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} - ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} - ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} -// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} - ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} -// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23} - ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23} - ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32} + ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} + ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} + ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} +// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} + ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} +// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23} + ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23} + ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32} + ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: 0x49} } SilicaListView { @@ -100,13 +102,15 @@ Page { case 0x32: case 0x23: case 0x44: + case 0x49: loader.setSource("../components/ChoiceSetting.qml", {name: name, prettyName: prettyName, tag: tag, valid: printer.attrs.hasOwnProperty(name+"-supported"), choices: printer.attrs[name+"-supported"].value, - default_choice: printer.attrs[name+"-default"].value + default_choice: printer.attrs[name+"-default"].value, + mime_type: Mimer.get_type(selectedFile) }) break } diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 5c51925..acbd053 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -114,6 +114,27 @@ function ippName(name, value) { return value; } + case "document-format": + switch(value) { + case "application/octet-stream": + return qsTr("Auto-sense"); + case "application/pdf": + return qsTr("PDF"); + case "application/postscript": + return qsTr("Postscript"); + case "image/pwg-raster": + return qsTr("PWG-raster"); + case "image/urf": + return qsTr("URF-raster"); + case "image/png": + return qsTr("PNG"); + case "image/jpeg": + return qsTr("JPEG"); + case "image/gif": + return qsTr("GIF"); + default: + return value; + } } return value; } @@ -123,6 +144,38 @@ function endsWith(ending, string) return string.lastIndexOf(ending) == (string.length - ending.length); } +function canConvertPdfTo(type) +{ + var targets = ["application/octet-stream", "application/pdf", "image/pwg-raster", "image/urf"]; + return has(targets, type) +} + +function canConvertImageTo(type) +{ + var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"]; + return has(targets, type) +} + +function limitChoices(name, choices, mimeType) +{ + switch(name) { + case "document-format": + if(mimeType == "application/pdf") + { + return choices.filter(canConvertPdfTo) + } + else if(mimeType == "image/jpeg" || mimeType == "image/png") + { + return choices.filter(canConvertImageTo); + } + else + { + return ["application/octet-stream"]; + } + default: + return choices; + } +} var media = {"asme_f_28x40in": "28 x 40″", diff --git a/src/convertworker.cpp b/src/convertworker.cpp index da082e7..6b1eaef 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -32,9 +32,25 @@ void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, } void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { + bool urf = false; + + if(targetFormat == "image/urf") + { + urf = true; + } + else if(targetFormat == "image/pwg-raster") + { + //ok + } + else + { + emit failed(tr("Unsupported target format")); + return; + } + if(urf && (HwResX != HwResY)) { // URF only supports symmetric resolutions qDebug() << "Unsupported URF resolution" << PaperSize; @@ -141,9 +157,31 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo } void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY) { + bool urf = false; + QString imageFormat = ""; + QStringList supportedImageFormats = {"image/jpeg", "image/png", "image/gif"}; + + if(targetFormat == "image/urf") + { + urf = true; + } + else if(targetFormat == "image/pwg-raster") + { + //ok + } + else if(supportedImageFormats.contains(targetFormat)) + { + imageFormat = targetFormat.split("/")[1]; + } + else + { + emit failed(tr("Unsupported target format")); + return; + } + if(urf && (HwResX != HwResY)) { // URF only supports symmetric resolutions qDebug() << "Unsupported URF resolution" << PaperSize; @@ -184,44 +222,61 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem painter.drawImage(0, (outImage.height()-inImage.height())/2, inImage); painter.end(); - QTemporaryFile tmpImage; - tmpImage.open(); - qDebug() << "Raw image: " << tmpImage.fileName(); - outImage.save(tmpImage.fileName(), Colors == 1 ? "pgm" : "ppm"); - tmpImage.close(); + if(imageFormat != "") + { // We are converting to a supported image format + QTemporaryFile tmpImage; + tmpImage.open(); + qDebug() << "Raw image: " << tmpImage.fileName(); - QProcess* ppm2pwg = new QProcess(this); - // Yo dawg, I heard you like programs... - ppm2pwg->setProgram("harbour-seaprint"); - ppm2pwg->setArguments({"ppm2pwg"}); - - QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false); - qDebug() << "ppm2pwg env is " << env; - - ppm2pwg->setEnvironment(env); - ppm2pwg->setStandardInputFile(tmpImage.fileName()); - ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); - - connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); - - qDebug() << "All connected"; - ppm2pwg->start(); - - qDebug() << "Starting"; - - if(!ppm2pwg->waitForStarted()) - { - qDebug() << "ppm2pwg died"; - tempfile->deleteLater(); - emit failed(tr("Conversion error")); - return; + outImage.save(tmpImage.fileName(), imageFormat.toStdString().c_str()); + QFile tempfileAsFile(tempfile->fileName()); + tempfileAsFile.open(QIODevice::Append); + tempfileAsFile.write(tmpImage.readAll()); + tempfileAsFile.close(); + tmpImage.close(); } - qDebug() << "All started"; + else + { // We are converting to a raster format + QTemporaryFile tmpImage; + tmpImage.open(); + qDebug() << "Raw image: " << tmpImage.fileName(); - ppm2pwg->waitForFinished(); + outImage.save(tmpImage.fileName(), Colors == 1 ? "pgm" : "ppm"); + tmpImage.close(); - qDebug() << "Finished"; + QProcess* ppm2pwg = new QProcess(this); + // Yo dawg, I heard you like programs... + ppm2pwg->setProgram("harbour-seaprint"); + ppm2pwg->setArguments({"ppm2pwg"}); + + QStringList env; + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false); + qDebug() << "ppm2pwg env is " << env; + + ppm2pwg->setEnvironment(env); + ppm2pwg->setStandardInputFile(tmpImage.fileName()); + ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); + + qDebug() << "All connected"; + ppm2pwg->start(); + + qDebug() << "Starting"; + + if(!ppm2pwg->waitForStarted()) + { + qDebug() << "ppm2pwg died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + qDebug() << "All started"; + + ppm2pwg->waitForFinished(); + + qDebug() << "Finished"; + } emit done(request, tempfile); qDebug() << "posted"; diff --git a/src/convertworker.h b/src/convertworker.h index 43e124a..cf466a9 100644 --- a/src/convertworker.h +++ b/src/convertworker.h @@ -9,11 +9,11 @@ class ConvertWorker : public QObject public slots: void convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); void convertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY); signals: diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index cfaa209..e609406 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -250,8 +250,9 @@ bool IppPrinter::hasPrinterDeviceIdCmd(QString cmd) return false; } - -void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ +// TODO: make alwaysConvert force ratser format +void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) +{ qDebug() << "printing" << filename << attrs; _progress = ""; @@ -270,15 +271,20 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ QJsonObject o = opAttrs(); o.insert("job-name", QJsonObject {{"tag", IppMsg::NameWithoutLanguage}, {"value", fileinfo.fileName()}}); + QJsonArray jobCreationAttributes = _attrs["job-creation-attributes-supported"].toObject()["value"].toArray(); - // Only include if printer supports it -// if (filename.endsWith("pdf")) -// { -// attrs.insert("document-format", QJsonObject {{"tag", 73}, {"value", "application/pdf"}}); -// } -// else if (filename.endsWith("jpg")) { -// attrs.insert("document-format", QJsonObject {{"tag", 73}, {"value", "image/jpeg"}}); -// } + QString documentFormat = getAttrOrDefault(attrs, "document-format").toString(); + + if(documentFormat == "") + { + emit convertFailed(tr("Unknown document format")); + return; + } + + if(!jobCreationAttributes.contains("document-format")) + { // Only include if printer supports it + attrs.remove("document-format"); + } qDebug() << "Printing job" << o << attrs; IppMsg job = IppMsg(o, attrs); @@ -294,16 +300,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ Mimer* mimer = Mimer::instance(); QString mimeType = mimer->get_type(filename); - ConvertFrom from = NotConvertable; - ConvertTarget target = NoConvert; - - if(mimeType == "application/pdf") - { - from = Pdf; - } - else if (mimeType.contains("image")) { - from = Image; - } QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); @@ -313,23 +309,11 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ qDebug() << "supportsPdf" << supportsPdf; - if(alwaysConvert || from == Image || (from == Pdf && !supportsPdf)) - { - if(supportedMimeTypes.contains("image/pwg-raster")) - { - target = PwgConvert; - } - else if (supportedMimeTypes.contains("image/urf")) - { - target = UrfConvert; - } - } - QJsonValue PrinterResolutionRef = getAttrOrDefault(attrs, "printer-resolution"); quint32 HwResX = PrinterResolutionRef.toObject()["x"].toInt(); quint32 HwResY = PrinterResolutionRef.toObject()["y"].toInt(); - if(target == UrfConvert) + if(documentFormat == "image/urf") { // Ensure symmetric resolution for URF if(HwResX < HwResY) { @@ -358,7 +342,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ return; } - if(target != NoConvert) + if(documentFormat != mimeType) { file.close(); @@ -370,7 +354,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ setBusyMessage("Converting"); - if(from == Pdf ) + if(mimeType == "application/pdf") { QString Sides = getAttrOrDefault(attrs, "sides").toString(); @@ -386,12 +370,12 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ Tumble = true; } - emit doConvertPdf(request, filename, tempfile, target==UrfConvert, Colors, Quality, + emit doConvertPdf(request, filename, tempfile, documentFormat, Colors, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble); } - else if (from == Image) + else if (mimeType.contains("image")) { - emit doConvertImage(request, filename, tempfile, target==UrfConvert, Colors, Quality, + emit doConvertImage(request, filename, tempfile, documentFormat, Colors, Quality, PaperSize, HwResX, HwResY); } else diff --git a/src/ippprinter.h b/src/ippprinter.h index 26e1574..e4c4e38 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -32,20 +32,6 @@ public: bool hasPrinterDeviceIdCmd(QString cmd); - enum ConvertTarget - { - NoConvert, - PwgConvert, - UrfConvert - }; - - enum ConvertFrom - { - NotConvertable, - Pdf, - Image - }; - signals: void urlChanged(); void attrsChanged(); @@ -56,11 +42,11 @@ signals: void cancelStatus(bool status); void doConvertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, - bool urf, quint32 Colors, quint32 Quality, QString PaperSize, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble); - void doConvertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, bool urf, - quint32 Colors, quint32 Quality, QString PaperSize, + void doConvertImage(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, + QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY); void busyMessageChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index c36357f..d5d448e 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -140,6 +140,10 @@ Unsupported resolution (dpi) + + Unsupported target format + + CoverPage @@ -209,6 +213,10 @@ Cannot convert this file format + + Unknown document format + + JobsPage @@ -271,6 +279,10 @@ Print media + + Transfer format + + utils @@ -350,5 +362,37 @@ dots/cm + + Auto-sense + + + + PDF + + + + Postscript + + + + PWG-raster + + + + URF-raster + + + + PNG + + + + JPEG + + + + GIF + + diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 46aeab8..f04d37b 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -140,6 +140,10 @@ Unsupported resolution (dpi) + + Unsupported target format + + CoverPage @@ -209,6 +213,10 @@ Cannot convert this file format + + Unknown document format + + JobsPage @@ -271,6 +279,10 @@ Print media + + Transfer format + + utils @@ -350,5 +362,37 @@ dots/cm ppp + + Auto-sense + + + + PDF + + + + Postscript + + + + PWG-raster + + + + URF-raster + + + + PNG + + + + JPEG + + + + GIF + + diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index b112229..eb89498 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -140,6 +140,10 @@ Unsupported resolution (dpi) + + Unsupported target format + + CoverPage @@ -209,6 +213,10 @@ Cannot convert this file format + + Unknown document format + + JobsPage @@ -271,6 +279,10 @@ Print media + + Transfer format + + utils @@ -350,5 +362,37 @@ dots/cm pts/cm + + Auto-sense + + + + PDF + + + + Postscript + + + + PWG-raster + + + + URF-raster + + + + PNG + + + + JPEG + + + + GIF + + diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 8a119d9..cea3313 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -140,6 +140,10 @@ Unsupported resolution (dpi) + + Unsupported target format + + CoverPage @@ -209,6 +213,10 @@ Cannot convert this file format + + Unknown document format + + JobsPage @@ -271,6 +279,10 @@ Print media + + Transfer format + + utils @@ -350,5 +362,37 @@ dots/cm 点/厘米 + + Auto-sense + + + + PDF + + + + Postscript + + + + PWG-raster + + + + URF-raster + + + + PNG + + + + JPEG + + + + GIF + + diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index a01287e..8f64183 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -140,6 +140,10 @@ Unsupported resolution (dpi) + + Unsupported target format + + CoverPage @@ -209,6 +213,10 @@ Cannot convert this file format + + Unknown document format + + JobsPage @@ -271,6 +279,10 @@ Print media + + Transfer format + + utils @@ -350,5 +362,37 @@ dots/cm + + Auto-sense + + + + PDF + + + + Postscript + + + + PWG-raster + + + + URF-raster + + + + PNG + + + + JPEG + + + + GIF + + From 67c27bdb80a141ebcab28c385f5e242563963ec9 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 18:49:52 +0200 Subject: [PATCH 68/94] Expose media-source setting --- qml/pages/PrinterPage.qml | 19 ++++++++++--------- translations/harbour-seaprint-de.ts | 4 ++++ translations/harbour-seaprint-es.ts | 4 ++++ translations/harbour-seaprint-fr.ts | 4 ++++ translations/harbour-seaprint-zh_CN.ts | 4 ++++ translations/harbour-seaprint.ts | 4 ++++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 0104f5b..2e0c7f1 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -40,15 +40,16 @@ Page { ListModel { id:mod - ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} - ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} - ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} -// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} - ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} -// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23} - ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23} - ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32} - ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: 0x49} + ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} + ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} + ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} +// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} + ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} +// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23} + ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23} + ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32} + ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: 0x49} + ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: 0x44} } SilicaListView { diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index d5d448e..90299e4 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -283,6 +283,10 @@ Transfer format + + Media source + + utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index f04d37b..f476009 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -283,6 +283,10 @@ Transfer format + + Media source + + utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index eb89498..f470f0e 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -283,6 +283,10 @@ Transfer format + + Media source + + utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index cea3313..f17322e 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -283,6 +283,10 @@ Transfer format + + Media source + + utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 8f64183..b4ce6af 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -283,6 +283,10 @@ Transfer format + + Media source + + utils From 65c3ad186d9d31e963df5292a2998d14f5b49632 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 18:55:40 +0200 Subject: [PATCH 69/94] Fix om_large-photo_200x300 size --- src/papersizes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/papersizes.h b/src/papersizes.h index 054b2a2..c4d8858 100644 --- a/src/papersizes.h +++ b/src/papersizes.h @@ -184,7 +184,7 @@ static QMap> PaperSizes = {"om_invite_220x220mm", {220.00, 220.00}}, {"om_italian_110x230mm", {110.00, 230.00}}, {"om_juuro-ku-kai_198x275mm", {198.00, 275.00}}, - {"om_large-photo_200x300", {200.00, 3.00}}, + {"om_large-photo_200x300", {200.00, 300.00}}, {"om_medium-photo_130x180mm", {130.00, 180.00}}, {"om_pa-kai_267x389mm", {267.00, 389.00}}, {"om_postfix_114x229mm", {114.00, 229.00}}, From ed218e527841c1ee192884339f344d257680305a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 19:05:11 +0200 Subject: [PATCH 70/94] Limit resolution choices to dpi ...because nothing else is really supported --- qml/pages/utils.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index acbd053..ef3868f 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -156,6 +156,12 @@ function canConvertImageTo(type) return has(targets, type) } +function unitsIsDpi(resolution) +{ + return resolution.units == 3; +} + + function limitChoices(name, choices, mimeType) { switch(name) { @@ -172,6 +178,8 @@ function limitChoices(name, choices, mimeType) { return ["application/octet-stream"]; } + case "printer-resolution": + return choices.filter(unitsIsDpi); default: return choices; } From 8571b7fb5c1cda6cc3288494ec3f79fa66d6e357 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 20:05:48 +0200 Subject: [PATCH 71/94] Make additional formats a printer property ...and add them to format choices ...and consider them properly supported, for now --- qml/pages/FirstPage.qml | 10 ++------ qml/pages/PrinterPage.qml | 3 ++- qml/pages/utils.js | 25 ++----------------- src/ippprinter.cpp | 52 +++++++++++++++++++++++++-------------- src/ippprinter.h | 5 ++++ 5 files changed, 44 insertions(+), 51 deletions(-) diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index cc58ec5..723b31b 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -107,6 +107,7 @@ Page { Connections { target: printer onAttrsChanged: { + console.log(printer.url, Object.keys(printer.attrs)) if(Object.keys(printer.attrs).length === 0) { delegate.visible = false } @@ -209,7 +210,7 @@ Page { spacing: Theme.paddingMedium Label { id: format_unsupported_label - visible: format_label.text == "" && maybe_format_label.text == "" + visible: format_label.text == "" color: "red" font.pixelSize: Theme.fontSizeExtraSmall text: qsTr("No compatible formats supported") @@ -220,13 +221,6 @@ Page { font.pixelSize: Theme.fontSizeExtraSmall text: Utils.supported_formats(printer, ConvertChecker).supported } - Label { - id: maybe_format_label - color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.secondaryColor : "red" - font.pixelSize: Theme.fontSizeExtraSmall - font.italic: true - text: Utils.supported_formats(printer, ConvertChecker).maybe - } } } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 2e0c7f1..10ace6d 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -109,7 +109,8 @@ Page { prettyName: prettyName, tag: tag, valid: printer.attrs.hasOwnProperty(name+"-supported"), - choices: printer.attrs[name+"-supported"].value, + choices: name == "document-format" ? printer.attrs[name+"-supported"].value.concat(printer.additionalDocumentFormats) + : printer.attrs[name+"-supported"].value, default_choice: printer.attrs[name+"-default"].value, mime_type: Mimer.get_type(selectedFile) }) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index ef3868f..4645f68 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,6 +1,6 @@ function supported_formats(printer, ConvertChecker) { - var formats = printer.attrs["document-format-supported"].value; + var formats = printer.attrs["document-format-supported"].value+printer.additionalDocumentFormats; var mimetypes = []; var supported = []; if(has(formats, "application/pdf") || (ConvertChecker.pdf && ( has(formats, "image/pwg-raster") || has(formats, "image/urf"))) ) @@ -21,29 +21,8 @@ function supported_formats(printer, ConvertChecker) mimetypes.push("image/png"); supported.push("PNG"); } - //var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";"); - var maybe = [] - var info = printer.attrs["printer-info"] ? printer.attrs["printer-info"].value.split(";") : []; - for(var i in info) - { - if(info[i].split(":")[0] == "CMD") - { - if(!has(supported, "PDF") && has(info[i].split(":")[1].split(","), "PDF")) - { - mimetypes.push("application/pdf"); - maybe.push("PDF"); - } - if(!has(supported, "Postscript") && has(info[i].split(":")[1].split(","), "POSTSCRIPT")) - { - mimetypes.push("application/postscript"); - maybe.push("Postscript"); - } - break; - } - } - - return {supported: supported.join(" "), maybe: maybe.join(" "), mimetypes: mimetypes}; + return {supported: supported.join(" "), mimetypes: mimetypes}; } function has(arrayish, what) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index e609406..97c5a69 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -95,6 +95,10 @@ void IppPrinter::refresh() { _attrs = QJsonObject(); emit attrsChanged(); + _additionalDocumentFormats = QStringList(); + emit additionalDocumentFormatsChanged(); + + QNetworkRequest request; request.setUrl(httpUrl()); @@ -128,6 +132,31 @@ void IppPrinter::getPrinterAttributesFinished(QNetworkReply *reply) qDebug() << e.what(); } } + + if(_attrs.contains("printer-device-id")) + { + QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); + QStringList printerDeviceId = _attrs["printer-device-id"].toObject()["value"].toString().split(";"); + for (QStringList::iterator it = printerDeviceId.begin(); it != printerDeviceId.end(); it++) + { + QStringList kv = it->split(":"); + if(kv.length()==2 && kv[0]=="CMD") + { + QStringList cmds = kv[1].split(","); + if(cmds.contains("PDF") && !supportedMimeTypes.contains("application/pdf")) + { + _additionalDocumentFormats.append("application/pdf"); + } + if(cmds.contains("POSTSCRIPT") && !supportedMimeTypes.contains("application/postscript")) + { + _additionalDocumentFormats.append("application/postscript"); + } + } + } + qDebug() << "additionalDocumentFormats" << _additionalDocumentFormats; + emit additionalDocumentFormatsChanged(); + } + emit attrsChanged(); } @@ -235,21 +264,6 @@ void IppPrinter::convertFailed(QString message) emit jobFinished(false); } - -bool IppPrinter::hasPrinterDeviceIdCmd(QString cmd) -{ - QStringList printerDeviceId = _attrs["printer-device-id"].toObject()["value"].toString().split(";"); - for (QStringList::iterator it = printerDeviceId.begin(); it != printerDeviceId.end(); it++) - { - QStringList kv = it->split(":"); - if(kv.length()==2 && kv[0]=="CMD") - { - return kv[1].split(",").contains("PDF"); - } - } - return false; -} - // TODO: make alwaysConvert force ratser format void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) { @@ -302,13 +316,13 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) QString mimeType = mimer->get_type(filename); QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); + for(QStringList::iterator it = _additionalDocumentFormats.begin(); it != _additionalDocumentFormats.end(); it++) + { + supportedMimeTypes.append(*it); + } qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - bool supportsPdf = supportedMimeTypes.contains("application/pdf") || hasPrinterDeviceIdCmd("PDF"); - - qDebug() << "supportsPdf" << supportsPdf; - QJsonValue PrinterResolutionRef = getAttrOrDefault(attrs, "printer-resolution"); quint32 HwResX = PrinterResolutionRef.toObject()["x"].toInt(); quint32 HwResY = PrinterResolutionRef.toObject()["y"].toInt(); diff --git a/src/ippprinter.h b/src/ippprinter.h index e4c4e38..ac01f1c 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -13,6 +13,7 @@ class IppPrinter : public QObject Q_PROPERTY(QJsonObject attrs MEMBER _attrs NOTIFY attrsChanged) Q_PROPERTY(QJsonObject jobAttrs MEMBER _jobAttrs NOTIFY jobAttrsChanged) Q_PROPERTY(QJsonArray jobs MEMBER _jobs NOTIFY jobsChanged) + Q_PROPERTY(QStringList additionalDocumentFormats MEMBER _additionalDocumentFormats NOTIFY additionalDocumentFormatsChanged) Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged) Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged) @@ -49,6 +50,7 @@ signals: QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY); + void additionalDocumentFormatsChanged(); void busyMessageChanged(); void progressChanged(); @@ -86,6 +88,9 @@ private: QJsonObject _attrs; QJsonObject _jobAttrs; QJsonArray _jobs; + + QStringList _additionalDocumentFormats; + QString _busyMessage; QString _progress; From 5814a8c6a2b3f275f8736cdf2523fe99be5dcfad Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 20:41:45 +0200 Subject: [PATCH 72/94] Add format heuristics for when using octet-string --- src/ippprinter.cpp | 82 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 97c5a69..1cd4e73 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -264,6 +264,35 @@ void IppPrinter::convertFailed(QString message) emit jobFinished(false); } +QString firstMatch(QJsonArray supported, QStringList wanted) +{ + for(QStringList::iterator it = wanted.begin(); it != wanted.end(); it++) + { + if(supported.contains(*it)) + { + return *it; + } + } + return ""; +} + +QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray supportedMimeTypes) +{ + if(documentFormat == "application/octet-stream") + { + if(mimeType == "application/pdf") + { + return firstMatch(supportedMimeTypes, {"application/pdf", "image/pwg-raster", "image/urf" /*, "application/postscript"*/ }); + } + else if (mimeType.contains("image")) + { + return firstMatch(supportedMimeTypes, {"image/png", "image/gif", "image/jpeg", "image/pwg-raster", "image/urf"}); + } + return documentFormat; + } + return documentFormat; +} + // TODO: make alwaysConvert force ratser format void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) { @@ -280,6 +309,18 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) return; } + Mimer* mimer = Mimer::instance(); + QString mimeType = mimer->get_type(filename); + + + QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); + for(QStringList::iterator it = _additionalDocumentFormats.begin(); it != _additionalDocumentFormats.end(); it++) + { + supportedMimeTypes.append(*it); + } + + qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); + QFileInfo fileinfo(file); QJsonObject o = opAttrs(); @@ -288,8 +329,12 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) QJsonArray jobCreationAttributes = _attrs["job-creation-attributes-supported"].toObject()["value"].toArray(); QString documentFormat = getAttrOrDefault(attrs, "document-format").toString(); + qDebug() << "target format:" << documentFormat; - if(documentFormat == "") + documentFormat = targetFormatIfAuto(documentFormat, mimeType, supportedMimeTypes); + qDebug() << "adjusted target format:" << documentFormat; + + if(documentFormat == "" || documentFormat == "application/octet-string") { emit convertFailed(tr("Unknown document format")); return; @@ -311,18 +356,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) request.setHeader(QNetworkRequest::ContentTypeHeader, "application/ipp"); request.setHeader(QNetworkRequest::UserAgentHeader, "SeaPrint " SEAPRINT_VERSION); - - Mimer* mimer = Mimer::instance(); - QString mimeType = mimer->get_type(filename); - - QJsonArray supportedMimeTypes = _attrs["document-format-supported"].toObject()["value"].toArray(); - for(QStringList::iterator it = _additionalDocumentFormats.begin(); it != _additionalDocumentFormats.end(); it++) - { - supportedMimeTypes.append(*it); - } - - qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); - QJsonValue PrinterResolutionRef = getAttrOrDefault(attrs, "printer-resolution"); quint32 HwResX = PrinterResolutionRef.toObject()["x"].toInt(); quint32 HwResY = PrinterResolutionRef.toObject()["y"].toInt(); @@ -356,7 +389,18 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) return; } - if(documentFormat != mimeType) + // Always convert images to get resizing + if((mimeType == documentFormat) && !mimeType.contains("image")) + { + QByteArray filedata = file.readAll(); + contents = contents.append(filedata); + file.close(); + + setBusyMessage("Transferring"); + QNetworkReply* reply = _print_nam->post(request, contents); + connect(reply, &QNetworkReply::uploadProgress, this, &IppPrinter::setProgress); + } + else { file.close(); @@ -398,16 +442,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) return; } } - else - { - QByteArray filedata = file.readAll(); - contents = contents.append(filedata); - file.close(); - - setBusyMessage("Transferring"); - - _print_nam->post(request, contents); - } return; } From b7b587d099341ce424bf9b9f79ac055f843ce0b8 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 21:01:59 +0200 Subject: [PATCH 73/94] Make alwaysConvert do something again --- src/ippprinter.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 1cd4e73..dff703e 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -276,9 +276,13 @@ QString firstMatch(QJsonArray supported, QStringList wanted) return ""; } -QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray supportedMimeTypes) +QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray supportedMimeTypes, bool forceRaster) { - if(documentFormat == "application/octet-stream") + if(forceRaster) + { + return firstMatch(supportedMimeTypes, {"image/pwg-raster", "image/urf"}); + } + else if(documentFormat == "application/octet-stream") { if(mimeType == "application/pdf") { @@ -329,9 +333,9 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) QJsonArray jobCreationAttributes = _attrs["job-creation-attributes-supported"].toObject()["value"].toArray(); QString documentFormat = getAttrOrDefault(attrs, "document-format").toString(); - qDebug() << "target format:" << documentFormat; + qDebug() << "target format:" << documentFormat << "alwaysConvert:" << alwaysConvert; - documentFormat = targetFormatIfAuto(documentFormat, mimeType, supportedMimeTypes); + documentFormat = targetFormatIfAuto(documentFormat, mimeType, supportedMimeTypes, alwaysConvert); qDebug() << "adjusted target format:" << documentFormat; if(documentFormat == "" || documentFormat == "application/octet-string") From ce67e427204781e0f3e69f4d3da8cb180d2f3cbb Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 21:12:19 +0200 Subject: [PATCH 74/94] Add forceIncluDeDocumentFormat option ...because my printer is stupid --- qml/pages/PrinterPage.qml | 9 ++++++++- src/ippprinter.cpp | 6 +++--- src/ippprinter.h | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 10ace6d..31686d2 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -17,6 +17,13 @@ Page { defaultValue: false } + ConfigurationValue + { + id: forceIncluDeDocumentFormat + key: "/apps/harbour-seaprint/settings/force_include_document_format" + defaultValue: false + } + Component.onCompleted: { console.log(JSON.stringify(printer.attrs)) } @@ -33,7 +40,7 @@ Page { console.log(JSON.stringify(jobParams)) pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, PageStackAction.Immediate) - printer.print(jobParams, page.selectedFile, alwaysConvert.value) + printer.print(jobParams, page.selectedFile, alwaysConvert.value, forceIncluDeDocumentFormat.value) } } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index dff703e..dcbfb69 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -298,9 +298,9 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray } // TODO: make alwaysConvert force ratser format -void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) +void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, bool forceIncluDeDocumentFormat) { - qDebug() << "printing" << filename << attrs; + qDebug() << "printing" << filename << attrs << alwaysConvert << forceIncluDeDocumentFormat; _progress = ""; emit progressChanged(); @@ -344,7 +344,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert) return; } - if(!jobCreationAttributes.contains("document-format")) + if(!jobCreationAttributes.contains("document-format") && !forceIncluDeDocumentFormat) { // Only include if printer supports it attrs.remove("document-format"); } diff --git a/src/ippprinter.h b/src/ippprinter.h index ac01f1c..6cc11e3 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -55,7 +55,7 @@ signals: void progressChanged(); public slots: - void print(QJsonObject attrs, QString file, bool alwaysConvert); + void print(QJsonObject attrs, QString file, bool alwaysConvert, bool forceIncluDeDocumentFormat); void onUrlChanged(); From ee4b5625602faa5bdeed62e822f30e711c779936 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 21:45:41 +0200 Subject: [PATCH 75/94] Update ppm2pwg to correct URF grey --- ppm2pwg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppm2pwg b/ppm2pwg index 66939c8..150994f 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit 66939c8a9812d399f57753a14b8e96be68346281 +Subproject commit 150994fb2fd9f0b00552a7a54c8ef83b469e764a From dd6bca12fcc8edfa93d4cad83a19f71d715d49f5 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 21:46:17 +0200 Subject: [PATCH 76/94] Improve what is a color/mono choice --- src/ippprinter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index dcbfb69..a624768 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -384,7 +384,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, quint32 Quality = getAttrOrDefault(attrs, "print-quality").toInt(); QString PrintColorMode = getAttrOrDefault(attrs, "print-color-mode").toString(); - quint32 Colors = PrintColorMode=="color" ? 3 : PrintColorMode=="monochrome" ? 1 : 0; + quint32 Colors = PrintColorMode.contains("color") ? 3 : PrintColorMode.contains("monochrome") ? 1 : 0; QString PaperSize = getAttrOrDefault(attrs, "media").toString(); if(!PaperSizes.contains(PaperSize)) From 37431cc21e99f6fa225388f0f5330185d4a0111b Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Fri, 5 Jun 2020 22:01:12 +0200 Subject: [PATCH 77/94] Update ppm2pwg for sanity --- ppm2pwg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppm2pwg b/ppm2pwg index 150994f..66b9eea 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit 150994fb2fd9f0b00552a7a54c8ef83b469e764a +Subproject commit 66b9eea5a074f08cff948292c07c487a5d90aa78 From 213ab589a3264d7770adc3e5c2a7669016ac5532 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 11:27:08 +0200 Subject: [PATCH 78/94] Clean up connections --- src/ippprinter.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index a624768..b263650 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -10,17 +10,17 @@ IppPrinter::IppPrinter() _jobs_nam = new QNetworkAccessManager(this); _job_cancel_nam = new QNetworkAccessManager(this); - connect(_nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(getPrinterAttributesFinished(QNetworkReply*))); - connect(_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); + connect(_nam, &QNetworkAccessManager::finished, this, &IppPrinter::getPrinterAttributesFinished); + connect(_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::ignoreKnownSslErrors); - connect(_print_nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(printRequestFinished(QNetworkReply*))); - connect(_print_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); + connect(_print_nam, &QNetworkAccessManager::finished, this, &IppPrinter::printRequestFinished); + connect(_print_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::ignoreKnownSslErrors); - connect(_jobs_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(getJobsRequestFinished(QNetworkReply*))); - connect(_jobs_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); + connect(_jobs_nam, &QNetworkAccessManager::finished,this, &IppPrinter::getJobsRequestFinished); + connect(_jobs_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::ignoreKnownSslErrors); - connect(_job_cancel_nam, SIGNAL(finished(QNetworkReply*)),this, SLOT(cancelJobFinished(QNetworkReply*))); - connect(_job_cancel_nam, SIGNAL(sslErrors(QNetworkReply*,QList)), this, SLOT(ignoreKnownSslErrors(QNetworkReply*, const QList&))); + connect(_job_cancel_nam, &QNetworkAccessManager::finished,this, &IppPrinter::cancelJobFinished); + connect(_job_cancel_nam, &QNetworkAccessManager::sslErrors, this, &IppPrinter::ignoreKnownSslErrors); QObject::connect(this, &IppPrinter::urlChanged, this, &IppPrinter::onUrlChanged); qRegisterMetaType("QTemporaryFile*"); From 76abb7cea535a56cec5db0987021b19bed385c78 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 14:59:44 +0200 Subject: [PATCH 79/94] Add option to remove sides IPP attribute for raster formats ...because apparently my printer doesn't like it, even if it agrees with the raster file --- ppm2pwg | 2 +- qml/pages/PrinterPage.qml | 10 ++++++- src/convertworker.cpp | 39 ++++++++++++++++++++++++-- src/ippprinter.cpp | 20 +++++++------ src/ippprinter.h | 3 +- translations/harbour-seaprint-de.ts | 4 +++ translations/harbour-seaprint-es.ts | 4 +++ translations/harbour-seaprint-fr.ts | 4 +++ translations/harbour-seaprint-zh_CN.ts | 4 +++ translations/harbour-seaprint.ts | 4 +++ 10 files changed, 80 insertions(+), 14 deletions(-) diff --git a/ppm2pwg b/ppm2pwg index 66b9eea..a404a17 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit 66b9eea5a074f08cff948292c07c487a5d90aa78 +Subproject commit a404a177038626765b915ce0cf21527704bffd7e diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 31686d2..8eab41d 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -24,6 +24,13 @@ Page { defaultValue: false } + ConfigurationValue + { + id: removeDuplexAttributesForRaster + key: "/apps/harbour-seaprint/settings/remove_duplex_attribute_for_raster" + defaultValue: false + } + Component.onCompleted: { console.log(JSON.stringify(printer.attrs)) } @@ -40,7 +47,8 @@ Page { console.log(JSON.stringify(jobParams)) pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, PageStackAction.Immediate) - printer.print(jobParams, page.selectedFile, alwaysConvert.value, forceIncluDeDocumentFormat.value) + printer.print(jobParams, page.selectedFile, + alwaysConvert.value, forceIncluDeDocumentFormat.value, removeDuplexAttributesForRaster.value) } } } diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 6b1eaef..d962c9e 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -6,7 +6,7 @@ #include void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, - quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble, quint32 pages) { env.append("HWRES_X="+QString::number(HwResX)); env.append("HWRES_Y="+QString::number(HwResY)); @@ -29,12 +29,45 @@ void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, env.append("DUPLEX="+QString::number(TwoSided)); env.append("TUMBLE="+QString::number(Tumble)); + if(pages != 0) + { + env.append("PAGES="+QString::number(pages)); + } + } void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTemporaryFile* tempfile, QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize, quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble) { + + QProcess* pdfinfo = new QProcess(this); + pdfinfo->setProgram("pdfinfo"); + pdfinfo->setArguments({filename}); + pdfinfo->start(); + + if(!pdfinfo->waitForStarted() || !pdfinfo->waitForFinished()) + { + qDebug() << "pdfinfo died"; + pdfinfo->deleteLater(); + tempfile->deleteLater(); + emit failed(tr("Failed to get info about PDF file")); + return; + } + QByteArray pdfInfoOutput = pdfinfo->readAllStandardOutput(); + pdfinfo->deleteLater(); + qDebug() << pdfInfoOutput; + QList pdfInfoOutputLines = pdfInfoOutput.split('\n'); + quint32 pages = 0; + for(QList::iterator it = pdfInfoOutputLines.begin(); it != pdfInfoOutputLines.end(); it++) + { + if(it->startsWith("Pages")) + { + QList pagesTokens = it->split(' '); + pages = pagesTokens.last().toInt(); + } + } + bool urf = false; if(targetFormat == "image/urf") @@ -104,7 +137,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, pages); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); @@ -250,7 +283,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, 0); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index b263650..51844d2 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -297,10 +297,11 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray return documentFormat; } -// TODO: make alwaysConvert force ratser format -void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, bool forceIncluDeDocumentFormat) +void IppPrinter::print(QJsonObject attrs, QString filename, + bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeDuplexAttributesForRaster) { - qDebug() << "printing" << filename << attrs << alwaysConvert << forceIncluDeDocumentFormat; + qDebug() << "printing" << filename << attrs + << alwaysConvert << forceIncluDeDocumentFormat << removeDuplexAttributesForRaster; _progress = ""; emit progressChanged(); @@ -350,9 +351,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, } qDebug() << "Printing job" << o << attrs; - IppMsg job = IppMsg(o, attrs); - - QByteArray contents = job.encode(IppMsg::PrintJob); QNetworkRequest request; @@ -393,6 +391,14 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, return; } + QString Sides = getAttrOrDefault(attrs, "sides").toString(); + if(removeDuplexAttributesForRaster && (documentFormat=="image/pwg-raster" || documentFormat=="image/urf")) + { + attrs.remove("sides"); + } + + IppMsg job = IppMsg(o, attrs); + QByteArray contents = job.encode(IppMsg::PrintJob); // Always convert images to get resizing if((mimeType == documentFormat) && !mimeType.contains("image")) { @@ -418,8 +424,6 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert, if(mimeType == "application/pdf") { - - QString Sides = getAttrOrDefault(attrs, "sides").toString(); bool TwoSided = false; bool Tumble = false; if(Sides=="two-sided-long-edge") diff --git a/src/ippprinter.h b/src/ippprinter.h index 6cc11e3..118d911 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -55,7 +55,8 @@ signals: void progressChanged(); public slots: - void print(QJsonObject attrs, QString file, bool alwaysConvert, bool forceIncluDeDocumentFormat); + void print(QJsonObject attrs, QString file, + bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeDuplexAttributesForRaster); void onUrlChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 90299e4..60527e1 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -144,6 +144,10 @@ Unsupported target format + + Failed to get info about PDF file + + CoverPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index f476009..d9742b8 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -144,6 +144,10 @@ Unsupported target format + + Failed to get info about PDF file + + CoverPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index f470f0e..2fc0390 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -144,6 +144,10 @@ Unsupported target format + + Failed to get info about PDF file + + CoverPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index f17322e..3ebedfa 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -144,6 +144,10 @@ Unsupported target format + + Failed to get info about PDF file + + CoverPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index b4ce6af..a52e184 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -144,6 +144,10 @@ Unsupported target format + + Failed to get info about PDF file + + CoverPage From 5419ec2c3001234af4b3db31b345d1a0a6a48b97 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 15:16:46 +0200 Subject: [PATCH 80/94] Include print-color-mode in attributes to be removed ...when printing via raster format --- qml/pages/PrinterPage.qml | 8 ++++---- src/ippprinter.cpp | 9 ++++++--- src/ippprinter.h | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 8eab41d..9f0b925 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -26,9 +26,9 @@ Page { ConfigurationValue { - id: removeDuplexAttributesForRaster - key: "/apps/harbour-seaprint/settings/remove_duplex_attribute_for_raster" - defaultValue: false + id: removeRedundantAttributesForRaster + key: "/apps/harbour-seaprint/settings/remove_redundant_attributes_for_raster" + defaultValue: true } Component.onCompleted: { @@ -48,7 +48,7 @@ Page { pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, PageStackAction.Immediate) printer.print(jobParams, page.selectedFile, - alwaysConvert.value, forceIncluDeDocumentFormat.value, removeDuplexAttributesForRaster.value) + alwaysConvert.value, forceIncluDeDocumentFormat.value, removeRedundantAttributesForRaster.value) } } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 51844d2..2e65f7d 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -298,10 +298,10 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray } void IppPrinter::print(QJsonObject attrs, QString filename, - bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeDuplexAttributesForRaster) + bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantAttributesForRaster) { qDebug() << "printing" << filename << attrs - << alwaysConvert << forceIncluDeDocumentFormat << removeDuplexAttributesForRaster; + << alwaysConvert << forceIncluDeDocumentFormat << removeRedundantAttributesForRaster; _progress = ""; emit progressChanged(); @@ -392,11 +392,14 @@ void IppPrinter::print(QJsonObject attrs, QString filename, } QString Sides = getAttrOrDefault(attrs, "sides").toString(); - if(removeDuplexAttributesForRaster && (documentFormat=="image/pwg-raster" || documentFormat=="image/urf")) + if(removeRedundantAttributesForRaster && (documentFormat=="image/pwg-raster" || documentFormat=="image/urf")) { attrs.remove("sides"); + attrs.remove("print-color-mode"); } + qDebug() << "Final job attributes:" << attrs; + IppMsg job = IppMsg(o, attrs); QByteArray contents = job.encode(IppMsg::PrintJob); // Always convert images to get resizing diff --git a/src/ippprinter.h b/src/ippprinter.h index 118d911..7a8ea5a 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -56,7 +56,7 @@ signals: public slots: void print(QJsonObject attrs, QString file, - bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeDuplexAttributesForRaster); + bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantAttributesForRaster); void onUrlChanged(); From bfd496138dd937dc83212cf7bbaf13aafa480aca Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 15:47:43 +0200 Subject: [PATCH 81/94] Add pdf->postscript conversions --- qml/pages/utils.js | 7 +- src/convertworker.cpp | 171 +++++++++++++++++++++++++++--------------- src/ippprinter.cpp | 2 +- 3 files changed, 116 insertions(+), 64 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 4645f68..eb0797b 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -3,7 +3,10 @@ function supported_formats(printer, ConvertChecker) var formats = printer.attrs["document-format-supported"].value+printer.additionalDocumentFormats; var mimetypes = []; var supported = []; - if(has(formats, "application/pdf") || (ConvertChecker.pdf && ( has(formats, "image/pwg-raster") || has(formats, "image/urf"))) ) + if(has(formats, "application/pdf") || + (ConvertChecker.pdf && ( has(formats, "application/postscript") || + has(formats, "image/pwg-raster") || + has(formats, "image/urf"))) ) { mimetypes.push("application/pdf"); supported.push("PDF"); @@ -125,7 +128,7 @@ function endsWith(ending, string) function canConvertPdfTo(type) { - var targets = ["application/octet-stream", "application/pdf", "image/pwg-raster", "image/urf"]; + var targets = ["application/octet-stream", "application/pdf", "application/postscript", "image/pwg-raster", "image/urf"]; return has(targets, type) } diff --git a/src/convertworker.cpp b/src/convertworker.cpp index d962c9e..dba41a6 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -69,6 +69,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo } bool urf = false; + bool ps = false; if(targetFormat == "image/urf") { @@ -78,6 +79,10 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo { //ok } + else if(targetFormat == "application/postscript") + { + ps = true; + } else { emit failed(tr("Unsupported target format")); @@ -117,71 +122,115 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo return; } - QProcess* pdftocairo = new QProcess(this); - pdftocairo->setProgram("pdftocairo"); - pdftocairo->setArguments({"-pdf", "-paper", ShortPaperSize, filename, "-"}); - - QProcess* pdftoppm = new QProcess(this); - pdftoppm->setProgram("pdftoppm"); - QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)}; - if(Colors != 3) + if(ps) { - Pdf2PpmArgs.append("-gray"); + QProcess* pdftops = new QProcess(this); + pdftops->setProgram("pdftops"); + // -duplex? + pdftops->setArguments({"-paper", ShortPaperSize, filename, "-"}); + + pdftops->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + connect(pdftops, SIGNAL(finished(int, QProcess::ExitStatus)), pdftops, SLOT(deleteLater())); + + pdftops->start(); + + qDebug() << "Starting"; + + if(!pdftops->waitForStarted()) + { + qDebug() << "pdftops died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + + qDebug() << "Started"; + + if(!pdftops->waitForFinished()) + { + qDebug() << "pdftops failed"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } } - pdftoppm->setArguments(Pdf2PpmArgs); - - - QProcess* ppm2pwg = new QProcess(this); - // Yo dawg, I heard you like programs... - ppm2pwg->setProgram("harbour-seaprint"); - ppm2pwg->setArguments({"ppm2pwg"}); - - QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, pages); - qDebug() << "ppm2pwg env is " << env; - - ppm2pwg->setEnvironment(env); - - pdftocairo->setStandardOutputProcess(pdftoppm); - pdftoppm->setStandardOutputProcess(ppm2pwg); - ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); - - connect(pdftocairo, SIGNAL(finished(int, QProcess::ExitStatus)), pdftocairo, SLOT(deleteLater())); - connect(pdftoppm, SIGNAL(finished(int, QProcess::ExitStatus)), pdftoppm, SLOT(deleteLater())); - connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); - - qDebug() << "All connected"; - - pdftocairo->start(); - pdftoppm->start(); - ppm2pwg->start(); - - qDebug() << "Starting"; - - if(!pdftocairo->waitForStarted()) + else { - qDebug() << "pdftocairo died"; - tempfile->deleteLater(); - emit failed(tr("Conversion error")); - return; - } - if(!pdftoppm->waitForStarted()) - { - qDebug() << "pdftoppm died"; - tempfile->deleteLater(); - emit failed(tr("Conversion error")); - return; - } - if(!ppm2pwg->waitForStarted()) - { - qDebug() << "ppm2pwg died"; - tempfile->deleteLater(); - emit failed(tr("Conversion error")); - return; - } - qDebug() << "All started"; - ppm2pwg->waitForFinished(); + QProcess* pdftocairo = new QProcess(this); + pdftocairo->setProgram("pdftocairo"); + pdftocairo->setArguments({"-pdf", "-paper", ShortPaperSize, filename, "-"}); + + QProcess* pdftoppm = new QProcess(this); + pdftoppm->setProgram("pdftoppm"); + QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)}; + if(Colors != 3) + { + Pdf2PpmArgs.append("-gray"); + } + pdftoppm->setArguments(Pdf2PpmArgs); + + + QProcess* ppm2pwg = new QProcess(this); + // Yo dawg, I heard you like programs... + ppm2pwg->setProgram("harbour-seaprint"); + ppm2pwg->setArguments({"ppm2pwg"}); + + QStringList env; + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, pages); + qDebug() << "ppm2pwg env is " << env; + + ppm2pwg->setEnvironment(env); + + pdftocairo->setStandardOutputProcess(pdftoppm); + pdftoppm->setStandardOutputProcess(ppm2pwg); + ppm2pwg->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); + + connect(pdftocairo, SIGNAL(finished(int, QProcess::ExitStatus)), pdftocairo, SLOT(deleteLater())); + connect(pdftoppm, SIGNAL(finished(int, QProcess::ExitStatus)), pdftoppm, SLOT(deleteLater())); + connect(ppm2pwg, SIGNAL(finished(int, QProcess::ExitStatus)), ppm2pwg, SLOT(deleteLater())); + + qDebug() << "All connected"; + + pdftocairo->start(); + pdftoppm->start(); + ppm2pwg->start(); + + qDebug() << "Starting"; + + if(!pdftocairo->waitForStarted()) + { + qDebug() << "pdftocairo died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + if(!pdftoppm->waitForStarted()) + { + qDebug() << "pdftoppm died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + if(!ppm2pwg->waitForStarted()) + { + qDebug() << "ppm2pwg died"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + qDebug() << "All started"; + + + if(!ppm2pwg->waitForFinished()) + { + qDebug() << "ppm2pwg failed"; + tempfile->deleteLater(); + emit failed(tr("Conversion error")); + return; + } + } + qDebug() << "Finished"; diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 2e65f7d..f5c05f6 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -286,7 +286,7 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray { if(mimeType == "application/pdf") { - return firstMatch(supportedMimeTypes, {"application/pdf", "image/pwg-raster", "image/urf" /*, "application/postscript"*/ }); + return firstMatch(supportedMimeTypes, {"application/pdf", "application/postscript", "image/pwg-raster", "image/urf" }); } else if (mimeType.contains("image")) { From 37c0abee74ea57de242a46361c37b4a696861db6 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 16:12:42 +0200 Subject: [PATCH 82/94] Enable translation/prettification of media-source --- qml/pages/utils.js | 16 +++++++++++++++- translations/harbour-seaprint-de.ts | 20 ++++++++++++++++---- translations/harbour-seaprint-es.ts | 20 ++++++++++++++++---- translations/harbour-seaprint-fr.ts | 20 ++++++++++++++++---- translations/harbour-seaprint-zh_CN.ts | 20 ++++++++++++++++---- translations/harbour-seaprint.ts | 20 ++++++++++++++++---- 6 files changed, 95 insertions(+), 21 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index eb0797b..0f7f3cb 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -99,7 +99,7 @@ function ippName(name, value) case "document-format": switch(value) { case "application/octet-stream": - return qsTr("Auto-sense"); + return qsTr("auto-sense"); case "application/pdf": return qsTr("PDF"); case "application/postscript": @@ -117,6 +117,20 @@ function ippName(name, value) default: return value; } + case "media-source": + if(value.indexOf("tray-")==0) + { + return qsTr("tray")+" "+value.split("-")[1]; + } + else if(value=="by-pass-tray") + { + return qsTr("by-pass tray"); + } + else if(value=="auto") + { + return qsTr("auto"); + } + return value; } return value; } diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 60527e1..b55e1b4 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -370,10 +370,6 @@ dots/cm - - Auto-sense - - PDF @@ -402,5 +398,21 @@ GIF + + auto-sense + + + + by-pass tray + + + + auto + + + + tray + + diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index d9742b8..90b58ab 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -370,10 +370,6 @@ dots/cm ppp - - Auto-sense - - PDF @@ -402,5 +398,21 @@ GIF + + auto-sense + + + + by-pass tray + + + + auto + + + + tray + + diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 2fc0390..6acdf78 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -370,10 +370,6 @@ dots/cm pts/cm - - Auto-sense - - PDF @@ -402,5 +398,21 @@ GIF + + auto-sense + + + + by-pass tray + + + + auto + + + + tray + + diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 3ebedfa..039297b 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -370,10 +370,6 @@ dots/cm 点/厘米 - - Auto-sense - - PDF @@ -402,5 +398,21 @@ GIF + + auto-sense + + + + by-pass tray + + + + auto + + + + tray + + diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index a52e184..7e657c3 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -370,10 +370,6 @@ dots/cm - - Auto-sense - - PDF @@ -402,5 +398,21 @@ GIF + + auto-sense + + + + by-pass tray + + + + auto + + + + tray + + From 231e7df644045ae59da1c8f52387814b59602240 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 6 Jun 2020 17:20:30 +0200 Subject: [PATCH 83/94] Expose IPP type enums to QML --- qml/pages/PrinterPage.qml | 33 +++++++++++++++++---------------- src/harbour-seaprint.cpp | 1 + src/ippmsg.h | 7 +++++-- src/ippprinter.h | 2 -- 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 9f0b925..a907033 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -1,6 +1,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import seaprint.mimer 1.0 +import seaprint.ippmsg 1.0 import "utils.js" as Utils import Nemo.Configuration 1.0 @@ -55,16 +56,16 @@ Page { ListModel { id:mod - ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: 0x23} - ListElement {name: "media"; prettyName: qsTr("Print media"); tag: 0x44} - ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: 0x21} -// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: 0x33} - ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: 0x23} -// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: 0x23} - ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: 0x23} - ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: 0x32} - ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: 0x49} - ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: 0x44} + ListElement {name: "sides"; prettyName: qsTr("Sides"); tag: IppMsg.Enum} + ListElement {name: "media"; prettyName: qsTr("Print media"); tag: IppMsg.Keyword} + ListElement {name: "copies"; prettyName: qsTr("Copies"); tag: IppMsg.Integer} +// ListElement {name: "page-ranges"; prettyName: qsTr("Page range"); tag: IppMsg.IntegerRange} + ListElement {name: "print-color-mode"; prettyName: qsTr("Color mode"); tag: IppMsg.Enum} +// ListElement {name: "orientation-requested"; prettyName: qsTr("Orientation"); tag: IppMsg.Enum} + ListElement {name: "print-quality"; prettyName: qsTr("Quality"); tag: IppMsg.Enum} + ListElement {name: "printer-resolution"; prettyName: qsTr("Resolution"); tag: IppMsg.Resolution} + ListElement {name: "document-format"; prettyName: qsTr("Transfer format"); tag: IppMsg.MimeMediaType} + ListElement {name: "media-source"; prettyName: qsTr("Media source"); tag: IppMsg.Keyword} } SilicaListView { @@ -96,7 +97,7 @@ Page { Component.onCompleted: { switch(tag) { - case 0x21: + case IppMsg.Integer: loader.setSource("../components/IntegerSetting.qml", {name: name, prettyName: prettyName, @@ -107,7 +108,7 @@ Page { default_choice: printer.attrs[name+"-default"].value }) break - case 0x33: + case IppMsg.IntegerRange: loader.setSource("../components/RangeSetting.qml", {name: name, prettyName: prettyName, @@ -115,10 +116,10 @@ Page { valid: false //TODO printer.attrs.hasOwnProperty(name+"-supported"), }) break - case 0x32: - case 0x23: - case 0x44: - case 0x49: + case IppMsg.Resolution: + case IppMsg.Enum: + case IppMsg.Keyword: + case IppMsg.MimeMediaType: loader.setSource("../components/ChoiceSetting.qml", {name: name, prettyName: prettyName, diff --git a/src/harbour-seaprint.cpp b/src/harbour-seaprint.cpp index 5b2252c..468de25 100644 --- a/src/harbour-seaprint.cpp +++ b/src/harbour-seaprint.cpp @@ -37,6 +37,7 @@ int main(int argc, char *argv[]) qmlRegisterSingletonType("seaprint.mimer", 1, 0, "Mimer", singletontype_provider); qmlRegisterSingletonType("seaprint.convertchecker", 1, 0, "ConvertChecker", singletontype_provider); qmlRegisterType("seaprint.ippprinter", 1, 0, "IppPrinter"); + qmlRegisterUncreatableType("seaprint.ippmsg", 1, 0, "IppMsg", "Only used to supply an enum type"); QQuickView* view = SailfishApp::createView(); diff --git a/src/ippmsg.h b/src/ippmsg.h index 6b31af9..9cba800 100644 --- a/src/ippmsg.h +++ b/src/ippmsg.h @@ -4,6 +4,7 @@ #include "bytestream.h" #include +#include #include #include #include @@ -12,6 +13,7 @@ class IppMsg { + Q_GADGET public: enum IppTag : quint8 { @@ -39,6 +41,7 @@ public: NaturalLanguage = 0x48, MimeMediaType = 0x49 }; + Q_ENUMS(IppTag) enum Operation : quint16 { PrintJob = 0x0002, @@ -59,8 +62,8 @@ public: PurgeJobs = 0x0012 }; - IppMsg(); - IppMsg(QNetworkReply* resp); + explicit IppMsg(); + explicit IppMsg(QNetworkReply* resp); IppMsg(QJsonObject opAttrs, QJsonObject jobAttrs = QJsonObject()); IppMsg(const IppMsg& other) = default; ~IppMsg(); diff --git a/src/ippprinter.h b/src/ippprinter.h index 7a8ea5a..7ee6c57 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -31,8 +31,6 @@ public: Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool cancelJob(qint32 jobId); - bool hasPrinterDeviceIdCmd(QString cmd); - signals: void urlChanged(); void attrsChanged(); From 13a66f358b3f98a7836f3aa1d6247cfd8ebfc513 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 11:06:14 +0200 Subject: [PATCH 84/94] Make ChoiceSetting work when there are more choices than can fit on the screen --- harbour-seaprint.pro | 1 + qml/components/ChoiceSetting.qml | 15 ++++++++++- qml/components/LargeChoiceDialog.qml | 40 ++++++++++++++++++++++++++++ qml/pages/PrinterPage.qml | 24 +++++++++-------- 4 files changed, 68 insertions(+), 12 deletions(-) create mode 100644 qml/components/LargeChoiceDialog.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 588e6ac..ce025df 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -32,6 +32,7 @@ SOURCES += src/harbour-seaprint.cpp \ ppm2pwg/bytestream/bytestream.cpp DISTFILES += qml/harbour-seaprint.qml \ + qml/components/LargeChoiceDialog.qml \ qml/cover/CoverPage.qml \ qml/components/*.qml \ qml/pages/*.qml \ diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index ad0d577..06fd646 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -8,6 +8,8 @@ Setting { property var limited_choices: Utils.limitChoices(name, choices, mime_type) + property int num_large_choices: 8 + ValueButton { enabled: valid anchors.verticalCenter: parent.verticalCenter @@ -16,9 +18,20 @@ Setting { onClicked: parent.clicked() } + onClicked: { + if(limited_choices.length>num_large_choices) + { + var dialog = pageStack.push("LargeChoiceDialog.qml", + {name:name, choice: choice ? choice : default_choice, choices: limited_choices}) + dialog.accepted.connect(function() { + choice = dialog.choice + }) + } + } + property var menu: ContextMenu { id: menu - enabled: valid + enabled: valid && limited_choices.length <= num_large_choices Repeater { model: limited_choices MenuItem { diff --git a/qml/components/LargeChoiceDialog.qml b/qml/components/LargeChoiceDialog.qml new file mode 100644 index 0000000..7adaa9f --- /dev/null +++ b/qml/components/LargeChoiceDialog.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "../pages/utils.js" as Utils + +Dialog { + id: dialog + + property string name + property string choice + property string new_choice: choice + property var choices + canAccept: false + + SilicaListView + { + anchors.fill: parent + + header: DialogHeader {} + + model: choices + delegate: BackgroundItem { + onClicked: { + new_choice=choices[index] + dialog.canAccept = true + } + Label { + x: Theme.paddingLarge + anchors.verticalCenter: parent.verticalCenter + highlighted: choices[index]==new_choice + text: Utils.ippName(name, choices[index]) + } + } + } + + onDone: { + if (result == DialogResult.Accepted) { + choice = new_choice + } + } +} diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index a907033..a021ad2 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -93,6 +93,19 @@ Page { Loader { id: loader anchors.fill: parent + + onLoaded: { + if(loaderItem.menu.enabled) + { + menu = loaderItem.menu + loaderItem.clicked.connect(openMenu) + } + loaderItem.choiceMade.connect(function(tag, choice) { + console.log("choice changed", tag, JSON.stringify(choice)) + jobParams[name] = {tag: tag, value: choice}; + console.log(JSON.stringify(jobParams)); + }) + } } Component.onCompleted: { @@ -134,17 +147,6 @@ Page { } } - onLoaderItemChanged: { - menu = loaderItem.menu - loaderItem.clicked.connect(function() { - openMenu() - }) - loaderItem.choiceMade.connect(function(tag, choice) { - console.log("choice changed", tag, JSON.stringify(choice)) - jobParams[name] = {tag: tag, value: choice}; - console.log(JSON.stringify(jobParams)); - }) - } } VerticalScrollDecorator {} From ee0fc56bdea487c8b366e5907ee95c483332c7a0 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 12:18:10 +0200 Subject: [PATCH 85/94] Limit transfer formats when PDF tools not installed --- qml/components/ChoiceSetting.qml | 3 ++- qml/pages/utils.js | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/qml/components/ChoiceSetting.qml b/qml/components/ChoiceSetting.qml index 06fd646..e60f547 100644 --- a/qml/components/ChoiceSetting.qml +++ b/qml/components/ChoiceSetting.qml @@ -1,12 +1,13 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 +import seaprint.convertchecker 1.0 import "../pages/utils.js" as Utils Setting { property var choices property string mime_type - property var limited_choices: Utils.limitChoices(name, choices, mime_type) + property var limited_choices: Utils.limitChoices(name, choices, mime_type, ConvertChecker) property int num_large_choices: 8 diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 0f7f3cb..257171f 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -146,6 +146,12 @@ function canConvertPdfTo(type) return has(targets, type) } +function canTransferPdfAs(type) +{ + var targets = ["application/octet-stream", "application/pdf"]; + return has(targets, type) +} + function canConvertImageTo(type) { var targets = ["application/octet-stream", "image/jpeg", "image/png", "image/pwg-raster", "image/urf", "image/gif"]; @@ -158,13 +164,21 @@ function unitsIsDpi(resolution) } -function limitChoices(name, choices, mimeType) +function limitChoices(name, choices, mimeType, ConvertChecker) { switch(name) { case "document-format": if(mimeType == "application/pdf") { - return choices.filter(canConvertPdfTo) + if(ConvertChecker.pdf) + { + return choices.filter(canConvertPdfTo) + } + else + { + return choices.filter(canTransferPdfAs) + } + } else if(mimeType == "image/jpeg" || mimeType == "image/png") { From 5df016b0fa386c5c563d260c034d3157ffabcb05 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 14:28:54 +0200 Subject: [PATCH 86/94] Add nag-screen --- harbour-seaprint.pro | 1 + qml/harbour-seaprint.qml | 9 +++ qml/pages/FirstPage.qml | 16 ++++- qml/pages/NagScreen.qml | 82 ++++++++++++++++++++++++++ translations/harbour-seaprint-de.ts | 31 ++++++++++ translations/harbour-seaprint-es.ts | 31 ++++++++++ translations/harbour-seaprint-fr.ts | 31 ++++++++++ translations/harbour-seaprint-zh_CN.ts | 31 ++++++++++ translations/harbour-seaprint.ts | 31 ++++++++++ 9 files changed, 261 insertions(+), 2 deletions(-) create mode 100644 qml/pages/NagScreen.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index ce025df..48a3da5 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -40,6 +40,7 @@ DISTFILES += qml/harbour-seaprint.qml \ qml/pages/*svg \ qml/pages/BusyPage.qml \ qml/pages/DebugPage.qml \ + qml/pages/NagScreen.qml \ rpm/harbour-seaprint.changes.in \ rpm/harbour-seaprint.changes.run.in \ rpm/harbour-seaprint.spec \ diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index 8431cf3..d0e037a 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 import Sailfish.Silica 1.0 import QtQuick.LocalStorage 2.0 import Nemo.Notifications 1.0 +import Nemo.Configuration 1.0 import "pages" ApplicationWindow @@ -73,5 +74,13 @@ ApplicationWindow publish() } } + + ConfigurationValue + { + id: nagScreenSetting + key: "/apps/harbour-seaprint/settings/nag-screen" + defaultValue: 0 + property int expectedValue: 1 + } } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index 723b31b..bc8f1d8 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -46,7 +46,6 @@ Page { signal refreshed() Component.onCompleted: { - console.log("Can convert from PDF:", ConvertChecker.pdf) IppDiscovery.discover(); if(selectedFile != "") { @@ -56,6 +55,20 @@ Page { } } + property bool nagged: false + + onStatusChanged: { + if(status==PageStatus.Active && !nagged && nagScreenSetting.value != nagScreenSetting.expectedValue) + { + console.log("Can convert from PDF:", ConvertChecker.pdf) + if(!ConvertChecker.pdf) + { + nagged=true + pageStack.push(Qt.resolvedUrl("NagScreen.qml")) + } + } + } + // To enable PullDownMenu, place our content in a SilicaFlickable SilicaFlickable { anchors.fill: parent @@ -107,7 +120,6 @@ Page { Connections { target: printer onAttrsChanged: { - console.log(printer.url, Object.keys(printer.attrs)) if(Object.keys(printer.attrs).length === 0) { delegate.visible = false } diff --git a/qml/pages/NagScreen.qml b/qml/pages/NagScreen.qml new file mode 100644 index 0000000..658e8f7 --- /dev/null +++ b/qml/pages/NagScreen.qml @@ -0,0 +1,82 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Page { + backNavigation: false + + Column { + y: Theme.paddingLarge + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 2*Theme.paddingLarge + spacing: Theme.paddingLarge + + Label { + width: parent.width + wrapMode: Text.WordWrap + + text: qsTr("Optional dependencies are not installed!") + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + + text: qsTr("In order to convert PDF files to other formats, you need utilities from the package \"poppler-utils\"") + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + + text: qsTr("To install, enable delveloper mode, and open a terminal.") + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + + text: qsTr("Become root:") + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + font.family: "monospace" + + text: "devel-su" + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + + text: qsTr("Install poppler-utils:") + } + + Label { + width: parent.width + wrapMode: Text.WordWrap + font.family: "monospace" + + text: "pkcon install poppler-utils" + } + + Item{} + + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Dismiss") + onClicked: pageStack.pop() + } + + Button { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Don't show again") + onClicked: { + nagScreenSetting.value = nagScreenSetting.expectedValue + pageStack.pop() + } + } + } + +} diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index b55e1b4..89afc70 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -253,6 +253,37 @@ + + NagScreen + + Dismiss + + + + Don't show again + + + + Optional dependencies are not installed! + + + + In order to convert PDF files to other formats, you need utilities from the package "poppler-utils" + + + + To install, enable delveloper mode, and open a terminal. + + + + Become root: + + + + Install poppler-utils: + + + PrinterPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index 90b58ab..cae287f 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -253,6 +253,37 @@ + + NagScreen + + Dismiss + + + + Don't show again + + + + Optional dependencies are not installed! + + + + In order to convert PDF files to other formats, you need utilities from the package "poppler-utils" + + + + To install, enable delveloper mode, and open a terminal. + + + + Become root: + + + + Install poppler-utils: + + + PrinterPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 6acdf78..e3a70bf 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -253,6 +253,37 @@ Échec de l'annulation de la tâche d'impression + + NagScreen + + Dismiss + + + + Don't show again + + + + Optional dependencies are not installed! + + + + In order to convert PDF files to other formats, you need utilities from the package "poppler-utils" + + + + To install, enable delveloper mode, and open a terminal. + + + + Become root: + + + + Install poppler-utils: + + + PrinterPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 039297b..c458bc6 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -253,6 +253,37 @@ 作业失败 + + NagScreen + + Dismiss + + + + Don't show again + + + + Optional dependencies are not installed! + + + + In order to convert PDF files to other formats, you need utilities from the package "poppler-utils" + + + + To install, enable delveloper mode, and open a terminal. + + + + Become root: + + + + Install poppler-utils: + + + PrinterPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 7e657c3..6e18016 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -253,6 +253,37 @@ + + NagScreen + + Dismiss + + + + Don't show again + + + + Optional dependencies are not installed! + + + + In order to convert PDF files to other formats, you need utilities from the package "poppler-utils" + + + + To install, enable delveloper mode, and open a terminal. + + + + Become root: + + + + Install poppler-utils: + + + PrinterPage From dae84a97c9637f85cb3d9ae9fc28afa924214fb9 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 14:33:35 +0200 Subject: [PATCH 87/94] Move settings --- qml/harbour-seaprint.qml | 21 +++++++++++++++++++++ qml/pages/PrinterPage.qml | 26 +++----------------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index d0e037a..e54f043 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -82,5 +82,26 @@ ApplicationWindow defaultValue: 0 property int expectedValue: 1 } + + ConfigurationValue + { + id: alwaysConvertSetting + key: "/apps/harbour-seaprint/settings/always-convert" + defaultValue: false + } + + ConfigurationValue + { + id: forceIncluDeDocumentFormatSetting + key: "/apps/harbour-seaprint/settings/force-include-document-format" + defaultValue: false + } + + ConfigurationValue + { + id: removeRedundantAttributesForRasterSetting + key: "/apps/harbour-seaprint/settings/remove-redundant-raster-attributes" + defaultValue: true + } } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index a021ad2..53cc9a9 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -3,7 +3,6 @@ import Sailfish.Silica 1.0 import seaprint.mimer 1.0 import seaprint.ippmsg 1.0 import "utils.js" as Utils -import Nemo.Configuration 1.0 Page { id: page @@ -11,27 +10,6 @@ Page { property var jobParams: new Object(); property string selectedFile - ConfigurationValue - { - id: alwaysConvert - key: "/apps/harbour-seaprint/settings/always_convert" - defaultValue: false - } - - ConfigurationValue - { - id: forceIncluDeDocumentFormat - key: "/apps/harbour-seaprint/settings/force_include_document_format" - defaultValue: false - } - - ConfigurationValue - { - id: removeRedundantAttributesForRaster - key: "/apps/harbour-seaprint/settings/remove_redundant_attributes_for_raster" - defaultValue: true - } - Component.onCompleted: { console.log(JSON.stringify(printer.attrs)) } @@ -49,7 +27,9 @@ Page { pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer}, PageStackAction.Immediate) printer.print(jobParams, page.selectedFile, - alwaysConvert.value, forceIncluDeDocumentFormat.value, removeRedundantAttributesForRaster.value) + alwaysConvertSetting.value, + forceIncluDeDocumentFormatSetting.value, + removeRedundantAttributesForRasterSetting.value) } } } From 8b3ffad51311c9e2e2695f7fbf2098938c87bdcc Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 14:54:15 +0200 Subject: [PATCH 88/94] Add setting to (not) consider additional formats --- qml/harbour-seaprint.qml | 7 +++++++ qml/pages/FirstPage.qml | 6 ++---- qml/pages/PrinterPage.qml | 11 +++++++++-- qml/pages/utils.js | 9 +++++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index e54f043..6e3acb9 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -103,5 +103,12 @@ ApplicationWindow key: "/apps/harbour-seaprint/settings/remove-redundant-raster-attributes" defaultValue: true } + + ConfigurationValue + { + id: considerAdditionalFormatsSetting + key: "/apps/harbour-seaprint/settings/consider-additional-formats" + defaultValue: true + } } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index bc8f1d8..a631a3a 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -115,7 +115,7 @@ Page { visible: false property string name: printer.attrs["printer-name"].value != "" ? printer.attrs["printer-name"].value : qsTr("Unknown") - property bool canPrint: Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1 + property bool canPrint: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).mimetypes.indexOf(selectedFileType) != -1 Connections { target: printer @@ -152,8 +152,6 @@ Page { property int debugCount: 0 onClicked: { - console.log(Utils.supported_formats(printer, ConvertChecker).mimetypes, selectedFileType, - Utils.supported_formats(printer, ConvertChecker).mimetypes.indexOf(selectedFileType) != -1) if(++debugCount == 5) { @@ -231,7 +229,7 @@ Page { id: format_label color: selectedFile == "" ? Theme.secondaryColor : canPrint ? Theme.primaryColor : "red" font.pixelSize: Theme.fontSizeExtraSmall - text: Utils.supported_formats(printer, ConvertChecker).supported + text: Utils.supported_formats(printer, ConvertChecker, considerAdditionalFormatsSetting.value).supported } } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 53cc9a9..60dd87c 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -118,8 +118,7 @@ Page { prettyName: prettyName, tag: tag, valid: printer.attrs.hasOwnProperty(name+"-supported"), - choices: name == "document-format" ? printer.attrs[name+"-supported"].value.concat(printer.additionalDocumentFormats) - : printer.attrs[name+"-supported"].value, + choices: maybeSupplementChoices(name, printer.attrs[name+"-supported"].value), default_choice: printer.attrs[name+"-default"].value, mime_type: Mimer.get_type(selectedFile) }) @@ -127,6 +126,14 @@ Page { } } + function maybeSupplementChoices(name, choices) + { + if(name == "document-format" && considerAdditionalFormatsSetting.value) + { + return choices.concat(printer.additionalDocumentFormats) + } + return choices + } } VerticalScrollDecorator {} diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 257171f..97e4b7a 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -1,6 +1,11 @@ -function supported_formats(printer, ConvertChecker) +function supported_formats(printer, ConvertChecker, considerAdditionalFormats) { - var formats = printer.attrs["document-format-supported"].value+printer.additionalDocumentFormats; + var formats = printer.attrs["document-format-supported"].value; + if(considerAdditionalFormats) + { + formats=formats+printer.additionalDocumentFormats; + } + var mimetypes = []; var supported = []; if(has(formats, "application/pdf") || From 3bf59f0141d9d849e89cf159df564c9053415ba1 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 15:27:27 +0200 Subject: [PATCH 89/94] Remove duplex from IPP attributes if PS --- qml/harbour-seaprint.qml | 4 ++-- qml/pages/PrinterPage.qml | 2 +- src/convertworker.cpp | 8 ++++++-- src/ippprinter.cpp | 11 ++++++++--- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index 6e3acb9..dd12a20 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -99,8 +99,8 @@ ApplicationWindow ConfigurationValue { - id: removeRedundantAttributesForRasterSetting - key: "/apps/harbour-seaprint/settings/remove-redundant-raster-attributes" + id: removeRedundantConvertAttrsSetting + key: "/apps/harbour-seaprint/settings/remove-redundant-convert-attributes" defaultValue: true } diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index 60dd87c..8fe0294 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -29,7 +29,7 @@ Page { printer.print(jobParams, page.selectedFile, alwaysConvertSetting.value, forceIncluDeDocumentFormatSetting.value, - removeRedundantAttributesForRasterSetting.value) + removeRedundantConvertAttrsSetting.value) } } } diff --git a/src/convertworker.cpp b/src/convertworker.cpp index dba41a6..6cb8be0 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -126,8 +126,12 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo { QProcess* pdftops = new QProcess(this); pdftops->setProgram("pdftops"); - // -duplex? - pdftops->setArguments({"-paper", ShortPaperSize, filename, "-"}); + QStringList PdfToPsArgs = {"-paper", ShortPaperSize, filename, "-"}; + if(TwoSided) + { + PdfToPsArgs.prepend("-duplex"); + } + pdftops->setArguments(PdfToPsArgs); pdftops->setStandardOutputFile(tempfile->fileName(), QIODevice::Append); connect(pdftops, SIGNAL(finished(int, QProcess::ExitStatus)), pdftops, SLOT(deleteLater())); diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index f5c05f6..4c1ae08 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -298,10 +298,10 @@ QString targetFormatIfAuto(QString documentFormat, QString mimeType, QJsonArray } void IppPrinter::print(QJsonObject attrs, QString filename, - bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantAttributesForRaster) + bool alwaysConvert, bool forceIncluDeDocumentFormat, bool removeRedundantConvertAttrs) { qDebug() << "printing" << filename << attrs - << alwaysConvert << forceIncluDeDocumentFormat << removeRedundantAttributesForRaster; + << alwaysConvert << forceIncluDeDocumentFormat << removeRedundantConvertAttrs; _progress = ""; emit progressChanged(); @@ -392,11 +392,16 @@ void IppPrinter::print(QJsonObject attrs, QString filename, } QString Sides = getAttrOrDefault(attrs, "sides").toString(); - if(removeRedundantAttributesForRaster && (documentFormat=="image/pwg-raster" || documentFormat=="image/urf")) + if(removeRedundantConvertAttrs && (documentFormat=="image/pwg-raster" || + documentFormat=="image/urf")) { attrs.remove("sides"); attrs.remove("print-color-mode"); } + if(removeRedundantConvertAttrs && documentFormat == "application/postscript") + { + attrs.remove("sides"); + } qDebug() << "Final job attributes:" << attrs; From 40fe4c2b9098cff969a6eb756db35e26bdd8a2e1 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 17:05:46 +0200 Subject: [PATCH 90/94] Add settings page --- harbour-seaprint.pro | 1 + qml/harbour-seaprint.qml | 13 ++--- qml/pages/FirstPage.qml | 6 ++- qml/pages/SettingsPage.qml | 71 ++++++++++++++++++++++++++ translations/harbour-seaprint-de.ts | 47 +++++++++++++++++ translations/harbour-seaprint-es.ts | 47 +++++++++++++++++ translations/harbour-seaprint-fr.ts | 47 +++++++++++++++++ translations/harbour-seaprint-zh_CN.ts | 47 +++++++++++++++++ translations/harbour-seaprint.ts | 47 +++++++++++++++++ 9 files changed, 319 insertions(+), 7 deletions(-) create mode 100644 qml/pages/SettingsPage.qml diff --git a/harbour-seaprint.pro b/harbour-seaprint.pro index 48a3da5..e69d15b 100644 --- a/harbour-seaprint.pro +++ b/harbour-seaprint.pro @@ -41,6 +41,7 @@ DISTFILES += qml/harbour-seaprint.qml \ qml/pages/BusyPage.qml \ qml/pages/DebugPage.qml \ qml/pages/NagScreen.qml \ + qml/pages/SettingsPage.qml \ rpm/harbour-seaprint.changes.in \ rpm/harbour-seaprint.changes.run.in \ rpm/harbour-seaprint.spec \ diff --git a/qml/harbour-seaprint.qml b/qml/harbour-seaprint.qml index dd12a20..a3d06e4 100644 --- a/qml/harbour-seaprint.qml +++ b/qml/harbour-seaprint.qml @@ -83,6 +83,13 @@ ApplicationWindow property int expectedValue: 1 } + ConfigurationValue + { + id: considerAdditionalFormatsSetting + key: "/apps/harbour-seaprint/settings/consider-additional-formats" + defaultValue: true + } + ConfigurationValue { id: alwaysConvertSetting @@ -104,11 +111,5 @@ ApplicationWindow defaultValue: true } - ConfigurationValue - { - id: considerAdditionalFormatsSetting - key: "/apps/harbour-seaprint/settings/consider-additional-formats" - defaultValue: true - } } diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index a631a3a..1611295 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -78,7 +78,11 @@ Page { MenuItem { text: qsTr("About SeaPrint") onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml")) - } + } + MenuItem { + text: qsTr("Settings") + onClicked: pageStack.push(Qt.resolvedUrl("SettingsPage.qml")) + } MenuItem { text: qsTr("Add by URL") enabled: wifi.connected diff --git a/qml/pages/SettingsPage.qml b/qml/pages/SettingsPage.qml new file mode 100644 index 0000000..5ff3c38 --- /dev/null +++ b/qml/pages/SettingsPage.qml @@ -0,0 +1,71 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 + +Page { + SilicaFlickable { + anchors.fill: parent + contentHeight: column.height + + Column { + id: column + anchors.horizontalCenter: parent.horizontalCenter + width: parent.width - 2*Theme.paddingLarge + spacing: Theme.paddingLarge + + PageHeader{} + + TextSwitch { + text: qsTr("Show nag-screen") + description: qsTr("Display the warning page about optional dependencies not being installed, if they are not installed.") + checked: nagScreenSetting.value != nagScreenSetting.expectedValue + onCheckedChanged: { + if(checked) + { + nagScreenSetting.value=0 + } + else + { + nagScreenSetting.value = nagScreenSetting.expectedValue + } + } + } + + TextSwitch { + text: qsTr("Consider additional formats") + description: qsTr("Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF.") + checked: considerAdditionalFormatsSetting.value + onCheckedChanged: { + considerAdditionalFormatsSetting.value = checked + } + } + + TextSwitch { + text: qsTr("Always convert to raster format") + description: qsTr("Force conversion to PWG/URF raster format. This is mainly intended for testing.") + checked: alwaysConvertSetting.value + onCheckedChanged: { + alwaysConvertSetting.value = checked + } + } + + TextSwitch { + text: qsTr("Force-include document format") + description: qsTr("Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it.") + checked: forceIncluDeDocumentFormatSetting.value + onCheckedChanged: { + forceIncluDeDocumentFormatSetting.value = checked + } + } + + TextSwitch { + text: qsTr("Remove redundant attributes") + description: qsTr("Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent.") + checked: removeRedundantConvertAttrsSetting.value + onCheckedChanged: { + removeRedundantConvertAttrsSetting.value = checked + } + } + + } + } +} diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 89afc70..062a67e 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -202,6 +202,10 @@ Choose file + + Settings + + IppPrinter @@ -323,6 +327,49 @@ + + SettingsPage + + Show nag-screen + + + + Consider additional formats + + + + Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF. + + + + Always convert to raster format + + + + Force conversion to PWG/URF raster format. This is mainly intended for testing. + + + + Force-include document format + + + + Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it. + + + + Remove redundant attributes + + + + Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent. + + + + Display the warning page about optional dependencies not being installed, if they are not installed. + + + utils diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index cae287f..f9e176e 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -202,6 +202,10 @@ Choose file Elegir archivo + + Settings + + IppPrinter @@ -323,6 +327,49 @@ + + SettingsPage + + Show nag-screen + + + + Consider additional formats + + + + Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF. + + + + Always convert to raster format + + + + Force conversion to PWG/URF raster format. This is mainly intended for testing. + + + + Force-include document format + + + + Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it. + + + + Remove redundant attributes + + + + Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent. + + + + Display the warning page about optional dependencies not being installed, if they are not installed. + + + utils diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index e3a70bf..7eeae20 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -202,6 +202,10 @@ Choose file Choisir un fichier + + Settings + + IppPrinter @@ -323,6 +327,49 @@ + + SettingsPage + + Show nag-screen + + + + Consider additional formats + + + + Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF. + + + + Always convert to raster format + + + + Force conversion to PWG/URF raster format. This is mainly intended for testing. + + + + Force-include document format + + + + Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it. + + + + Remove redundant attributes + + + + Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent. + + + + Display the warning page about optional dependencies not being installed, if they are not installed. + + + utils diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index c458bc6..8e1f652 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -202,6 +202,10 @@ Choose file 选择文件 + + Settings + + IppPrinter @@ -323,6 +327,49 @@ + + SettingsPage + + Show nag-screen + + + + Consider additional formats + + + + Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF. + + + + Always convert to raster format + + + + Force conversion to PWG/URF raster format. This is mainly intended for testing. + + + + Force-include document format + + + + Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it. + + + + Remove redundant attributes + + + + Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent. + + + + Display the warning page about optional dependencies not being installed, if they are not installed. + + + utils diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 6e18016..fc8e0a1 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -202,6 +202,10 @@ Choose file + + Settings + + IppPrinter @@ -323,6 +327,49 @@ + + SettingsPage + + Show nag-screen + + + + Consider additional formats + + + + Some printers support more formats than they advertise correctly. However, additional formats can be inferred from other attributes. Mainly relevant for Postscript-compatible printers that also support PDF. + + + + Always convert to raster format + + + + Force conversion to PWG/URF raster format. This is mainly intended for testing. + + + + Force-include document format + + + + Force the document-format attribute to be included. Some printers have trouble recognizing certain formats, sometimes it helps to include this atribute even if the printer does not claim to support it. + + + + Remove redundant attributes + + + + Remove redundant IPP attributes, if they are also conveyed in the transfer format. Some printers reject the job even if the settings are consistent. + + + + Display the warning page about optional dependencies not being installed, if they are not installed. + + + utils From a8f904d234d959a311da6baaa4f9aca36918fc8a Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 17:21:08 +0200 Subject: [PATCH 91/94] Update ppm2pwg to get srgb option --- ppm2pwg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppm2pwg b/ppm2pwg index a404a17..8565ddf 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit a404a177038626765b915ce0cf21527704bffd7e +Subproject commit 8565ddfe2e401e627daeca55d1b821085a1af0ea From f42dbf4484dfa52eaa00a3d60c56096a94f8b3dd Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 17:38:40 +0200 Subject: [PATCH 92/94] Use SRGB setting in ppm2pwg image->sRGB PDF->RGB --- src/convertworker.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 6cb8be0..3c30e26 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -6,7 +6,7 @@ #include void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, - quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble, quint32 pages) + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble, bool srgb, quint32 pages) { env.append("HWRES_X="+QString::number(HwResX)); env.append("HWRES_Y="+QString::number(HwResY)); @@ -28,6 +28,7 @@ void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, env.append("DUPLEX="+QString::number(TwoSided)); env.append("TUMBLE="+QString::number(Tumble)); + env.append("SRGB="+QString::number(srgb)); if(pages != 0) { @@ -181,7 +182,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, pages); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, false, pages); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); @@ -336,7 +337,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, 0); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, true, 0); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); From 6c1b33e96de4ed7e84eab5cbddee2df18e615a57 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sun, 7 Jun 2020 17:58:47 +0200 Subject: [PATCH 93/94] Enable more translations --- qml/pages/utils.js | 68 ++++++++++++++++++--- translations/harbour-seaprint-de.ts | 84 +++++++++++++++++++++++++- translations/harbour-seaprint-es.ts | 84 +++++++++++++++++++++++++- translations/harbour-seaprint-fr.ts | 84 +++++++++++++++++++++++++- translations/harbour-seaprint-zh_CN.ts | 84 +++++++++++++++++++++++++- translations/harbour-seaprint.ts | 84 +++++++++++++++++++++++++- 6 files changed, 471 insertions(+), 17 deletions(-) diff --git a/qml/pages/utils.js b/qml/pages/utils.js index 97e4b7a..142e7bf 100644 --- a/qml/pages/utils.js +++ b/qml/pages/utils.js @@ -101,6 +101,38 @@ function ippName(name, value) { return value; } + case "sides": + switch(value) { + case "one-sided": + return qsTr("one-sided"); + case "two-sided-long-edge": + return qsTr("two-sided"); + case "two-sided-short-edge": + return qsTr("two-sided flipped"); + default: + return value + } + case "print-color-mode": + switch(value) { + case "auto": + return qsTr("automatic"); + case "auto-monochrome": + return qsTr("auto monochrome"); + case "bi-level": + return qsTr("bi-level"); + case "color": + return qsTr("color"); + case "highlight": + return qsTr("highlight"); + case "monochrome": + return qsTr("monochrome"); + case "process-bi-level": + return qsTr("process bi-level"); + case "process-monochrome": + return qsTr("process monochrome"); + default: + return value + } case "document-format": switch(value) { case "application/octet-stream": @@ -127,15 +159,37 @@ function ippName(name, value) { return qsTr("tray")+" "+value.split("-")[1]; } - else if(value=="by-pass-tray") + else { - return qsTr("by-pass tray"); + switch(value) { + case "by-pass-tray": + return qsTr("by-pass tray"); + case "auto": + return qsTr("automatic"); + case "bottom": + return qsTr("bottom"); + case "center": + return qsTr("center"); + case "main": + return qsTr("main"); + case "manual": + return qsTr("manual"); + case "middle": + return qsTr("middle"); + case "photo": + return qsTr("photo"); + case "rear": + return qsTr("rear"); + case "right": + return qsTr("right"); + case "side": + return qsTr("side"); + case "top": + return qsTr("top"); + default: + return value; + } } - else if(value=="auto") - { - return qsTr("auto"); - } - return value; } return value; } diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 062a67e..235c42a 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -485,11 +485,91 @@ - auto + tray - tray + bottom + + + + center + + + + main + + + + manual + + + + middle + + + + photo + + + + rear + + + + right + + + + side + + + + top + + + + automatic + + + + auto monochrome + + + + bi-level + + + + color + + + + highlight + + + + monochrome + + + + process bi-level + + + + process monochrome + + + + one-sided + + + + two-sided + + + + two-sided flipped diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index f9e176e..fe4609a 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -485,11 +485,91 @@ - auto + tray - tray + bottom + + + + center + + + + main + + + + manual + + + + middle + + + + photo + + + + rear + + + + right + + + + side + + + + top + + + + automatic + + + + auto monochrome + + + + bi-level + + + + color + + + + highlight + + + + monochrome + + + + process bi-level + + + + process monochrome + + + + one-sided + + + + two-sided + + + + two-sided flipped diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 7eeae20..349bf0c 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -485,11 +485,91 @@ - auto + tray - tray + bottom + + + + center + + + + main + + + + manual + + + + middle + + + + photo + + + + rear + + + + right + + + + side + + + + top + + + + automatic + + + + auto monochrome + + + + bi-level + + + + color + + + + highlight + + + + monochrome + + + + process bi-level + + + + process monochrome + + + + one-sided + + + + two-sided + + + + two-sided flipped diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index 8e1f652..04b02e7 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -485,11 +485,91 @@ - auto + tray - tray + bottom + + + + center + + + + main + + + + manual + + + + middle + + + + photo + + + + rear + + + + right + + + + side + + + + top + + + + automatic + + + + auto monochrome + + + + bi-level + + + + color + + + + highlight + + + + monochrome + + + + process bi-level + + + + process monochrome + + + + one-sided + + + + two-sided + + + + two-sided flipped diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index fc8e0a1..9955698 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -485,11 +485,91 @@ - auto + tray - tray + bottom + + + + center + + + + main + + + + manual + + + + middle + + + + photo + + + + rear + + + + right + + + + side + + + + top + + + + automatic + + + + auto monochrome + + + + bi-level + + + + color + + + + highlight + + + + monochrome + + + + process bi-level + + + + process monochrome + + + + one-sided + + + + two-sided + + + + two-sided flipped From 54f15dc372cf9d973b0e0878870fbe97e18eb78b Mon Sep 17 00:00:00 2001 From: attah Date: Sun, 7 Jun 2020 20:29:03 +0200 Subject: [PATCH 94/94] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..2eca1b2 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: paypal.me/AntonThomasson