File indexing completed on 2024-05-19 05:28:49
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 #include "breezebaseengine.h" 0011 #include "breezedatamap.h" 0012 #include "breezetabbardata.h" 0013 0014 namespace Breeze 0015 { 0016 //* stores tabbar hovered action and timeLine 0017 class TabBarEngine : public BaseEngine 0018 { 0019 Q_OBJECT 0020 0021 public: 0022 //* constructor 0023 explicit TabBarEngine(QObject *parent) 0024 : BaseEngine(parent) 0025 { 0026 } 0027 0028 //* register tabbar 0029 bool registerWidget(QObject *target); 0030 0031 //* true if widget hover state is changed 0032 bool updateState(const QObject *object, const QPoint &, AnimationMode, bool); 0033 0034 //* true if widget is animated 0035 bool isAnimated(const QObject *object, const QPoint &point, AnimationMode); 0036 0037 //* animation opacity 0038 qreal opacity(const QObject *object, const QPoint &point, AnimationMode mode) 0039 { 0040 return isAnimated(object, point, mode) ? data(object, mode).data()->opacity(point) : AnimationData::OpacityInvalid; 0041 } 0042 0043 //* enability 0044 void setEnabled(bool value) override 0045 { 0046 BaseEngine::setEnabled(value); 0047 _hoverData.setEnabled(value); 0048 _focusData.setEnabled(value); 0049 } 0050 0051 //* duration 0052 void setDuration(int value) override 0053 { 0054 BaseEngine::setDuration(value); 0055 _hoverData.setDuration(value); 0056 _focusData.setDuration(value); 0057 } 0058 0059 public Q_SLOTS: 0060 0061 //* remove widget from map 0062 bool unregisterWidget(QObject *object) override 0063 { 0064 if (!object) { 0065 return false; 0066 } 0067 bool found = false; 0068 if (_hoverData.unregisterWidget(object)) { 0069 found = true; 0070 } 0071 if (_focusData.unregisterWidget(object)) { 0072 found = true; 0073 } 0074 return found; 0075 } 0076 0077 private: 0078 //* returns data associated to widget 0079 DataMap<TabBarData>::Value data(const QObject *, AnimationMode); 0080 0081 //* data map 0082 DataMap<TabBarData> _hoverData; 0083 DataMap<TabBarData> _focusData; 0084 }; 0085 0086 }