1 /* This file is part of the KDE project
2    Copyright (C) 2006-2007 Thorsten Zachmann <zachmann@kde.org>
3    Copyright (C) 2009-2010 Benjamin Port <port.benjamin@gmail.com>
4 
5    This library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public
7    License as published by the Free Software Foundation; either
8    version 2 of the License, or (at your option) any later version.
9 
10    This library 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 GNU
13    Library General Public License for more details.
14 
15    You should have received a copy of the GNU Library General Public License
16    along with this library; see the file COPYING.LIB.  If not, write to
17    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KPRVIEW_H
22 #define KPRVIEW_H
23 
24 #include "stage_export.h"
25 #include <QObject>
26 #include <KoPAView.h>
27 
28 class KPrDocument;
29 class KPrPart;
30 
31 #ifndef QT_NO_DBUS
32 class KPrViewAdaptor;
33 #endif
34 
35 class KPrViewModeNotes;
36 class KPrViewModeSlidesSorter;
37 class KPrViewModePresentation;
38 class KActionMenu;
39 class KoPAPageBase;
40 
41 class STAGE_EXPORT KPrView : public KoPAView
42 {
43     Q_OBJECT
44     friend class KPrConfigureSlideShowDialog;
45 public:
46     explicit KPrView(KPrPart *part, KPrDocument *document, QWidget *parent = 0);
47     ~KPrView() override;
48 
49     using KoPAViewBase::viewConverter;
50     KoViewConverter * viewConverter( KoPACanvasBase * canvas) override;
51 
52     /**
53      * Get the document object the view was initialised with
54      */
55     KPrDocument * kprDocument() const;
56 
57 #ifndef QT_NO_DBUS
58     /**
59      * Get the view's dbus adaptor
60      */
61     virtual KPrViewAdaptor * dbusObject() const;
62 #endif
63 
64     /**
65      * Get the presentation view mode
66      */
67     Q_INVOKABLE KPrViewModePresentation * presentationMode() const;
68 
69     /**
70      * Get the slides sorter view mode
71      */
72     KPrViewModeSlidesSorter *slidesSorter() const;
73 
74     /**
75      * Find whether the presentation view mode is active
76      */
77     bool isPresentationRunning() const;
78 
79     /**
80       * Load zoom configuration
81       */
82     void initZoomConfig();
83 
84     /**
85       * Restore zoom configuration
86       */
87     void restoreZoomConfig();
88 
89     /**
90       * Save zoom value
91       */
92     void saveZoomConfig(KoZoomMode::Mode zoomMode, int zoom);
93 
94     /**
95      * Setter of the zoom
96      *
97      * @param zoomMode mode
98      * @param zoom zoom percent
99      */
100     void setZoom(KoZoomMode::Mode zoomMode, int zoom);
101 
102     /**
103      * Return the last zoom stored
104      *
105      * @return the last zoom stored
106      */
107     int zoom();
108 
109     /**
110      * Return the last zoom mode stored
111      *
112      * @return the last zoom mode stored
113      */
114     KoZoomMode::Mode zoomMode();
115 
116 public Q_SLOTS:
117     /**
118      * Activate the presentation view mode
119      */
120     void startPresentation();
121 
122     /**
123      * Activate the presentation view mode from the first slide
124      */
125     void startPresentationFromBeginning();
126 
127     /**
128      * Stop the presentation and activate the previously active view mode.
129      */
130     void stopPresentation();
131 
132     void showNormal();
133 
134     /** Change current view mode using a given index */
135     void changeViewByIndex(int index);
136 
137     void replaceActivePage(KoPAPageBase *page, KoPAPageBase *newActivePage);
138 
139 protected:
140     void initGUI();
141     void initActions();
142     bool event(QEvent* event) override;
143 
144 protected Q_SLOTS:
145     void createAnimation();
146     void showNotes();
147     void showSlidesSorter();
148     void editCustomSlideShows();
149     void configureSlideShow();
150     void configurePresenterView();
151     void exportToHtml();
152     void insertPictures();
153     void drawOnPresentation();
154     void highlightPresentation();
155     void blackPresentation();
156     void showStatusBar(bool toggled);
157     /// called if the zoom changed
158     void zoomChanged(KoZoomMode::Mode mode, qreal zoom);
159 
160 private:
161     KPrPart *m_part;
162     QAction *m_actionStopPresentation;
163     QAction *m_actionCreateAnimation;
164     QAction *m_actionViewModeNormal;
165     QAction *m_actionViewModeNotes;
166     QAction *m_actionViewModeSlidesSorter;
167     QAction *m_actionEditCustomSlideShows;
168     QAction *m_actionExportHtml;
169     QAction *m_actionInsertPictures;
170     QAction *m_actionDrawOnPresentation;
171     QAction *m_actionHighlightPresentation;
172     QAction *m_actionBlackPresentation;
173 
174     KPrViewModePresentation *m_presentationMode;
175     KoPAViewMode *m_normalMode;
176     KPrViewModeNotes *m_notesMode;
177     KPrViewModeSlidesSorter *m_slidesSorterMode;
178 
179 #ifndef QT_NO_DBUS
180     KPrViewAdaptor *m_dbus;
181 #endif
182 
183     int m_zoom;
184     KoZoomMode::Mode m_zoomMode;
185 
186     KoPrintJob *createPdfPrintJob() override;
187 };
188 
189 #endif /* KPRVIEW_H */
190