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 RUNTIMECONFIGURATION_H
22 #define RUNTIMECONFIGURATION_H
23 #include <QObject>
24 #include <string>
25 #include <QString>
26 #include <stdexcept>
27 #include "pagepart.h"
28 #include "pdfcacheoption.h"
29 
30 struct noFileNameException: public std::logic_error {
31 	noFileNameException();
32 };
33 
34 class RuntimeConfiguration: public QObject
35 {
36 	Q_OBJECT
37 
38   /** Use the program to render a standard PDF (i.e. display
39    * the full page on both sides)
40    */
41   bool	m_useFullPage;
42 
43   /** Show presenter area
44    */
45   bool m_showPresenterArea;
46 
47   /** Show a full second screen
48    */
49   bool m_duplicate;
50 
51   /** Show the wall clock
52    */
53   bool m_showWallClock;
54 
55   /** Show the thumbnails of previous, this and next slide */
56   bool m_showThumbnails;
57 
58   /** Select page part of the thumbnails */
59   PagePart m_thumbnailPagePart;
60 
61   /** Show the total presentation time **/
62   bool m_showPresentationClock;
63 
64   /** Show the current slide time **/
65   bool m_showSlideClock;
66 
67   /** complete path to the PDF file */
68   std::string m_filePath;
69 
70   /** Support PDF Hyperlinks**/
71   bool m_hyperlinkSupport;
72 
73   /** Shall the complete PDF be read into memory */
74   bool m_cacheToMemory;
75 
76   /** Size of the pre-render-cache in megabytes */
77   unsigned m_cacheSizeMegaBytes;
78 
79   /** Single-Display mode
80    *
81    * If True, there is only the audience display, the presenter's screen will remain hidden
82    * Probably most useful with -f
83    */
84   bool m_useSecondScreen;
85 
86   /** Workaround for i3 window manager active
87    */
88   bool m_i3workaround;
89 
90   /** Make sure that so many previous pages are pre-rendered
91    * (Probably wont make sense until you can jump to slide
92    * n without visiting 0..(n-1) first, but once PDF hyperlinks
93    * are enabled, this will be quite useful.
94    */
95   unsigned m_prerenderPreviousPages;
96 
97   /** Make sure so many next pages are pre-rendered
98    */
99   unsigned m_prerenderNextPages;
100 
101   /**
102    * Percentage of the second screen devoted to the bottom pane
103    */
104   unsigned m_bottomPaneHeightPercent;
105 public:
106 
107   /** fill the variables based on the config file and the C-style arguments to main()
108    *
109    * Note: Reads the config file before command-line arguments.
110    * Command-line overrides config.
111    *
112    * Note: Might call exit() if a terminating option like --help
113    * or --version was called.
114    *
115    * Note: Might throw exceptions if not parsable.
116    */
117   RuntimeConfiguration(int argc, const char * const * argv);
118 
119   bool useFullPage() const;
120 
121   bool filePathDefined() const;
122 
123   QString filePathQString() const;
124 
125   std::string filePath() const;
126   void filePath(const std::string& newPath);
127 
128   bool showPresenterArea() const;
129   bool duplicate() const;
130   bool showWallClock() const;
131   bool showThumbnails() const;
132   PagePart thumbnailPagePart() const;
133   bool showPresentationClock() const;
134   bool showSlideClock() const;
135 
136   unsigned prerenderPreviousPages() const;
137   unsigned prerenderNextPages() const;
138 
139   unsigned cacheSizeMegaBytes() const;
140   unsigned cacheSizeBytes() const;
141 
142   bool useSecondScreen() const;
143 
144   PDFCacheOption cacheSetting() const;
145 
146   unsigned bottomPaneHeight() const;
147   bool hyperlinkSupport() const;
148 
149   /* Use i3-workaround.
150    *
151    * In the future, this might auto-detect if we're running on i3.
152    */
153   bool i3workaround() const;
154 
155   /* What shellcode to execute.
156    *
157    * This may be programatically generated in the future.
158    */
159   std::string i3workaround_shellcode() const;
160 };
161 
162 #endif // RUNTIMECONFIGURATION_H
163