blob: ab9a8c3a4d926870904222c0363131ebe5bbc2e2 (
plain)
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
|
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PRINTHANDLER_H
#define PRINTHANDLER_H
#include <QEventLoop>
#include <QObject>
#include <QPrinter>
QT_BEGIN_NAMESPACE
class QPainter;
class QPrinter;
class QWebEngineView;
QT_END_NAMESPACE
class PrintHandler : public QObject
{
Q_OBJECT
public:
PrintHandler(QObject *parent = nullptr);
void setView(QWebEngineView *view);
public slots:
void print();
void printPreview();
void printDocument(QPrinter *printer);
void printFinished(bool success);
private:
QWebEngineView *m_view = nullptr;
QPrinter m_printer;
QEventLoop m_waitForResult;
bool m_inPrintPreview = false;
};
#endif // PRINTHANDLER_H
|