make print() a slot

This commit is contained in:
Anton Thomasson 2020-04-04 13:56:36 +02:00
parent ed25def70a
commit e0b10c83a1
3 changed files with 11 additions and 7 deletions

View file

@ -14,7 +14,7 @@ Page {
Connections {
target: printer
onJobAttrsFinished: {
onJobFinished: {
var msg = printer.jobAttrs["job-state-message"] && printer.jobAttrs["job-state-message"].value != ""
? printer.jobAttrs["job-state-message"].value : Utils.ippName("job-state", printer.jobAttrs["job-state"].value)
if(status == true) {

View file

@ -134,7 +134,7 @@ void IppPrinter::printRequestFinished(QNetworkReply *reply)
_jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Network error"}});
}
emit jobAttrsChanged();
emit jobAttrsFinished(status);
emit jobFinished(status);
}
void IppPrinter::getJobsRequestFinished(QNetworkReply *reply)
@ -198,13 +198,16 @@ void IppPrinter::ignoreKnownSslErrors(QNetworkReply *reply, const QList<QSslErro
bool IppPrinter::print(QJsonObject attrs, QString filename){
void IppPrinter::print(QJsonObject attrs, QString filename){
qDebug() << "printing" << filename << attrs;
QFile file(filename);
bool file_ok = file.open(QIODevice::ReadOnly);
if(!file_ok)
return false;
{
emit jobFinished(false);
return;
}
QFileInfo fileinfo(file);
QNetworkRequest request;
@ -235,7 +238,6 @@ bool IppPrinter::print(QJsonObject attrs, QString filename){
_print_nam->post(request, contents);
file.close();
return true;
}
bool IppPrinter::getJobs() {

View file

@ -24,7 +24,6 @@ public:
Q_INVOKABLE void refresh();
Q_INVOKABLE bool print(QJsonObject attrs, QString file);
Q_INVOKABLE bool getJobs();
Q_INVOKABLE bool cancelJob(qint32 jobId);
@ -34,10 +33,13 @@ signals:
void jobAttrsChanged();
void jobsChanged();
void jobAttrsFinished(bool status);
void jobFinished(bool status);
void cancelStatus(bool status);
public slots:
void print(QJsonObject attrs, QString file);
void onUrlChanged();
void getPrinterAttributesFinished(QNetworkReply* reply);
void printRequestFinished(QNetworkReply* reply);