Improve job flow
This commit is contained in:
parent
733fd201b8
commit
ad0f92ba1e
3 changed files with 20 additions and 3 deletions
|
@ -14,8 +14,16 @@ Page {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: printer
|
target: printer
|
||||||
onJobAttrsChanged: {
|
onJobAttrsFinished: {
|
||||||
notifier.notify(printer.jobAttrs["job-state-message"].value)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,19 +83,26 @@ void IppPrinter::getPrinterAttributesFinished(QNetworkReply *reply)
|
||||||
|
|
||||||
void IppPrinter::printRequestFinished(QNetworkReply *reply)
|
void IppPrinter::printRequestFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
|
_jobAttrs = QJsonObject();
|
||||||
|
bool status = false;
|
||||||
if(reply->error() == QNetworkReply::NoError)
|
if(reply->error() == QNetworkReply::NoError)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
IppMsg resp(reply);
|
IppMsg resp(reply);
|
||||||
qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getJobAttrs();
|
qDebug() << resp.getStatus() << resp.getOpAttrs() << resp.getJobAttrs();
|
||||||
_jobAttrs = resp.getJobAttrs()[0].toObject();
|
_jobAttrs = resp.getJobAttrs()[0].toObject();
|
||||||
emit jobAttrsChanged();
|
status = resp.getStatus() <= 0xff;
|
||||||
}
|
}
|
||||||
catch(std::exception e)
|
catch(std::exception e)
|
||||||
{
|
{
|
||||||
qDebug() << e.what();
|
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)
|
void IppPrinter::getJobsRequestFinished(QNetworkReply *reply)
|
||||||
|
|
|
@ -32,6 +32,8 @@ signals:
|
||||||
void jobAttrsChanged();
|
void jobAttrsChanged();
|
||||||
void jobsChanged();
|
void jobsChanged();
|
||||||
|
|
||||||
|
void jobAttrsFinished(bool status);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onUrlChanged();
|
void onUrlChanged();
|
||||||
void getPrinterAttributesFinished(QNetworkReply* reply);
|
void getPrinterAttributesFinished(QNetworkReply* reply);
|
||||||
|
|
Loading…
Reference in a new issue