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 {
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -32,6 +32,8 @@ signals:
|
|||
void jobAttrsChanged();
|
||||
void jobsChanged();
|
||||
|
||||
void jobAttrsFinished(bool status);
|
||||
|
||||
public slots:
|
||||
void onUrlChanged();
|
||||
void getPrinterAttributesFinished(QNetworkReply* reply);
|
||||
|
|
Loading…
Reference in a new issue