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

0001 /* This file is part of the KDE project
0002    Copyright (C) 2012 Paul Mendez <paulestebanms@gmail.com>
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 KPRVIEWMODEPREVIEWSHAPEANIMATIONS_H
0021 #define KPRVIEWMODEPREVIEWSHAPEANIMATIONS_H
0022 
0023 #include "stage_export.h"
0024 
0025 #include <KoPAViewMode.h>
0026 #include "KPrAnimationDirector.h"
0027 #include <QTimeLine>
0028 
0029 class KPrShapeAnimation;
0030 
0031 /**
0032   * This view mode play a specific shape animation preview
0033   * and return to the previous view mode after finish.
0034   */
0035 class STAGE_EXPORT KPrViewModePreviewShapeAnimations : public KoPAViewMode
0036 {
0037     Q_OBJECT
0038 public:
0039     KPrViewModePreviewShapeAnimations(KoPAViewBase *view, KoPACanvasBase *canvas);
0040     ~KPrViewModePreviewShapeAnimations() override;
0041 
0042     void paint(KoPACanvasBase *canvas, QPainter &painter, const QRectF &paintRect) override;
0043     void tabletEvent(QTabletEvent *event, const QPointF &point) override;
0044     void mousePressEvent(QMouseEvent *event, const QPointF &point) override;
0045     void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &point) override;
0046     void mouseMoveEvent(QMouseEvent *event, const QPointF &point) override;
0047     void mouseReleaseEvent(QMouseEvent *event, const QPointF &point) override;
0048     void shortcutOverrideEvent(QKeyEvent *event) override;
0049     void keyPressEvent(QKeyEvent *event) override;
0050     void keyReleaseEvent(QKeyEvent *event) override;
0051     void wheelEvent(QWheelEvent *event, const QPointF &point) override;
0052 
0053     void activate(KoPAViewMode *previousViewMode) override;
0054     void deactivate() override;
0055 
0056     /// reimplemented
0057     void updateActivePage(KoPAPageBase *page) override;
0058 
0059     /// Set the shape animation to be played
0060     void setShapeAnimation(KPrShapeAnimation *shapeAnimation);
0061 
0062     void stopAnimation();
0063 
0064 public Q_SLOTS:
0065     /**
0066      * @brief Activate the saved view mode
0067      *
0068      * This ends the presentation mode. The view mode that was active before the
0069      * presentation will be restored.
0070      */
0071     void activateSavedViewMode();
0072 
0073 protected Q_SLOTS:
0074     void animate();
0075 
0076 private:
0077 
0078     KoPAViewMode *m_savedViewMode;
0079     QTimeLine m_timeLine;
0080     KPrShapeAnimation *m_shapeAnimation;
0081     KPrAnimationCache *m_animationCache;
0082     QRect m_pageRect;
0083 };
0084 
0085 #endif // KPRVIEWMODEPREVIEWSHAPEANIMATIONS_H