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

0001 #ifndef oxygenbusyindicatorengine_h
0002 #define oxygenbusyindicatorengine_h
0003 
0004 //////////////////////////////////////////////////////////////////////////////
0005 // oxygenbusyindicatorengine.h
0006 // handle progress bar busy indicator
0007 // -------------------
0008 //
0009 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0010 //
0011 // SPDX-License-Identifier: MIT
0012 //////////////////////////////////////////////////////////////////////////////
0013 
0014 #include "oxygenanimation.h"
0015 #include "oxygenbaseengine.h"
0016 #include "oxygenbusyindicatordata.h"
0017 #include "oxygendatamap.h"
0018 
0019 namespace Oxygen
0020 {
0021 //* handles progress bar animations
0022 class BusyIndicatorEngine : public BaseEngine
0023 {
0024     Q_OBJECT
0025 
0026     //* declare opacity property
0027     Q_PROPERTY(qreal value READ value WRITE setValue)
0028 
0029 public:
0030     //* constructor
0031     explicit BusyIndicatorEngine(QObject *);
0032 
0033     //*@name accessors
0034     //@{
0035 
0036     //* true if widget is animated
0037     bool isAnimated(const QObject *);
0038 
0039     //* value
0040     qreal value(void) const
0041     {
0042         return _value;
0043     }
0044 
0045     //@}
0046 
0047     //*@name modifiers
0048     //@{
0049 
0050     //* register progressbar
0051     bool registerWidget(QObject *);
0052 
0053     //* duration
0054     void setDuration(int) override;
0055 
0056     //* set object as animated
0057     void setAnimated(const QObject *, bool);
0058 
0059     //* opacity
0060     void setValue(qreal value);
0061 
0062     //@}
0063 
0064 public Q_SLOTS:
0065 
0066     //* remove widget from map
0067     bool unregisterWidget(QObject *) override;
0068 
0069 private:
0070     //* returns data associated to widget
0071     DataMap<BusyIndicatorData>::Value data(const QObject *);
0072 
0073     //* map widgets to progressbar data
0074     DataMap<BusyIndicatorData> _data;
0075 
0076     //* animation
0077     Animation::Pointer _animation;
0078 
0079     //* value
0080     qreal _value = 0;
0081 };
0082 }
0083 
0084 #endif