Add a status page for convert/transfer

This commit is contained in:
Anton Thomasson 2020-05-06 20:46:41 +02:00
parent 2741bccd22
commit c1570bcb1b
11 changed files with 108 additions and 62 deletions

View file

@ -36,6 +36,7 @@ DISTFILES += qml/harbour-seaprint.qml \
qml/pages/*.qml \
qml/pages/*.js \
qml/pages/*svg \
qml/pages/BusyPage.qml \
qml/pages/DebugPage.qml \
rpm/harbour-seaprint.changes.in \
rpm/harbour-seaprint.changes.run.in \

32
qml/pages/BusyPage.qml Normal file
View file

@ -0,0 +1,32 @@
import QtQuick 2.0
import Sailfish.Silica 1.0
import "utils.js" as Utils
Page {
property var printer
backNavigation: false
Connections {
target: printer
onJobFinished: {
var msg = ""
if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") {
msg = printer.jobAttrs["job-state-message"].value
}
else if (printer.jobAttrs.hasOwnProperty("job-state")) {
msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value)
}
if(status == true) {
notifier.notify(qsTr("Print success: ") + msg)
pageStack.pop() //or replace?
}
else {
notifier.notify(qsTr("Print failed: ") + msg)
}
}
}
BusyLabel {
text: printer.busyMessage
running: true
}
}

View file

@ -12,26 +12,6 @@ Page {
console.log(JSON.stringify(printer.attrs))
}
Connections {
target: printer
onJobFinished: {
var msg = ""
if (printer.jobAttrs.hasOwnProperty("job-state-message") && printer.jobAttrs["job-state-message"].value != "") {
msg = printer.jobAttrs["job-state-message"].value
}
else if (printer.jobAttrs.hasOwnProperty("job-state")) {
msg = Utils.ippName("job-state", printer.jobAttrs["job-state"].value)
}
if(status == true) {
notifier.notify(qsTr("Print success: ") + msg)
pageStack.pop() //or replace?
}
else {
notifier.notify(qsTr("Print failed: ") + msg)
}
}
}
// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
anchors.fill: parent
@ -42,8 +22,8 @@ Page {
text: qsTr("Print")
onClicked: {
console.log(JSON.stringify(jobParams))
pageStack.replace(Qt.resolvedUrl("BusyPage.qml"),{printer:printer})
printer.print(jobParams, page.selectedFile)
}
}
}

View file

@ -14,7 +14,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename,
QProcess* ppm2pwg = new QProcess(this);
// Yo dwag, I heard you like programs...
// Yo dawg, I heard you like programs...
ppm2pwg->setProgram("harbour-seaprint");
ppm2pwg->setArguments({"ppm2pwg"});
QStringList env = {"HWRES_X="+HwResX_s, "HWRES_Y="+HwResY_s};

View file

@ -212,6 +212,9 @@ void IppPrinter::convertDone(QNetworkRequest request, QTemporaryFile* data)
{
connect(_print_nam, SIGNAL(finished(QNetworkReply*)), data, SLOT(deleteLater()));
data->open();
setBusyMessage("Transferring");
_print_nam->post(request, data);
}
@ -314,6 +317,8 @@ void IppPrinter::print(QJsonObject attrs, QString filename){
qDebug() << tempfile->fileName();
tempfile->close();
setBusyMessage("Converting");
emit doConvertPdf(request, filename, target==UrfConvert, HwResX, HwResY, tempfile);
}
else
@ -322,6 +327,8 @@ void IppPrinter::print(QJsonObject attrs, QString filename){
contents = contents.append(filedata);
file.close();
setBusyMessage("Transferring");
_print_nam->post(request, contents);
}
@ -381,3 +388,8 @@ QUrl IppPrinter::httpUrl() {
return url;
}
void IppPrinter::setBusyMessage(QString msg)
{
_busyMessage = msg;
emit busyMessageChanged();
}

View file

@ -13,6 +13,7 @@ class IppPrinter : public QObject
Q_PROPERTY(QJsonObject attrs MEMBER _attrs NOTIFY attrsChanged)
Q_PROPERTY(QJsonObject jobAttrs MEMBER _jobAttrs NOTIFY jobAttrsChanged)
Q_PROPERTY(QJsonArray jobs MEMBER _jobs NOTIFY jobsChanged)
Q_PROPERTY(QString busyMessage MEMBER _busyMessage NOTIFY busyMessageChanged)
public:
@ -53,6 +54,8 @@ signals:
void doConvertPdf(QNetworkRequest request, QString filename, bool urf, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile);
void busyMessageChanged();
public slots:
void print(QJsonObject attrs, QString file);
@ -74,6 +77,8 @@ private:
QJsonObject opAttrs();
void setBusyMessage(QString msg);
QNetworkAccessManager* _nam;
QNetworkAccessManager* _jobs_nam;
QNetworkAccessManager* _job_cancel_nam;
@ -82,6 +87,7 @@ private:
QJsonObject _attrs;
QJsonObject _jobAttrs;
QJsonArray _jobs;
QString _busyMessage;
QThread _workerThread;
ConvertWorker* _worker;

View file

@ -87,6 +87,17 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>
<message>
<source>Print success: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -198,14 +209,6 @@
<source>Resolution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print success: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>utils</name>

View file

@ -87,6 +87,17 @@
<translation>Desconocida</translation>
</message>
</context>
<context>
<name>BusyPage</name>
<message>
<source>Print success: </source>
<translation type="unfinished">Impresión correcta: </translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished">Impresión fallida: </translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -198,14 +209,6 @@
<source>Resolution</source>
<translation>Resolución</translation>
</message>
<message>
<source>Print success: </source>
<translation>Impresión correcta: </translation>
</message>
<message>
<source>Print failed: </source>
<translation>Impresión fallida: </translation>
</message>
</context>
<context>
<name>utils</name>

View file

@ -87,6 +87,17 @@
<translation>Inconnu</translation>
</message>
</context>
<context>
<name>BusyPage</name>
<message>
<source>Print success: </source>
<translation type="unfinished">Impression réussie :</translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished">Échec de l&apos;impression :</translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -198,14 +209,6 @@
<source>Resolution</source>
<translation>Résolution</translation>
</message>
<message>
<source>Print success: </source>
<translation>Impression réussie :</translation>
</message>
<message>
<source>Print failed: </source>
<translation>Échec de l&apos;impression :</translation>
</message>
</context>
<context>
<name>utils</name>

View file

@ -87,6 +87,17 @@
<translation></translation>
</message>
</context>
<context>
<name>BusyPage</name>
<message>
<source>Print success: </source>
<translation type="unfinished">:</translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished">:</translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -198,14 +209,6 @@
<source>Resolution</source>
<translation></translation>
</message>
<message>
<source>Print success: </source>
<translation>:</translation>
</message>
<message>
<source>Print failed: </source>
<translation>:</translation>
</message>
</context>
<context>
<name>utils</name>

View file

@ -87,6 +87,17 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BusyPage</name>
<message>
<source>Print success: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>CoverPage</name>
<message>
@ -198,14 +209,6 @@
<source>Resolution</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print success: </source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Print failed: </source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>utils</name>