CCIMXDesktop
 
Loading...
Searching...
No Matches
ccpdfviewer.h
1#ifndef CCPDFVIEWER_H
2#define CCPDFVIEWER_H
3
4#include <QImage>
5#include <QWidget>
6
7/* Forward declarations */
8class CCPdfDocument;
9class QScrollArea;
10class QLabel;
11
12namespace Ui {
13class CCPdfViewer;
14}
15
22class CCPdfViewer : public QWidget {
23 Q_OBJECT
24
25public:
30 explicit CCPdfViewer(QWidget* parent = nullptr);
36
41
48
52 void unbindDocument();
53
58 inline float current_zoom() const {
59 return view_zoom;
60 }
61
66 inline void set_zoom_step(const float zoom_step) {
67 this->zoom_step = zoom_step;
68 }
69
74 enum class ZoomDirection {
75 ZOOM_IN,
77 };
78
79public slots:
84 inline void zoom(const ZoomDirection direction) {
85 switch (direction) {
87 view_zoom += zoom_step;
88 break;
90 view_zoom -= zoom_step;
91 break;
92 }
93 }
94
99 inline void fresh_zoom(const ZoomDirection direction) {
100 zoom(direction);
101 fresh_render();
102 }
103
104public slots:
108 void fresh_render();
109
110private:
111 Ui::CCPdfViewer* ui;
112 CCPdfDocument* document_for_view { nullptr };
113 float view_zoom { 1.0f };
114 float zoom_step { 0.1f };
115 QImage cached_image;
116 QLabel* imageLabel;
121 void init_internal(void);
122};
123
124#endif // CCPDFVIEWER_H
The CCPdfDocument class CCPdfDocument manages the lifetime and access to a PDF document....
Definition ccpdfdocument.h:24
Provides a widget to view PDF documents at the page level.
Definition ccpdfviewer.h:22
void unbindDocument()
Unbinds the currently bound document.
Definition ccpdfviewer.cpp:40
float current_zoom() const
Returns the current zoom level.
Definition ccpdfviewer.h:58
void zoom(const ZoomDirection direction)
Applies zoom in the specified direction.
Definition ccpdfviewer.h:84
~CCPdfViewer()
Destructor.
Definition ccpdfviewer.cpp:65
Q_DISABLE_COPY(CCPdfViewer)
disable copy object
void set_zoom_step(const float zoom_step)
Sets the zoom step value.
Definition ccpdfviewer.h:66
void fresh_render()
Refreshes the rendered page view.
Definition ccpdfviewer.cpp:49
ZoomDirection
Specifies the direction of zooming.
Definition ccpdfviewer.h:74
bool bindDocument(CCPdfDocument *bindDocument)
Binds a PDF document to the viewer.
Definition ccpdfviewer.cpp:26
void fresh_zoom(const ZoomDirection direction)
Zooms and refreshes the rendered view.
Definition ccpdfviewer.h:99