diff --git a/qml/pages/PrinterPage.qml b/qml/pages/PrinterPage.qml index ca25f3d..ca10c11 100644 --- a/qml/pages/PrinterPage.qml +++ b/qml/pages/PrinterPage.qml @@ -14,8 +14,16 @@ Page { Connections { target: printer - onJobAttrsChanged: { - notifier.notify(printer.jobAttrs["job-state-message"].value) + onJobAttrsFinished: { + var msg = printer.jobAttrs["job-state-message"] && printer.jobAttrs["job-state-message"].value != "" + ? printer.jobAttrs["job-state-message"].value : qsTr("Unknown") + if(status == true) { + notifier.notify(qsTr("Print success: ") + msg) + pageStack.pop() //or replace? + } + else { + notifier.notify(qsTr("Print failed: ") + msg) + } } } diff --git a/src/ippprinter.cpp b/src/ippprinter.cpp index 246cc03..9738e1c 100644 --- a/src/ippprinter.cpp +++ b/src/ippprinter.cpp @@ -83,19 +83,26 @@ void IppPrinter::getPrinterAttributesFinished(QNetworkReply *reply) void IppPrinter::printRequestFinished(QNetworkReply *reply) { + _jobAttrs = QJsonObject(); + bool status = false; if(reply->error() == QNetworkReply::NoError) { try { IppMsg resp(reply); qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getJobAttrs(); _jobAttrs = resp.getJobAttrs()[0].toObject(); - emit jobAttrsChanged(); + status = resp.getStatus() <= 0xff; } catch(std::exception e) { qDebug() << e.what(); } } + else { + _jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Network error"}}); + } + emit jobAttrsChanged(); + emit jobAttrsFinished(status); } void IppPrinter::getJobsRequestFinished(QNetworkReply *reply) diff --git a/src/ippprinter.h b/src/ippprinter.h index 0f32321..53723f9 100644 --- a/src/ippprinter.h +++ b/src/ippprinter.h @@ -32,6 +32,8 @@ signals: void jobAttrsChanged(); void jobsChanged(); + void jobAttrsFinished(bool status); + public slots: void onUrlChanged(); void getPrinterAttributesFinished(QNetworkReply* reply);