File indexing completed on 2024-05-05 05:35:32

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 class OXYGEN_EXPORT Animation : public QPropertyAnimation
0024 {
0025     Q_OBJECT
0026 
0027 public:
0028     //! TimeLine shared pointer
0029     using Pointer = WeakPointer<Animation>;
0030 
0031     //! constructor
0032     Animation(int duration, QObject *parent)
0033         : QPropertyAnimation(parent)
0034     {
0035         setDuration(duration);
0036     }
0037 
0038     //! true if running
0039     bool isRunning(void) const
0040     {
0041         return state() == Animation::Running;
0042     }
0043 
0044     //! restart
0045     void restart(void)
0046     {
0047         if (isRunning())
0048             stop();
0049         start();
0050     }
0051 };
0052 }
0053 
0054 #endif