File indexing completed on 2024-04-21 04:33:48

0001 /*******************************************************************************
0002  * Copyright (C) 2020 by Steve Allewell                                        *
0003  * steve.allewell@gmail.com                                                    *
0004  *                                                                             *
0005  * This program is free software; you can redistribute it and/or modify        *
0006  * it under the terms of the GNU General Public License as published by        *
0007  * the Free Software Foundation; either version 2 of the License, or           *
0008  * (at your option) any later version.                                         *
0009  ******************************************************************************/
0010 
0011 
0012 #ifndef ViewerTab_H
0013 #define ViewerTab_H
0014 
0015 
0016 #include <QPixmap>
0017 #include <QString>
0018 #include <QTimer>
0019 #include <QWidget>
0020 
0021 #include <poppler-qt5.h>
0022 
0023 #include "ui_ViewerTab.h"
0024 
0025 
0026 class QResizeEvent;
0027 class QShowEvent;
0028 class QUrl;
0029 
0030 
0031 class ViewerTab : public QWidget
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     explicit ViewerTab(QWidget *parent);
0037     ~ViewerTab();
0038 
0039     int load(const QUrl &url);
0040 
0041     QString title() const;
0042 
0043     QByteArray pdfData();
0044 
0045     void print();
0046 
0047 protected slots:
0048     void renderPages();
0049     void splitterMoved(int pos, int index);
0050     void valueChanged(int value);
0051 
0052 protected:
0053     void quickScale();
0054     void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
0055     void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
0056 
0057 private:
0058     Ui::ViewerTab   ui;
0059 
0060     Poppler::Document *m_document;
0061 
0062     QByteArray      m_pdfData;
0063     QPixmap         m_pixmap;
0064     QString         m_tabTitle;
0065     QString         m_website;
0066 
0067     QTimer          m_timer;
0068 };
0069 
0070 
0071 #endif