File indexing completed on 2024-05-19 05:28:48
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "breeze.h" 0010 0011 #include <QPropertyAnimation> 0012 #include <QVariant> 0013 0014 namespace Breeze 0015 { 0016 class Animation : public QPropertyAnimation 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 //* convenience 0022 using Pointer = WeakPointer<Animation>; 0023 0024 //* constructor 0025 Animation(int duration, QObject *parent) 0026 : QPropertyAnimation(parent) 0027 { 0028 setDuration(duration); 0029 } 0030 0031 //* true if running 0032 bool isRunning() const 0033 { 0034 return state() == Animation::Running; 0035 } 0036 0037 //* restart 0038 void restart() 0039 { 0040 if (isRunning()) { 0041 stop(); 0042 } 0043 start(); 0044 } 0045 }; 0046 0047 }