Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Network
Konqueror
Commits
a0b83e8f
Commit
a0b83e8f
authored
Sep 26, 2020
by
Stefano Crocco
Committed by
David Faure
Sep 26, 2020
Browse files
Implement print preview
parent
5f16fc6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
webenginepart/src/webenginepart_ext.cpp
View file @
a0b83e8f
...
...
@@ -18,6 +18,24 @@
*
*/
/*
* The code for the function slotPrintPreview was adapted from the PrintMe Qt example
* and is distributed under the BSD license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of The Qt Company Ltd nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*/
#include
"webenginepart_ext.h"
#include
<QtWebEngine/QtWebEngineVersion>
...
...
@@ -54,6 +72,7 @@
#include
<QPrintPreviewDialog>
#include
<QWebEngineHistory>
#include
<QMimeData>
#include
<QPrinterInfo>
#define QL1S(x) QLatin1String(x)
#define QL1C(x) QLatin1Char(x)
...
...
@@ -800,14 +819,16 @@ void WebEngineBrowserExtension::saveHistory()
void
WebEngineBrowserExtension
::
slotPrintPreview
()
{
#if 0
// Make it non-modal, in case a redirection deletes the part
QPointer<QPrintPreviewDialog> dlg (new QPrintPreviewDialog(view()));
connect(dlg.data(), SIGNAL(paintRequested(QPrinter*)),
view()->page()->currentFrame(), SLOT(print(QPrinter*)));
dlg->exec();
delete dlg;
#endif
QPrinter
printer
;
QPrintPreviewDialog
dlg
(
&
printer
,
view
());
auto
printPreview
=
[
this
](
QPrinter
*
p
){
QEventLoop
loop
;
auto
preview
=
[
&
](
bool
)
{
loop
.
quit
();};
m_view
->
page
()
->
print
(
p
,
preview
);
loop
.
exec
();
};
connect
(
&
dlg
,
&
QPrintPreviewDialog
::
paintRequested
,
this
,
printPreview
);
dlg
.
exec
();
}
void
WebEngineBrowserExtension
::
slotOpenSelection
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment