Messagelib

printmessage.h
1 /*
2  SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "messageviewer_export.h"
10 
11 #include <QEventLoop>
12 #include <QObject>
13 #include <QPrinter>
14 
15 class QWebEngineView;
16 namespace MessageViewer
17 {
18 class MESSAGEVIEWER_EXPORT PrintMessage : public QObject
19 {
20  Q_OBJECT
21 public:
22  explicit PrintMessage(QObject *parent = nullptr);
23  ~PrintMessage() override;
24 
25  void setView(QWebEngineView *view);
26  void setDocumentName(const QString &name);
27 
28  void print();
29  void printPreview();
30 
31  [[nodiscard]] QString documentName() const;
32 
33  [[nodiscard]] QWidget *parentWidget() const;
34  void setParentWidget(QWidget *newParentWidget);
35 
36 Q_SIGNALS:
37  void printingFinished();
38 
39 private:
40  MESSAGEVIEWER_NO_EXPORT void printDocument(QPrinter *printer);
41  MESSAGEVIEWER_NO_EXPORT void printFinished(bool success);
42  QString mDocumentName;
43  QPrinter mPrinter;
44  QEventLoop mWaitForResult;
45  QWidget *mParentWidget = nullptr;
46  QWebEngineView *mView = nullptr;
47  bool mInPrintPreview = false;
48 };
49 }
QAction * print(const QObject *recvr, const char *slot, QObject *parent)
QAction * printPreview(const QObject *recvr, const char *slot, QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Thu Feb 15 2024 03:55:21 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.