subsurface/desktop-widgets/printerwebengine.h
Robert C. Helling 9583173425 desktop: implement template previewing for WebEngine
This allows the template editor to preview in a QWebEngineView. It also
improves the logic of the buttons (Apply updates the preview but does not force
a save first).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-11-26 12:35:34 -08:00

61 lines
1.1 KiB
C++

// SPDX-License-Identifier: GPL-2.0
#ifndef PRINTER_H
#define PRINTER_H
#include "printoptions.h"
#include <QPrinter>
#include <QTemporaryDir>
class ProfileWidget2;
class QPainter;
class QPaintDevice;
class QRect;
class QWebEngineView;
class Printer : public QObject {
Q_OBJECT
public:
enum PrintMode {
PRINT,
PREVIEW
};
QWebEngineView *webView;
private:
QPaintDevice *paintDevice;
QPrinter printer;
QTemporaryDir printDir;
print_options &printOptions;
template_options &templateOptions;
QSize pageSize;
PrintMode printMode;
bool inPlanner;
int done;
void onLoadFinished();
bool profilesMissing;
private slots:
void templateProgessUpdated(int value);
void printing();
public:
Printer(QPaintDevice *paintDevice, print_options &printOptions, template_options &templateOptions, PrintMode printMode, bool inPlanner, QWidget *parent);
~Printer();
void print();
void previewOnePage();
QString writeTmpTemplate(const QString templtext);
QString exportHtml();
void updateOptions(print_options &poptions, template_options &toptions);
signals:
void progessUpdated(int value);
void profilesInserted();
void jobDone();
};
#endif //PRINTER_H