File indexing completed on 2024-05-19 05:35:25
0001 #ifndef oxygenlabel_datah 0002 #define oxygenlabel_datah 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // oxygenlabeldata.h 0006 // data container for QLabel transition 0007 // ------------------- 0008 // 0009 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0010 // 0011 // SPDX-License-Identifier: MIT 0012 ////////////////////////////////////////////////////////////////////////////// 0013 0014 #include "oxygentransitiondata.h" 0015 0016 #include <QBasicTimer> 0017 #include <QLabel> 0018 #include <QString> 0019 0020 namespace Oxygen 0021 { 0022 //* generic data 0023 class LabelData : public TransitionData 0024 { 0025 Q_OBJECT 0026 0027 public: 0028 //* constructor 0029 LabelData(QObject *, QLabel *, int); 0030 0031 //* event filter 0032 bool eventFilter(QObject *, QEvent *) override; 0033 0034 //* returns true if animations are locked 0035 bool isLocked(void) const 0036 { 0037 return _animationLockTimer.isActive(); 0038 } 0039 0040 //* start lock animation timer 0041 void lockAnimations(void) 0042 { 0043 _animationLockTimer.start(_lockTime, this); 0044 } 0045 0046 //* start lock animation timer 0047 void unlockAnimations(void) 0048 { 0049 _animationLockTimer.stop(); 0050 } 0051 0052 protected: 0053 //* timer event 0054 void timerEvent(QTimerEvent *) override; 0055 0056 protected Q_SLOTS: 0057 0058 //* initialize animation 0059 bool initializeAnimation(void) override; 0060 0061 //* animate 0062 bool animate(void) override; 0063 0064 private Q_SLOTS: 0065 0066 //* called when target is destroyed 0067 void targetDestroyed(void); 0068 0069 private: 0070 //* true if transparent 0071 bool transparent(void) const 0072 { 0073 return transition() && transition().data()->testFlag(TransitionWidget::Transparent); 0074 } 0075 0076 private: 0077 //* lock time (milliseconds 0078 static const int _lockTime; 0079 0080 //* timer used to disable animations when triggered too early 0081 QBasicTimer _animationLockTimer; 0082 0083 //* needed to start animations out of parent paintEvent 0084 QBasicTimer _timer; 0085 0086 //* target 0087 WeakPointer<QLabel> _target; 0088 0089 //* old text 0090 QString _text; 0091 0092 //* widget rect 0093 /** needed to properly handle QLabel geometry changes */ 0094 QRect _widgetRect; 0095 }; 0096 } 0097 0098 #endif