-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.h
More file actions
74 lines (63 loc) · 2.15 KB
/
renderer.h
File metadata and controls
74 lines (63 loc) · 2.15 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Support for reading various file formats.
* Copyright (c) 2021 Benjamin Johnson
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef RENDERER_H
#define RENDERER_H
#include <QObject> // inherited by basically everything else
#include <QString>
#include <QMimeType>
/*
* The Renderer processes files into a format the Viewer can display.
*
* It is intended to run in its own QThread, to prevent long render operations
* from locking up the user interface.
*
* If you're adding support for a new file format, this is the place to start.
*/
class Renderer : public QObject
{
Q_OBJECT
public:
Renderer(const QString &path, int dpiX, int dpiY);
static void init();
enum RenderMode { TextContent, PagedContent };
public slots:
void render();
signals:
void renderMode(int mode); // should be a value from RenderMode
void renderProgress(int pagesDone, int pagesTotal);
// Use for standard image files
void renderedImage(const QImage &image);
// Use for pages from a multi-page document like a PDF file
void renderedPage(const QImage &image);
// Use for plain text
void renderedText(const QString &text);
private:
QString path;
QMimeType mimeType;
int dpiX, dpiY;
void renderError(const QString &details = QString());
void renderImage();
void renderPDF(void *document = nullptr);
void renderPS();
void renderXPS();
void renderText();
void renderTIFF();
void renderUnidentified();
};
#endif /* RENDERER_H */