File indexing completed on 2024-05-19 05:35:22
0001 #ifndef oxygentabbarengine_h 0002 #define oxygentabbarengine_h 0003 /* 0004 SPDX-FileCopyrightText: 2014 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #include "oxygen.h" 0009 #include "oxygenbaseengine.h" 0010 #include "oxygendatamap.h" 0011 #include "oxygentabbardata.h" 0012 0013 namespace Oxygen 0014 { 0015 //* stores tabbar hovered action and timeLine 0016 class TabBarEngine : public BaseEngine 0017 { 0018 Q_OBJECT 0019 0020 public: 0021 //* constructor 0022 explicit TabBarEngine(QObject *parent) 0023 : BaseEngine(parent) 0024 { 0025 } 0026 0027 //* register tabbar 0028 bool registerWidget(QWidget *); 0029 0030 //* true if widget hover state is changed 0031 bool updateState(const QObject *, const QPoint &, AnimationMode, bool); 0032 0033 //* true if widget is animated 0034 bool isAnimated(const QObject *object, const QPoint &point, AnimationMode); 0035 0036 //* animation opacity 0037 qreal opacity(const QObject *object, const QPoint &point, AnimationMode mode) 0038 { 0039 return isAnimated(object, point, mode) ? data(object, mode).data()->opacity(point) : AnimationData::OpacityInvalid; 0040 } 0041 0042 //* enable state 0043 void setEnabled(bool value) override 0044 { 0045 BaseEngine::setEnabled(value); 0046 _hoverData.setEnabled(value); 0047 _focusData.setEnabled(value); 0048 } 0049 0050 //* duration 0051 void setDuration(int value) override 0052 { 0053 BaseEngine::setDuration(value); 0054 _hoverData.setDuration(value); 0055 _focusData.setDuration(value); 0056 } 0057 0058 public Q_SLOTS: 0059 0060 //* remove widget from map 0061 bool unregisterWidget(QObject *object) override 0062 { 0063 if (!object) 0064 return false; 0065 bool found = false; 0066 if (_hoverData.unregisterWidget(object)) 0067 found = true; 0068 if (_focusData.unregisterWidget(object)) 0069 found = true; 0070 return found; 0071 } 0072 0073 private: 0074 //* returns data associated to widget 0075 DataMap<TabBarData>::Value data(const QObject *, AnimationMode); 0076 0077 //* data map 0078 DataMap<TabBarData> _hoverData; 0079 DataMap<TabBarData> _focusData; 0080 }; 0081 } 0082 0083 #endif