diff --git a/qml/pages/FirstPage.qml b/qml/pages/FirstPage.qml index cfc308b..526dca4 100644 --- a/qml/pages/FirstPage.qml +++ b/qml/pages/FirstPage.qml @@ -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; diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 8245b88..246cc03 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -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) diff --git a/translations/harbour-seaprint-de.ts b/translations/harbour-seaprint-de.ts index c438ca4..8da74a3 100644 --- a/translations/harbour-seaprint-de.ts +++ b/translations/harbour-seaprint-de.ts @@ -108,6 +108,10 @@ Remove printer + + Unknown + + JobsPage diff --git a/translations/harbour-seaprint.ts b/translations/harbour-seaprint.ts index c438ca4..8da74a3 100644 --- a/translations/harbour-seaprint.ts +++ b/translations/harbour-seaprint.ts @@ -108,6 +108,10 @@ Remove printer + + Unknown + + JobsPage