File indexing completed on 2024-05-12 16:36:50

0001 /* This file is part of the KDE project
0002  * Copyright (  C ) 2007 Thorsten Zachmann <zachmann@kde.org>
0003  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (  at your option ) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #ifndef KPRVIEWMODEPRESENTATION_H
0021 #define KPRVIEWMODEPRESENTATION_H
0022 
0023 #include <KoPAViewMode.h>
0024 
0025 #include "KPrAnimationDirector.h"
0026 #include "KPrPresentationTool.h"
0027 
0028 class QWidget;
0029 class KPrPresentationTool;
0030 class KPrPresenterViewWidget;
0031 class KPrEndOfSlideShowPage;
0032 class KPrView;
0033 
0034 class STAGE_EXPORT KPrViewModePresentation : public KoPAViewMode
0035 {
0036     Q_OBJECT
0037 
0038 public:
0039     KPrViewModePresentation( KoPAViewBase * view, KoPACanvasBase * m_canvas );
0040     ~KPrViewModePresentation() override;
0041 
0042     KoViewConverter * viewConverter( KoPACanvasBase * canvas ) override;
0043 
0044     void paint(KoPACanvasBase* canvas, QPainter& painter, const QRectF &paintRect) override;
0045     void tabletEvent( QTabletEvent *event, const QPointF &point ) override;
0046     void mousePressEvent( QMouseEvent *event, const QPointF &point ) override;
0047     void mouseDoubleClickEvent( QMouseEvent *event, const QPointF &point ) override;
0048     void mouseMoveEvent( QMouseEvent *event, const QPointF &point ) override;
0049     void mouseReleaseEvent( QMouseEvent *event, const QPointF &point ) override;
0050     void shortcutOverrideEvent( QKeyEvent *event ) override;
0051     void keyPressEvent( QKeyEvent *event ) override;
0052     void keyReleaseEvent( QKeyEvent *event ) override;
0053     void wheelEvent( QWheelEvent * event, const QPointF &point ) override;
0054     void closeEvent( QCloseEvent * event ) override;
0055 
0056     void activate( KoPAViewMode * previousViewMode ) override;
0057     void deactivate() override;
0058 
0059     /// reimplemented
0060     void updateActivePage( KoPAPageBase *page ) override;
0061 
0062     /**
0063      * @brief Activate the saved view mode
0064      *
0065      * This ends the presentation mode. The view mode that was active before the
0066      * presentation will be restored.
0067      */
0068     void activateSavedViewMode();
0069 
0070     /**
0071      * @brief Get the animation director
0072      *
0073      * Get the animation director used for effects
0074      *
0075      * @return animationDirector
0076      */
0077     KPrAnimationDirector * animationDirector();
0078 
0079     /**
0080      * Get the number of pages.
0081      *
0082      * This assumes that the presentation is active.
0083      */
0084     int numPages() const;
0085 
0086     /**
0087      * Get the current page number.
0088      *
0089      * This assumes that the presentation is active.
0090      */
0091     int currentPage() const;
0092 
0093     /**
0094      * Get the number of steps in this page.
0095      *
0096      * This assumes that the presentation is active.
0097      */
0098     int numStepsInPage() const;
0099 
0100     /**
0101      * get the current step.
0102      *
0103      * This assumes that the presentation is active.
0104      */
0105     int currentStep() const;
0106 
0107     /**
0108      * get the current Presentation Tool
0109      *
0110      * This assumes that the presentation is active.
0111      */
0112     KPrPresentationTool * presentationTool() const;
0113 
0114     /**
0115      * Navigate in the presentation.
0116      */
0117     void navigate( KPrAnimationDirector::Navigation navigation );
0118 
0119     Q_INVOKABLE void navigateToPage( int index );
0120     void blackPresentation();
0121 
0122     /**
0123      * Returns whether the presentation is activated or not
0124      */
0125     bool isActivated();
0126 
0127 Q_SIGNALS:
0128 
0129     /**
0130      * Emitted when the presentation is activated.
0131      */
0132     void activated();
0133 
0134     /**
0135      * Emitted when the presentation is about to be deactivated.
0136      */
0137     void deactivated();
0138 
0139     /**
0140      * Emitted when the page changes.
0141      *
0142      * @param page new page index within the current slideshow
0143      * @param stepsInPage the number of steps in the new page
0144      */
0145     void pageChanged( int page, int stepsInPage );
0146 
0147     /**
0148      * Emitted when the step changes.
0149      *
0150      * @param step new step index within the page
0151      */
0152     void stepChanged( int step );
0153 
0154 protected:
0155     KoPAViewMode * m_savedViewMode;
0156     QWidget * m_savedParent;
0157     KPrPresentationTool * m_tool;
0158     KPrAnimationDirector * m_animationDirector;
0159     KPrAnimationDirector * m_pvAnimationDirector;
0160     KoPACanvas * m_presenterViewCanvas;
0161     KoPACanvas * m_baseCanvas;
0162     KPrPresenterViewWidget * m_presenterViewWidget;
0163     KPrEndOfSlideShowPage * m_endOfSlideShowPage;
0164     KPrView *m_view;
0165 };
0166 
0167 Q_DECLARE_METATYPE(KPrViewModePresentation *)
0168 
0169 #endif /* KPRVIEWMODEPRESENTATION_H */