Add warning/hint about suffixes

This commit is contained in:
Anton Thomasson 2021-06-28 20:15:21 +02:00
parent 5dcd6cf54f
commit 2f1e1bf7a5
10 changed files with 217 additions and 21 deletions

View file

@ -82,14 +82,16 @@ Dialog {
text: printerName ? printerName : ""
}
}
Item {
width: 1
height: 2*Theme.paddingLarge
}
Row {
visible: valueField.text.indexOf(":9100") != -1
x: Theme.paddingLarge
anchors.top: col.bottom
anchors.topMargin: Theme.paddingLarge*2
anchors.horizontalCenter: parent.horizontalCenter
width: parent.width-2*Theme.paddingLarge
spacing: Theme.paddingMedium
@ -108,6 +110,56 @@ Dialog {
}
}
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: {
if (result == DialogResult.Accepted) {
value = valueField.text

View file

@ -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;

View file

@ -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();

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation>9100IPP</translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>

View file

@ -118,6 +118,22 @@
<source>Port 9100 is not used for IPP.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The uri suffix is not in the printer&apos;s supported list.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>It might not accept print jobs on this address.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Consider using a suffix like &quot;/ipp/print&quot;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The printer/server lists these suffixes:</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>