-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprojcontroller.h
executable file
·280 lines (267 loc) · 9.15 KB
/
projcontroller.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/* Copyright 2016 Pascal COMBES <[email protected]>
*
* This file is part of ProSlideShower.
*
* ProSlideShower is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ProSlideShower is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ProSlideShower. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef PROJCONTROLLER_H
#define PROJCONTROLLER_H
#include <QWidget>
#include "subdisplayhandler.h"
#include "presstyle.h"
#include "projcontrollerpane.h"
#include <QTimer>
#include <QTime>
class PresModel;
class ProjDisplay;
class QSplitter;
class QLabel;
class QProgressBar;
/*!
* \brief The ProjController describes a widget controller for the presentation
*
* This class allows to control easily the unfolding of the presentation.
* It is only useful to the presenter and is not shown to the audience.
*
* It displays up to three ProjDisplay in a splitter, so that uneeded views
* can easily be closed. It also shows progress bars for the presentation
* and the time. The color of the bars changes depending on whether the presentation
* is too fast or too slow. Finally, there is a miniature gallery, which allows to
* easily reach the desired slide in the presentation.
*/
class ProjController : public QWidget
{
Q_OBJECT
public:
/*!
* \brief Construnctor
*
* Initializes the members and allocates the resources.
* \param model The PresModel being presented.
* \param parent The parent widget.
*/
ProjController(PresModel *model, QWidget *parent = NULL);
/*!
* \brief Destructor
*
* Deletes the style and saves presentation time in settings.
*/
~ProjController(void);
/*!
* \brief Set the model
*
* Sets the PresModel from which slides are fetched.
* \param model The PresModel being presented.
* \sa model()
*/
void setModel(PresModel* model);
/*!
* \brief Get the model
*
* Gets the PresModel from which slides are fetched.
* \return The PresModel being presented.
* \sa setModel()
*/
inline PresModel* model(void) const {return mDisplays->model();}
/*!
* \brief Set time format
*
* Sets the format in which the time is displayed.
* \param format The time format to use.
* \sa timeFormat()
*/
inline void setTimeFormat(const QString& format) {mFormat = format; updateTime();}
/*!
* \brief Get time format
*
* Gets the format in which the time is displayed.
* \return The time format used.
* \sa setTimeFormat()
*/
inline QString timeFormat(void) const {return mFormat;}
/*!
* \brief Set presentation duration
*
* Sets the total presentation duration.
* \param length The time of the presentation.
* \sa totalTime()
*/
inline void setTotalTime(const QTime& length) {mTotalTime = length; updateTime();}
/*!
* \brief Get presentation duration
*
* Gets the total presentation duration.
* \return The time of the presentation.
* \sa setTotalTime()
*/
inline QTime totalTime(void) const {return mTotalTime;}
/*!
* \brief Set height of gallery panel
*
* Sets the height of the auto-hide gallery panel
* displaying the miniatures of the slides in the presentation.
* \param height The height of the gallery panel to use.
* \sa paneHeight()
*/
inline void setPaneHeight(int height) {mPane->setFixedHeight(height);}
/*!
* \brief Get height of gallery panel
*
* Gets the height of the auto-hide gallery panel
* displaying the miniatures of the slides in the presentation.
* \return The height of the gallery panel in use.
* \sa setPaneHeight()
*/
inline int paneHeight(void) const {return mPane->height();}
/*!
* \brief Whether gallery panel is shown
*
* Tells whether the auto-hide gallery panel displaying
* the miniatures of the slides in the presentation is being shown.
* \return \c true, if it is shown, \c false otherwise.
* \sa showControlPane(), hideControlPane()
*/
inline bool isPaneShown(void) const {return mPane->isVisible();}
public slots:
/*!
* \brief Go to next page
*
* Tells the SubDisplayHandler to switch to the next page,
* which changes the current page in the PresModel.
*
* Also start the presentation, it it is not already started.
* \sa goToPrevPage(), SubDisplayHandler::goToNextPage()
*/
inline void goToNextPage() {mDisplays->goToNextPage(); start();}
/*!
* \brief Go to previous page
*
* Tells the SubDisplayHandler to switch to the previous page,
* which changes the current page in the PresModel.
* \sa goToNextPage(), SubDisplayHandler::goToPrevPage()
*/
inline void goToPrevPage() {mDisplays->goToPrevPage();}
/*!
* \brief Start the presentation
*
* Starts the presentation, which means that the presentation time
* begins to increase.
* \sa stop(), pause()
*/
inline void start(void) {if (!mTimer->isActive()) mTimer->start();}
/*!
* \brief Pause the presentation
*
* Pauses the presentation, which means that the presentation time
* stops increasing but is not reset.
* \sa start(), stop()
*/
inline void pause(void) {if (mTimer->isActive()) mTimer->stop();}
/*!
* \brief Stop the presentation
*
* Stops the prsentation, which means that the presentation time
* is reset.
* \sa start(), pause()
*/
void stop(void);
/*!
* \brief Show the gallery pane
*
* Shows the auto-hide gallery panel displaying
* the miniatures of the slides in the presentation.
* \sa hideControlPane()
*/
inline void showControlPane(void) {mPane->show();}
/*!
* \brief Hide the gallery pane
*
* Hides the auto-hide gallery panel displaying
* the miniatures of the slides in the presentation.
* \sa showControlPane()
*/
inline void hideControlPane(void) {mPane->hide();}
/*!
* \brief Configuration
*
* Opens a dialog to configure the presentation.
* Currently only the total presentation time can be configured.
*/
void configure(void);
private slots:
/*!
* \brief Updates the presentation time
*
* This slot is triggerred every second when the presentation is running.
* It updates the the presentation time.
*/
inline void handleSecondStep(void) {mTime = mTime.addSecs(1); updateTime();}
/*!
* \brief Handle change of document
*
* This slot updates the controller when the document is changed in the PresModel.
* \sa handleFrameChange()
*/
void handleDocumentChange(void);
/*!
* \brief Handle change of frame
*
* This slot is called when the current frame (slide) is changed.
* It updates the frame progress bar.
* \sa handleDocumentChange()
*/
void handleFrameChange(void);
private:
/*!
* \brief Updatesthe displays
*
* Triggers a repaint of the children ProjDisplay.
*/
void updateDisplays(void);
/*!
* \brief Update presentation time
*
* Updates the presentation time progress bar.
* \sa updateColor()
*/
void updateTime(void);
/*!
* \brief Update presentation time
*
* Updates the presentation frame progress bar.
* \sa updateColor()
*/
void updateFrame(void);
/*!
* \brief Updates and repaints the progress bars
*
* Updates the color of the progress bars depending on
* whether the presentation is too fast or too slow
* and triggers the repaint.
* \sa updateTime(), updateFrame()
*/
void updateColor(void);
SubDisplayHandler *mDisplays; /*!< The handler of the children ProjDisplay. */
QSplitter* mSplitter; /*!< The splitter which contains the children ProjDisplay. */
ProjControllerPane* mPane; /*!< The auto-hide pane contraining the miniature gallery for the presentation slides. */
QLabel* mTimeLabel; /*!< The time label displaying the presentation time. */
QLabel* mSlideLabel; /*!< The slide label diplaying the current slide (and also the total number of slides in the presentation). */
QProgressBar* mSlideProgress; /*!< The progress bar for the slides. */
QProgressBar* mTimeProgress; /*!< The progress bar for the time. */
QTimer* mTimer; /*!< The timer which increases the presentation time every second. */
QTime mTime; /*!< The presentation time. */
QTime mTotalTime; /*!< The total duration of the presentation. */
QString mFormat; /*!< The format in which the presentation time will be displayed. */
};
#endif // PROJCONTROLLER_H