From 2f1e1bf7a561d9c0ea8ba36de5771c4c090f555f Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Mon, 28 Jun 2021 20:15:21 +0200 Subject: [PATCH] Add warning/hint about suffixes --- qml/pages/AddPrinterDialog.qml | 92 ++++++++++++++++++++------ src/ippprinter.cpp | 28 ++++++++ src/ippprinter.h | 6 +- translations/harbour-seaprint-de.ts | 16 +++++ translations/harbour-seaprint-es.ts | 16 +++++ translations/harbour-seaprint-fr.ts | 16 +++++ translations/harbour-seaprint-nl.ts | 16 +++++ translations/harbour-seaprint-pl.ts | 16 +++++ translations/harbour-seaprint-zh_CN.ts | 16 +++++ translations/harbour-seaprint.ts | 16 +++++ 10 files changed, 217 insertions(+), 21 deletions(-) diff --git a/qml/pages/AddPrinterDialog.qml b/qml/pages/AddPrinterDialog.qml index 4b7f2f6..2a039ae 100644 --- a/qml/pages/AddPrinterDialog.qml +++ b/qml/pages/AddPrinterDialog.qml @@ -82,30 +82,82 @@ Dialog { text: printerName ? printerName : "" } } - } - Row { - visible: valueField.text.indexOf(":9100") != -1 - - anchors.top: col.bottom - anchors.topMargin: Theme.paddingLarge*2 - anchors.horizontalCenter: parent.horizontalCenter - width: parent.width-2*Theme.paddingLarge - spacing: Theme.paddingMedium - - Icon { - id: warningIcon - source: "image://theme/icon-m-warning" - anchors.verticalCenter: parent.verticalCenter + Item { + width: 1 + height: 2*Theme.paddingLarge } - Label { - width: parent.width-warningIcon.width-Theme.paddingMedium - anchors.verticalCenter: parent.verticalCenter - color: Theme.highlightColor - wrapMode: Text.WordWrap - text: qsTr("Port 9100 is not used for IPP.") + Row { + visible: valueField.text.indexOf(":9100") != -1 + x: Theme.paddingLarge + + width: parent.width-2*Theme.paddingLarge + spacing: Theme.paddingMedium + + Icon { + id: warningIcon + source: "image://theme/icon-m-warning" + anchors.verticalCenter: parent.verticalCenter + } + + Label { + width: parent.width-warningIcon.width-Theme.paddingMedium + anchors.verticalCenter: parent.verticalCenter + color: Theme.highlightColor + wrapMode: Text.WordWrap + text: qsTr("Port 9100 is not used for IPP.") + } } + + Row { + id: suffixWarning + visible: canAccept && !printer.correctSuffix + x: Theme.paddingLarge + + width: parent.width-2*Theme.paddingLarge + spacing: Theme.paddingMedium + + Icon { + id: warningIcon2 + source: "image://theme/icon-m-warning" + anchors.verticalCenter: parent.verticalCenter + } + + Label { + width: parent.width-warningIcon2.width-Theme.paddingMedium + anchors.verticalCenter: parent.verticalCenter + color: Theme.highlightColor + wrapMode: Text.WordWrap + text: qsTr("The uri suffix is not in the printer's supported list.")+" "+ + qsTr("It might not accept print jobs on this address.")+" "+ + qsTr("Consider using a suffix like \"/ipp/print\".") + } + } + + Item { + width: 1 + height: 2*Theme.paddingLarge + } + + Label + { + x: Theme.paddingLarge + visible: suffixWarning.visible && printer.suffixes.length != 0 + text: qsTr("The printer/server lists these suffixes:") + } + + Repeater + { + model: suffixWarning.visible ? printer.suffixes : 0 + Label + { + x: Theme.paddingLarge + text: printer.suffixes[index] + } + + } + } onDone: { diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 5c45b71..46f6203 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -722,6 +722,34 @@ bool IppPrinter::isIpps() return _url.scheme() == "ipps"; } +bool IppPrinter::correctSuffix() +{ + foreach(QJsonValue u, _attrs["printer-uri-supported"].toObject()["value"].toArray()) + { + QUrl url(u.toString()); + if(url.path() == _url.path()) + { + return true; + } + } + return false; +} + +QStringList IppPrinter::suffixes() +{ + QStringList res; + foreach(QJsonValue u, _attrs["printer-uri-supported"].toObject()["value"].toArray()) + { + QUrl url(u.toString()); + if(!res.contains(url.path())) + { + res.append(url.path()); + } + } + res.sort(); + return res; +} + QUrl IppPrinter::httpUrl() { qDebug() << _url; QUrl url = _url; diff --git a/src/ippprinter.h b/src/ippprinter.h index 8e4cab7..770005c 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -19,7 +19,9 @@ class IppPrinter : public QObject Q_PROPERTY(QString progress MEMBER _progress NOTIFY progressChanged) Q_PROPERTY(bool tainted MEMBER _tainted NOTIFY taintedChanged) - Q_PROPERTY(bool isIpps READ isIpps() NOTIFY urlChanged) + Q_PROPERTY(bool isIpps READ isIpps NOTIFY urlChanged) + Q_PROPERTY(bool correctSuffix READ correctSuffix NOTIFY attrsChanged) + Q_PROPERTY(QStringList suffixes READ suffixes NOTIFY attrsChanged) public: IppPrinter(); @@ -35,6 +37,8 @@ public: Q_INVOKABLE bool cancelJob(qint32 jobId); bool isIpps(); + bool correctSuffix(); + QStringList suffixes(); signals: void urlChanged(); diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index 283d265..812eb53 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint-es.ts b/translations/harbour-seaprint-es.ts index d0bf2c1..8e8d5be 100644 --- a/translations/harbour-seaprint-es.ts +++ b/translations/harbour-seaprint-es.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint-fr.ts b/translations/harbour-seaprint-fr.ts index 8f24b08..91a400a 100644 --- a/translations/harbour-seaprint-fr.ts +++ b/translations/harbour-seaprint-fr.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint-nl.ts b/translations/harbour-seaprint-nl.ts index 84c3929..48ba1b5 100644 --- a/translations/harbour-seaprint-nl.ts +++ b/translations/harbour-seaprint-nl.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint-pl.ts b/translations/harbour-seaprint-pl.ts index e8eb2db..0865c21 100644 --- a/translations/harbour-seaprint-pl.ts +++ b/translations/harbour-seaprint-pl.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint-zh_CN.ts b/translations/harbour-seaprint-zh_CN.ts index a68e46e..c115d44 100644 --- a/translations/harbour-seaprint-zh_CN.ts +++ b/translations/harbour-seaprint-zh_CN.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. 端口9100未用于IPP。 + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index 862299d..59098a1 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -118,6 +118,22 @@ Port 9100 is not used for IPP. + + The uri suffix is not in the printer's supported list. + + + + It might not accept print jobs on this address. + + + + Consider using a suffix like "/ipp/print". + + + + The printer/server lists these suffixes: + + BusyPage