1 /* 2 dspdfviewer - Dual Screen PDF Viewer for LaTeX-Beamer 3 Copyright (C) 2012 Danny Edel <mail@danny-edel.de> 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License along 16 with this program; if not, write to the Free Software Foundation, Inc., 17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 */ 19 20 21 #ifndef dspdfviewer_H 22 #define dspdfviewer_H 23 24 #include <QObject> 25 #include <QElapsedTimer> 26 #include <QTimer> 27 #include <QFileSystemWatcher> 28 #include "poppler-qt.h" 29 30 #include "pdfviewerwindow.h" 31 #include "pdfrenderfactory.h" 32 #include "runtimeconfiguration.h" 33 34 class DSPDFViewer: public QObject 35 { 36 Q_OBJECT 37 38 private: 39 const RuntimeConfiguration& runtimeConfiguration; 40 enum { 41 TIMER_UPDATE_INTERVAL=250 42 }; 43 44 private: 45 QTimer clockDisplayTimer; 46 QElapsedTimer slideStart; 47 QElapsedTimer presentationStart; 48 bool presentationClockRunning; 49 50 private: 51 QFileSystemWatcher documentFileWatcher; 52 PdfRenderFactory renderFactory; 53 unsigned int m_pagenumber; 54 PDFViewerWindow audienceWindow; 55 PDFViewerWindow secondaryWindow; 56 57 58 59 private: 60 QString timeToString(QTime time) const; 61 QString timeToString(int milliseconds) const; 62 void resetSlideClock(); 63 64 RenderingIdentifier toRenderIdent(unsigned int pageNumber, const PDFViewerWindow& window); 65 RenderingIdentifier toThumbnailRenderIdent(unsigned int pageNumber, PDFViewerWindow& window); 66 67 private slots: 68 void sendAllClockSignals() const; 69 70 public: 71 DSPDFViewer(const RuntimeConfiguration& r); 72 virtual ~DSPDFViewer(); 73 74 75 /** get current page number 76 */ 77 unsigned int pageNumber() const; 78 79 /** get page count 80 */ 81 unsigned int numberOfPages() const; 82 83 void setHighQuality(bool hq); 84 85 bool isReadyToRender() const; 86 87 PdfRenderFactory* theFactory(); 88 89 QTime wallClock() const; 90 QTime slideClock() const; 91 QTime presentationClock() const; 92 93 QTime timeSince( const QElapsedTimer& startPoint) const; 94 95 bool isAudienceScreenBlank() const; 96 97 /** Allow const access to the windows' positions. 98 * Needed for tests to inspect things. */ 99 const QRect audienceGeometry() const; 100 const QRect secondGeometry() const; 101 102 signals: 103 void wallClockUpdate(const QTime& wallClock) const; 104 void slideClockUpdate(const QTime& slideClock) const; 105 void presentationClockUpdate(const QTime& presentationClock) const; 106 107 public slots: 108 /** (re-)Renders the current page on both monitors 109 */ 110 void renderPage(); 111 112 /** goes to the specified page. Pages start at zero. 113 */ 114 void gotoPage(unsigned int pageNumber); 115 /** go Forward one page 116 */ 117 void goForward(); 118 119 /** go backward one page 120 */ 121 void goBackward(); 122 123 void goToStartAndResetClocks(); 124 125 void swapScreens(); 126 127 void toggleAudienceScreenBlank(); 128 void setAudienceScreenBlank(); 129 void setAudienceScreenVisible(); 130 131 void toggleSecondaryScreenFunction(); 132 void toggleSecondaryScreenDuplication(); 133 134 void exit(); 135 }; 136 137 #endif // dspdfviewer_H 138