Commit c8b6e0e3 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement export to pdf

parent 5586de4b
......@@ -116,6 +116,7 @@
#include "header/headerstylemenumanager.h"
#include "widgets/submittedformwarningwidget.h"
#include <WebEngineViewer/LocalDataBaseManager>
#include <WebEngineViewer/WebEngineExportPdfPageJob>
#include <MimeTreeParser/BodyPart>
#include "interfaces/htmlwriter.h"
......@@ -2308,10 +2309,19 @@ void ViewerPrivate::slotDelayPrintPreview()
dialog->open(this, SIGNAL(printingFinished()));
}
void ViewerPrivate::slotExportToPdf()
{
WebEngineViewer::WebEngineExportPdfPageJob *job
= new WebEngineViewer::WebEngineExportPdfPageJob(this);
job->setEngineView(mViewer);
job->start();
//TODO
}
void ViewerPrivate::slotOpenInBrowser()
{
WebEngineViewer::WebEngineExportHtmlPageJob *job
= new WebEngineViewer::WebEngineExportHtmlPageJob;
= new WebEngineViewer::WebEngineExportHtmlPageJob(this);
job->setEngineView(mViewer);
connect(job, &WebEngineViewer::WebEngineExportHtmlPageJob::failed, this,
&ViewerPrivate::slotExportHtmlPageFailed);
......
......@@ -471,6 +471,8 @@ private Q_SLOTS:
void slotExportHtmlPageSuccess(const QString &filename);
void slotHandlePagePrinted(bool result);
void slotToggleEmoticons();
void slotExportToPdf();
public Q_SLOTS:
/** An URL has been activate with a click. */
void slotUrlOpen(const QUrl &url = QUrl());
......
......@@ -19,6 +19,8 @@
#include "webengineexportpdfpagejob.h"
#include "webengineviewer_debug.h"
#include <QWebEngineView>
using namespace WebEngineViewer;
WebEngineExportPdfPageJob::WebEngineExportPdfPageJob(QObject *parent)
: QObject(parent)
......@@ -33,10 +35,12 @@ WebEngineExportPdfPageJob::~WebEngineExportPdfPageJob()
void WebEngineExportPdfPageJob::start()
{
if (!mWebEngineView) {
qCWarning(WEBENGINEVIEWER_LOG) << "webengineview not defined! It's a bug";
if (!canStart()) {
qCWarning(WEBENGINEVIEWER_LOG) << "webengineview not defined or path is not defined.! It's a bug";
return;
}
mWebEngineView->page()->printToPdf(mPdfPath);
//TODO deleteLater
}
QWebEngineView *WebEngineExportPdfPageJob::engineView() const
......@@ -48,3 +52,18 @@ void WebEngineExportPdfPageJob::setEngineView(QWebEngineView *engineView)
{
mWebEngineView = engineView;
}
QString WebEngineExportPdfPageJob::pdfPath() const
{
return mPdfPath;
}
void WebEngineExportPdfPageJob::setPdfPath(const QString &pdfPath)
{
mPdfPath = pdfPath;
}
bool WebEngineExportPdfPageJob::canStart() const
{
return mWebEngineView && !mPdfPath.isEmpty();
}
......@@ -38,7 +38,14 @@ public:
Q_REQUIRED_RESULT QWebEngineView *engineView() const;
void setEngineView(QWebEngineView *engineView);
Q_REQUIRED_RESULT QString pdfPath() const;
void setPdfPath(const QString &pdfPath);
Q_REQUIRED_RESULT bool canStart() const;
private:
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