PDF4QT/Pdf4QtViewerPlugins/OutputPreviewPlugin/outputpreviewdialog.h

99 lines
2.9 KiB
C
Raw Normal View History

2021-01-30 18:54:38 +01:00
// Copyright (C) 2021 Jakub Melka
//
// This file is part of Pdf4Qt.
//
// Pdf4Qt is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Pdf4Qt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Pdf4Qt. If not, see <https://www.gnu.org/licenses/>.
#ifndef OUTPUTPREVIEWDIALOG_H
#define OUTPUTPREVIEWDIALOG_H
2021-01-31 19:15:11 +01:00
#include "pdfdocument.h"
#include "pdfdrawwidget.h"
#include "pdftransparencyrenderer.h"
2021-01-30 18:54:38 +01:00
#include <QDialog>
2021-02-13 19:20:05 +01:00
#include <QFuture>
#include <QFutureWatcher>
2021-01-30 18:54:38 +01:00
namespace Ui
{
class OutputPreviewDialog;
}
namespace pdfplugin
{
class OutputPreviewDialog : public QDialog
{
Q_OBJECT
public:
2021-01-31 19:15:11 +01:00
explicit OutputPreviewDialog(const pdf::PDFDocument* document, pdf::PDFWidget* widget, QWidget* parent);
2021-01-30 18:54:38 +01:00
virtual ~OutputPreviewDialog() override;
2021-02-07 18:59:39 +01:00
virtual void resizeEvent(QResizeEvent* event) override;
2021-02-13 19:20:05 +01:00
virtual void closeEvent(QCloseEvent* event) override;
virtual void showEvent(QShowEvent* event) override;
2021-02-07 18:59:39 +01:00
2021-02-14 18:38:53 +01:00
virtual void accept() override;
virtual void reject() override;
2021-01-30 18:54:38 +01:00
private:
2021-02-13 19:20:05 +01:00
2021-03-27 12:18:56 +01:00
enum DisplayMode
{
Separations,
ColorWarningInkCoverage,
ColorWarningRichBlack,
InkCoverage
};
2021-02-14 18:38:53 +01:00
void updateInks();
void updatePaperColorWidgets();
void onPaperColorChanged();
void onSimulateSeparationsChecked(bool checked);
void onSimulatePaperColorChecked(bool checked);
void onInksChanged(const QModelIndex& topLeft, const QModelIndex& bottomRight, const QVector<int>& roles);
2021-02-13 19:20:05 +01:00
struct RenderedImage
{
QImage image;
2021-03-01 15:24:04 +01:00
QList<pdf::PDFRenderError> errors;
2021-02-13 19:20:05 +01:00
};
void updatePageImage();
void onPageImageRendered();
2021-03-27 12:18:56 +01:00
RenderedImage renderPage(const pdf::PDFPage* page,
QSize renderSize,
pdf::PDFRGB paperColor,
uint32_t activeColorMask,
pdf::PDFTransparencyRendererSettings::Flags additionalFlags);
2021-02-13 19:20:05 +01:00
bool isRenderingDone() const;
2021-01-31 19:15:11 +01:00
2021-01-30 18:54:38 +01:00
Ui::OutputPreviewDialog* ui;
2021-01-31 19:15:11 +01:00
pdf::PDFInkMapper m_inkMapper;
2021-02-14 18:38:53 +01:00
pdf::PDFInkMapper m_inkMapperForRendering;
2021-01-31 19:15:11 +01:00
const pdf::PDFDocument* m_document;
pdf::PDFWidget* m_widget;
2021-02-13 19:20:05 +01:00
bool m_needUpdateImage;
QFuture<RenderedImage> m_future;
QFutureWatcher<RenderedImage>* m_futureWatcher;
2021-01-30 18:54:38 +01:00
};
} // namespace pdf
#endif // OUTPUTPREVIEWDIALOG_H