File indexing completed on 2024-05-19 05:35:21
0001 #ifndef oxygenspinboxengine_h 0002 #define oxygenspinboxengine_h 0003 0004 ////////////////////////////////////////////////////////////////////////////// 0005 // oxygenspinboxengine.h 0006 // stores event filters and maps widgets to animations 0007 // ------------------- 0008 // 0009 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0010 // 0011 // SPDX-License-Identifier: MIT 0012 ////////////////////////////////////////////////////////////////////////////// 0013 0014 #include "oxygenbaseengine.h" 0015 #include "oxygendatamap.h" 0016 #include "oxygenspinboxdata.h" 0017 0018 namespace Oxygen 0019 { 0020 //* handle spinbox arrows hover effect 0021 class SpinBoxEngine : public BaseEngine 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 //* constructor 0027 explicit SpinBoxEngine(QObject *parent) 0028 : BaseEngine(parent) 0029 { 0030 } 0031 0032 //* register widget 0033 bool registerWidget(QWidget *); 0034 0035 //* state 0036 bool updateState(const QObject *object, QStyle::SubControl subControl, bool value) 0037 { 0038 if (DataMap<SpinBoxData>::Value data = _data.find(object)) { 0039 return data.data()->updateState(subControl, value); 0040 } else 0041 return false; 0042 } 0043 0044 //* true if widget is animated 0045 bool isAnimated(const QObject *object, QStyle::SubControl subControl) 0046 { 0047 if (DataMap<SpinBoxData>::Value data = _data.find(object)) { 0048 return data.data()->isAnimated(subControl); 0049 } else 0050 return false; 0051 } 0052 0053 //* animation opacity 0054 qreal opacity(const QObject *object, QStyle::SubControl subControl) 0055 { 0056 if (DataMap<SpinBoxData>::Value data = _data.find(object)) { 0057 return data.data()->opacity(subControl); 0058 } else 0059 return AnimationData::OpacityInvalid; 0060 } 0061 0062 //* enable state 0063 void setEnabled(bool value) override 0064 { 0065 BaseEngine::setEnabled(value); 0066 _data.setEnabled(value); 0067 } 0068 0069 //* duration 0070 void setDuration(int value) override 0071 { 0072 BaseEngine::setDuration(value); 0073 _data.setDuration(value); 0074 } 0075 0076 public Q_SLOTS: 0077 0078 //* remove widget from map 0079 bool unregisterWidget(QObject *object) override 0080 { 0081 return _data.unregisterWidget(object); 0082 } 0083 0084 private: 0085 //* data map 0086 DataMap<SpinBoxData> _data; 0087 }; 0088 } 0089 0090 #endif