Add progress to pdf conversions
This commit is contained in:
parent
406c92c9a4
commit
1abbdfb768
3 changed files with 24 additions and 1 deletions
|
@ -225,8 +225,29 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo
|
|||
}
|
||||
qDebug() << "All started";
|
||||
|
||||
bool ppm2pwgSuccess = false;
|
||||
|
||||
if(!ppm2pwg->waitForFinished(10000+5000*pages))
|
||||
for(size_t i = 0; i < (5*pages+10); i++)
|
||||
{
|
||||
if(ppm2pwg->waitForFinished(1000))
|
||||
{
|
||||
ppm2pwgSuccess = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
QList<QByteArray> ppm2pwgOutput = ppm2pwg->readAllStandardError().split('\n');
|
||||
for(QList<QByteArray>::iterator it = ppm2pwgOutput.begin(); it != ppm2pwgOutput.end(); it++)
|
||||
{
|
||||
if(it->startsWith("Page"))
|
||||
{
|
||||
QList<QByteArray> ppm2pwgTokens = it->split(' ');
|
||||
emit progress(ppm2pwgTokens.last().toInt(), pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ppm2pwgSuccess)
|
||||
{
|
||||
qDebug() << "ppm2pwg failed";
|
||||
tempfile->deleteLater();
|
||||
|
|
|
@ -18,6 +18,7 @@ public slots:
|
|||
|
||||
signals:
|
||||
void done(QNetworkRequest request, QTemporaryFile* data);
|
||||
void progress(qint64 done, qint64 pages);
|
||||
void failed(QString message);
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ IppPrinter::IppPrinter()
|
|||
connect(this, &IppPrinter::doConvertPdf, _worker, &ConvertWorker::convertPdf);
|
||||
connect(this, &IppPrinter::doConvertImage, _worker, &ConvertWorker::convertImage);
|
||||
connect(_worker, &ConvertWorker::done, this, &IppPrinter::convertDone);
|
||||
connect(_worker, &ConvertWorker::progress, this, &IppPrinter::setProgress);
|
||||
connect(_worker, &ConvertWorker::failed, this, &IppPrinter::convertFailed);
|
||||
|
||||
_workerThread.start();
|
||||
|
|
Loading…
Reference in a new issue