blob: e4fe1a67cbc96b2b7416aed98b35086e98734590 (
plain)
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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef PDFVIEWER_H
#define PDFVIEWER_H
#include "viewerinterfaces.h"
#include <QLoggingCategory>
Q_DECLARE_LOGGING_CATEGORY(lcExample)
class QMainWindow;
class QPdfDocument;
class QPdfView;
class QPdfPageSelector;
class QListView;
class QTabWidget;
class QTreeView;
class ZoomSelector;
class PdfViewer : public ViewerInterface
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.DocumentViewer.ViewerInterface" FILE "pdfviewer.json")
Q_INTERFACES(ViewerInterface)
public:
~PdfViewer() override;
void init(QFile *file, QWidget *parent, QMainWindow *mainWindow) override;
QString viewerName() const override { return staticMetaObject.className(); };
QStringList supportedMimeTypes() const override;
bool supportsOverview() const override { return true; }
bool hasContent() const override;
QByteArray saveState() const override { return QByteArray(); }
bool restoreState(QByteArray &) override { return true; }
#ifdef QT_DOCUMENTVIEWER_PRINTSUPPORT
protected:
void printDocument(QPrinter *printer) const override;
#endif // QT_DOCUMENTVIEWER_PRINTSUPPORT
public slots:
void openPdfFile();
private slots:
void initPdfViewer();
void bookmarkSelected(const QModelIndex &index);
void pageSelected(int page);
// action handlers
void onActionOpenTriggered();
void onActionQuitTriggered();
void onActionZoomInTriggered();
void onActionZoomOutTriggered();
void onActionPreviousPageTriggered();
void onActionNextPageTriggered();
void onActionBackTriggered();
void onActionForwardTriggered();
private:
void populateQuestions();
const qreal zoomMultiplier = qSqrt(2.0);
static constexpr int maxIconWidth = 200;
QToolBar *m_toolBar = nullptr;
ZoomSelector *m_zoomSelector = nullptr;
QPdfPageSelector *m_pageSelector = nullptr;
QPdfDocument *m_document = nullptr;
QPdfView *m_pdfView = nullptr;
QAction *m_actionForward = nullptr;
QAction *m_actionBack = nullptr;
QTreeView *m_bookmarks = nullptr;
QListView *m_pages = nullptr;
};
#endif //PDFVIEWER_H
|