Commit 114273c7 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Autodelete job when it's finished

parent a0e77a07
......@@ -41,7 +41,6 @@ InvokeWrapper<Arg, R, C> invoke(R *receiver, void (C::*memberFun)(Arg))
WebEngineExportHtmlPageJob::WebEngineExportHtmlPageJob(QObject *parent)
: QObject(parent)
, mEngineView(nullptr)
{
}
......
......@@ -37,10 +37,22 @@ void WebEngineExportPdfPageJob::start()
{
if (!canStart()) {
qCWarning(WEBENGINEVIEWER_LOG) << "webengineview not defined or path is not defined.! It's a bug";
deleteLater();
return;
}
connect(mWebEngineView->page(), &QWebEnginePage::pdfPrintingFinished, this, &WebEngineExportPdfPageJob::slotPdfPrintingFinished);
mWebEngineView->page()->printToPdf(mPdfPath);
//TODO deleteLater
}
void WebEngineExportPdfPageJob::slotPdfPrintingFinished(const QString &filePath, bool success)
{
if (success) {
Q_EMIT exportToPdfSuccess();
} else {
qCWarning(WEBENGINEVIEWER_LOG) << "Failed to export to pdf to " << filePath;
Q_EMIT exportPdfFailed();
}
deleteLater();
}
QWebEngineView *WebEngineExportPdfPageJob::engineView() const
......
......@@ -44,7 +44,12 @@ public:
Q_REQUIRED_RESULT bool canStart() const;
Q_SIGNALS:
void exportPdfFailed();
void exportToPdfSuccess();
private:
void slotPdfPrintingFinished(const QString &filePath, bool success);
QString mPdfPath;
QWebEngineView *mWebEngineView = nullptr;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment