Fix visibility of missing/lost printers

This commit is contained in:
Anton Thomasson 2019-12-15 11:24:36 +01:00
parent cf8f4a6680
commit f56507c7ad
4 changed files with 25 additions and 4 deletions

View file

@ -73,11 +73,24 @@ Page {
delegate: ListItem {
id: delegate
contentItem.height: visible ? Math.max(column.implicitHeight, Theme.itemSizeLarge+2*Theme.paddingMedium) : 0
visible: printer.attrs["printer-name"] ? true : false
property string name: printer.attrs["printer-name"].value
visible: false
property string name: printer.attrs["printer-name"] ? printer.attrs["printer-name"].value : qsTr("Unknown")
property bool canPrint: Utils.can_print(printer, selectedFile)
Connections {
target: printer
onAttrsChanged: {
if(Object.keys(printer.attrs).length === 0) {
delegate.visible = false
}
else {
delegate.visible = true
}
}
}
onClicked: {
if(!canPrint)
return;

View file

@ -65,20 +65,20 @@ void IppPrinter::onUrlChanged()
void IppPrinter::getPrinterAttributesFinished(QNetworkReply *reply)
{
qDebug() << reply->error() << reply->errorString() << reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toString();
_attrs = QJsonObject();
if(reply->error() == QNetworkReply::NoError)
{
try {
IppMsg resp(reply);
qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getPrinterAttrs();
_attrs = resp.getPrinterAttrs();
emit attrsChanged();
}
catch(std::exception e)
{
qDebug() << e.what();
}
}
emit attrsChanged();
}
void IppPrinter::printRequestFinished(QNetworkReply *reply)

View file

@ -108,6 +108,10 @@
<source>Remove printer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>JobsPage</name>

View file

@ -108,6 +108,10 @@
<source>Remove printer</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Unknown</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>JobsPage</name>