make print() a slot
This commit is contained in:
parent
ed25def70a
commit
e0b10c83a1
3 changed files with 11 additions and 7 deletions
|
@ -14,7 +14,7 @@ Page {
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: printer
|
target: printer
|
||||||
onJobAttrsFinished: {
|
onJobFinished: {
|
||||||
var msg = printer.jobAttrs["job-state-message"] && 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 : Utils.ippName("job-state", printer.jobAttrs["job-state"].value)
|
? printer.jobAttrs["job-state-message"].value : Utils.ippName("job-state", printer.jobAttrs["job-state"].value)
|
||||||
if(status == true) {
|
if(status == true) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ void IppPrinter::printRequestFinished(QNetworkReply *reply)
|
||||||
_jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Network error"}});
|
_jobAttrs.insert("job-state-message", QJsonObject {{"tag", IppMsg::TextWithoutLanguage}, {"value", "Network error"}});
|
||||||
}
|
}
|
||||||
emit jobAttrsChanged();
|
emit jobAttrsChanged();
|
||||||
emit jobAttrsFinished(status);
|
emit jobFinished(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IppPrinter::getJobsRequestFinished(QNetworkReply *reply)
|
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;
|
qDebug() << "printing" << filename << attrs;
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
bool file_ok = file.open(QIODevice::ReadOnly);
|
bool file_ok = file.open(QIODevice::ReadOnly);
|
||||||
if(!file_ok)
|
if(!file_ok)
|
||||||
return false;
|
{
|
||||||
|
emit jobFinished(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QFileInfo fileinfo(file);
|
QFileInfo fileinfo(file);
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
|
@ -235,7 +238,6 @@ bool IppPrinter::print(QJsonObject attrs, QString filename){
|
||||||
|
|
||||||
_print_nam->post(request, contents);
|
_print_nam->post(request, contents);
|
||||||
file.close();
|
file.close();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IppPrinter::getJobs() {
|
bool IppPrinter::getJobs() {
|
||||||
|
|
|
@ -24,7 +24,6 @@ public:
|
||||||
|
|
||||||
Q_INVOKABLE void refresh();
|
Q_INVOKABLE void refresh();
|
||||||
|
|
||||||
Q_INVOKABLE bool print(QJsonObject attrs, QString file);
|
|
||||||
Q_INVOKABLE bool getJobs();
|
Q_INVOKABLE bool getJobs();
|
||||||
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
||||||
|
|
||||||
|
@ -34,10 +33,13 @@ signals:
|
||||||
void jobAttrsChanged();
|
void jobAttrsChanged();
|
||||||
void jobsChanged();
|
void jobsChanged();
|
||||||
|
|
||||||
void jobAttrsFinished(bool status);
|
void jobFinished(bool status);
|
||||||
void cancelStatus(bool status);
|
void cancelStatus(bool status);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void print(QJsonObject attrs, QString file);
|
||||||
|
|
||||||
|
|
||||||
void onUrlChanged();
|
void onUrlChanged();
|
||||||
void getPrinterAttributesFinished(QNetworkReply* reply);
|
void getPrinterAttributesFinished(QNetworkReply* reply);
|
||||||
void printRequestFinished(QNetworkReply* reply);
|
void printRequestFinished(QNetworkReply* reply);
|
||||||
|
|
Loading…
Reference in a new issue