File indexing completed on 2024-04-28 11:20:52

0001 /*
0002     SPDX-License-Identifier: GPL-2.0-or-later
0003     SPDX-FileCopyrightText: 2009 Alexander Rieder <alexanderrieder@gmail.com>
0004 */
0005 
0006 #ifndef _ANIMATION_H
0007 #define _ANIMATION_H
0008 
0009 #include <QObject>
0010 #include <QTextCursor>
0011 #include <QPointer>
0012 #include <QSharedPointer>
0013 
0014 class QMovie;
0015 
0016 //Represents an animation placed in a QTextDocument
0017 class Animation : public QObject
0018 {
0019   Q_OBJECT
0020   public:
0021     explicit Animation( QObject* parent=nullptr);
0022     ~Animation() override;
0023 
0024     void setMovie(QMovie* movie);
0025     QMovie* movie();
0026 
0027     void setPosition(const QTextCursor& cursor);
0028     QTextCursor position();
0029 
0030   public Q_SLOTS:
0031     void movieFrameChanged();
0032 
0033   private:
0034     QPointer<QMovie> m_movie;
0035     QTextCursor m_position;
0036 };
0037 
0038 
0039 //Helper Object used for storing Animations in the TextCharFormat
0040 class AnimationHelperItem
0041 {
0042   public:
0043     AnimationHelperItem( );
0044     AnimationHelperItem( const AnimationHelperItem& other);
0045     ~AnimationHelperItem() = default;
0046 
0047     QTextCursor position() const;
0048     void setPosition(const QTextCursor& cursor);
0049 
0050     void setMovie(QMovie* movie);
0051     QMovie* movie() const;
0052 
0053   private:
0054     QSharedPointer<Animation> m_animation;
0055 };
0056 
0057 
0058 Q_DECLARE_METATYPE(AnimationHelperItem)
0059 
0060 #endif /* _ANIMATION_H */