1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
|
From a8c0deca850ca519b3f146c71492a8f42a33dd84 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=BCri=20Valdmann?= <juri.valdmann@qt.io>
Date: Tue, 20 Jun 2017 15:36:43 +0200
Subject: [PATCH] Always compile QWebEnginePage::print
- Remove two out of five layers of ifdefs around and inside this method.
- Now always compiled but will yield an error if printing is disabled.
- Remove printing-related ifdefs from demobrowser.
Task-number: QTBUG-61510
Change-Id: I79781189d3d3fb62db0a2216b2b989e3fa1d1f86
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Rolf Eike Beer <eb@emlix.com>
---
examples/webenginewidgets/demobrowser/browsermainwindow.cpp | 12 ------------
examples/webenginewidgets/demobrowser/browsermainwindow.h | 6 ------
examples/webenginewidgets/demobrowser/printtopdfdialog.cpp | 7 -------
src/webenginewidgets/api/qwebenginepage.cpp | 10 ++--------
src/webenginewidgets/api/qwebenginepage.h | 8 --------
5 files changed, 2 insertions(+), 41 deletions(-)
diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
index 327d7a9d..14d49f7f 100644
--- a/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
+++ b/examples/webenginewidgets/demobrowser/browsermainwindow.cpp
@@ -109,9 +109,7 @@ BrowserMainWindow::BrowserMainWindow(QWidget *parent, Qt::WindowFlags flags)
, m_historyForward(0)
, m_stop(0)
, m_reload(0)
-#ifndef QT_NO_PRINTER
, m_currentPrinter(nullptr)
-#endif
{
setToolButtonStyle(Qt::ToolButtonFollowStyle);
setAttribute(Qt::WA_DeleteOnClose, true);
@@ -312,9 +310,7 @@ void BrowserMainWindow::setupMenu()
#if defined(QWEBENGINEPAGE_PRINT)
fileMenu->addAction(tr("P&rint Preview..."), this, SLOT(slotFilePrintPreview()));
#endif
-#ifndef QT_NO_PRINTER
fileMenu->addAction(tr("&Print..."), this, SLOT(slotFilePrint()), QKeySequence::Print);
-#endif
fileMenu->addAction(tr("&Print to PDF..."), this, SLOT(slotFilePrintToPDF()));
fileMenu->addSeparator();
@@ -702,23 +698,19 @@ void BrowserMainWindow::slotFileOpen()
void BrowserMainWindow::slotFilePrintPreview()
{
-#ifndef QT_NO_PRINTPREVIEWDIALOG
if (!currentTab())
return;
QPrintPreviewDialog *dialog = new QPrintPreviewDialog(this);
connect(dialog, SIGNAL(paintRequested(QPrinter*)),
currentTab(), SLOT(print(QPrinter*)));
dialog->exec();
-#endif
}
void BrowserMainWindow::slotFilePrint()
{
-#ifndef QT_NO_PRINTER
if (!currentTab())
return;
printRequested(currentTab()->page());
-#endif
}
void BrowserMainWindow::slotHandlePdfPrinted(const QByteArray& result)
@@ -751,7 +743,6 @@ void BrowserMainWindow::slotFilePrintToPDF()
currentTab()->page()->printToPdf(invoke(this, &BrowserMainWindow::slotHandlePdfPrinted), dialog->pageLayout());
}
-#ifndef QT_NO_PRINTER
void BrowserMainWindow::slotHandlePagePrinted(bool result)
{
Q_UNUSED(result);
@@ -763,7 +754,6 @@ void BrowserMainWindow::slotHandlePagePrinted(bool result)
void BrowserMainWindow::printRequested(QWebEnginePage *page)
{
-#ifndef QT_NO_PRINTDIALOG
if (m_currentPrinter)
return;
m_currentPrinter = new QPrinter();
@@ -774,9 +764,7 @@ void BrowserMainWindow::printRequested(QWebEnginePage *page)
return;
}
page->print(m_currentPrinter, invoke(this, &BrowserMainWindow::slotHandlePagePrinted));
-#endif
}
-#endif
void BrowserMainWindow::slotPrivateBrowsing()
{
diff --git a/examples/webenginewidgets/demobrowser/browsermainwindow.h b/examples/webenginewidgets/demobrowser/browsermainwindow.h
index 91e1c1d2..5bbbb292 100644
--- a/examples/webenginewidgets/demobrowser/browsermainwindow.h
+++ b/examples/webenginewidgets/demobrowser/browsermainwindow.h
@@ -56,9 +56,7 @@
#include <QtCore/QUrl>
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_PRINTER
class QPrinter;
-#endif
class QWebEnginePage;
QT_END_NAMESPACE
@@ -142,10 +140,8 @@ private slots:
void slotSwapFocus();
void slotHandlePdfPrinted(const QByteArray&);
-#ifndef QT_NO_PRINTER
void slotHandlePagePrinted(bool result);
void printRequested(QWebEnginePage *page);
-#endif
void geometryChangeRequested(const QRect &geometry);
void updateToolbarActionText(bool visible);
void updateBookmarksToolbarActionText(bool visible);
@@ -180,9 +176,7 @@ private:
QAction *m_restoreLastSession;
QAction *m_addBookmark;
-#ifndef QT_NO_PRINTER
QPrinter *m_currentPrinter;
-#endif
QIcon m_reloadIcon;
QIcon m_stopIcon;
diff --git a/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp b/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp
index 0f3b1765..50a8bb91 100644
--- a/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp
+++ b/examples/webenginewidgets/demobrowser/printtopdfdialog.cpp
@@ -52,10 +52,8 @@
#include "ui_printtopdfdialog.h"
#include <QtCore/QDir>
-#ifndef QT_NO_PRINTER
#include <QtPrintSupport/QPageSetupDialog>
#include <QtPrintSupport/QPrinter>
-#endif // QT_NO_PRINTER
#include <QtWidgets/QFileDialog>
PrintToPdfDialog::PrintToPdfDialog(const QString &filePath, QWidget *parent) :
@@ -66,11 +64,8 @@ PrintToPdfDialog::PrintToPdfDialog(const QString &filePath, QWidget *parent) :
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
connect(ui->chooseFilePathButton, &QToolButton::clicked, this, &PrintToPdfDialog::onChooseFilePathButtonClicked);
-#ifndef QT_NO_PRINTER
connect(ui->choosePageLayoutButton, &QToolButton::clicked, this, &PrintToPdfDialog::onChoosePageLayoutButtonClicked);
-#else
ui->choosePageLayoutButton->hide();
-#endif // QT_NO_PRINTER
updatePageLayoutLabel();
setFilePath(filePath);
}
@@ -82,7 +77,6 @@ PrintToPdfDialog::~PrintToPdfDialog()
void PrintToPdfDialog::onChoosePageLayoutButtonClicked()
{
-#ifndef QT_NO_PRINTER
QPrinter printer;
printer.setPageLayout(currentPageLayout);
@@ -92,7 +86,6 @@ void PrintToPdfDialog::onChoosePageLayoutButtonClicked()
currentPageLayout.setPageSize(printer.pageLayout().pageSize());
currentPageLayout.setOrientation(printer.pageLayout().orientation());
updatePageLayoutLabel();
-#endif // QT_NO_PRINTER
}
void PrintToPdfDialog::onChooseFilePathButtonClicked()
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 82720ae3..20d3268c 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -80,11 +80,9 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
-#if defined(QT_PRINTSUPPORT_LIB)
-#ifndef QT_NO_PRINTER
+#ifdef ENABLE_PRINTING
#include <QPrinter>
-#endif //QT_NO_PRINTER
-#endif //QT_PRINTSUPPORT_LIB
+#endif
#include <QStandardPaths>
#include <QStyle>
#include <QTimer>
@@ -2052,8 +2050,6 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
#endif // if defined(ENABLE_PDF)
}
-#if defined(QT_PRINTSUPPORT_LIB)
-#ifndef QT_NO_PRINTER
/*!
\fn void QWebEnginePage::print(QPrinter *printer, FunctorOrLambda resultCallback)
Renders the current content of the page into a temporary PDF document, then prints it using \a printer.
@@ -2090,8 +2086,6 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
d->m_callbacks.invokeDirectly(resultCallback, false);
#endif // if defined(ENABLE_PDF)
}
-#endif // if defined(QT_NO_PRINTER)
-#endif // if defined(QT_PRINTSUPPORT_LIB)
/*!
\since 5.7
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index c7d5a19e..5619639c 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -55,11 +55,7 @@
QT_BEGIN_NAMESPACE
class QMenu;
-#if defined(QT_PRINTSUPPORT_LIB)
-#ifndef QT_NO_PRINTER
class QPrinter;
-#endif // QT_NO_PRINTER
-#endif // QT_PRINTSUPPORT_LIB
class QWebChannel;
class QWebEngineContextMenuData;
@@ -294,15 +290,11 @@ public:
void printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()));
#endif
-#if defined(QT_PRINTSUPPORT_LIB)
-#ifndef QT_NO_PRINTER
#ifdef Q_QDOC
void print(QPrinter *printer, FunctorOrLambda resultCallback);
#else
void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback);
#endif // QDOC
-#endif // QT_NO_PRINTER
-#endif // QT_PRINTSUPPORT_LIB
const QWebEngineContextMenuData &contextMenuData() const;
|