File indexing completed on 2024-05-12 13:38:21

0001 #ifndef oxygenanimation_h
0002 #define oxygenanimation_h
0003 //////////////////////////////////////////////////////////////////////////////
0004 // oxygenanimation.h
0005 // stores event filters and maps widgets to animations for animations
0006 // -------------------
0007 //
0008 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0009 //
0010 // SPDX-License-Identifier: MIT
0011 //////////////////////////////////////////////////////////////////////////////
0012 
0013 #include <QPointer>
0014 #include <QPropertyAnimation>
0015 #include <QVariant>
0016 
0017 #include "oxygen_export.h"
0018 
0019 #include "liboxygen.h"
0020 
0021 namespace Oxygen
0022 {
0023 
0024 class OXYGEN_EXPORT Animation : public QPropertyAnimation
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     //! TimeLine shared pointer
0030     using Pointer = WeakPointer<Animation>;
0031 
0032     //! constructor
0033     Animation(int duration, QObject *parent)
0034         : QPropertyAnimation(parent)
0035     {
0036         setDuration(duration);
0037     }
0038 
0039     //! true if running
0040     bool isRunning(void) const
0041     {
0042         return state() == Animation::Running;
0043     }
0044 
0045     //! restart
0046     void restart(void)
0047     {
0048         if (isRunning())
0049             stop();
0050         start();
0051     }
0052 };
0053 }
0054 
0055 #endif