Commit c5129089 authored by Laurent Montel's avatar Laurent Montel 😁

improve print support

parent ead4712c
......@@ -22,6 +22,7 @@
#include <QToolButton>
#include <QPageSetupDialog>
#include <QPrinter>
#include <QDebug>
using namespace WebEngineViewer;
......@@ -60,12 +61,15 @@ PrintConfigureWidget::~PrintConfigureWidget()
void PrintConfigureWidget::slotSelectPrintLayout()
{
QPrinter printer;
printer.setPageLayout(mCurrentPageLayout);
//TODO port to qCDebug
if (!printer.setPageLayout(mCurrentPageLayout)) {
qDebug() << "Print Setup unsupported";
}
QPageSetupDialog dlg(&printer, this);
if (dlg.exec() != QDialog::Accepted)
return;
mCurrentPageLayout.setPageSize(printer.pageLayout().pageSize());
mCurrentPageLayout.setOrientation(printer.pageLayout().orientation());
mCurrentPageLayout = printer.pageLayout();
updatePageLayoutLabel();
}
......
......@@ -59,7 +59,6 @@ void PrintWebEngineViewJob::start()
if (mPageLayout.isValid()) {
mTemporaryFile.setAutoRemove(false);
#if QT_VERSION >= 0x050700
//Print to pdf
mEngineView->page()->printToPdf(invoke(this, &PrintWebEngineViewJob::slotHandlePdfPrinted), mPageLayout);
#endif
} else {
......
......@@ -22,6 +22,9 @@ set(printwebenginetest_gui_test_SRCS
../printpreviewdialog.cpp
../printpreviewpageviewer.cpp
../printpreviewpagewidget.cpp
../printwebengineviewjob.cpp
../printconfiguredialog.cpp
../printconfigurewidget.cpp
)
add_executable(printwebenginetest_gui ${printwebenginetest_gui_test_SRCS})
......
......@@ -17,6 +17,8 @@
#include "printwebenginetest_gui.h"
#include "../printwebengineviewjob.h"
#include "../printconfiguredialog.h"
#include <QApplication>
#include <QStandardPaths>
......@@ -28,11 +30,12 @@
PrintWebEngineTest_Gui::PrintWebEngineTest_Gui(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *mainLayout = new QHBoxLayout;
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mWebEngine = new QWebEngineView(this);
mainLayout->addWidget(mWebEngine);
mWebEngine->load(QUrl(QStringLiteral("http://www.kde.org")));
QPushButton *printButton = new QPushButton(QStringLiteral("Print"), this);
mainLayout->addWidget(printButton);
......@@ -47,6 +50,11 @@ PrintWebEngineTest_Gui::~PrintWebEngineTest_Gui()
void PrintWebEngineTest_Gui::slotPrint()
{
//TODO
WebEngineViewer::PrintConfigureDialog dlg(this);
if (dlg.exec()) {
const QPageLayout pageLayout = dlg.currentPageLayout();
//TODO
}
}
int main(int argc, char *argv[])
......
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