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

0001 //////////////////////////////////////////////////////////////////////////////
0002 // oxygentoolboxengine.h
0003 // stores event filters and maps widgets to timelines for animations
0004 // -------------------
0005 //
0006 // SPDX-FileCopyrightText: 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0007 //
0008 // SPDX-License-Identifier: MIT
0009 //////////////////////////////////////////////////////////////////////////////
0010 
0011 #include "oxygentoolboxengine.h"
0012 
0013 namespace Oxygen
0014 {
0015 //____________________________________________________________
0016 bool ToolBoxEngine::registerWidget(QWidget *widget)
0017 {
0018     if (!widget)
0019         return false;
0020     if (!_data.contains(widget)) {
0021         _data.insert(widget, new WidgetStateData(this, widget, duration()), enabled());
0022     }
0023 
0024     // connect destruction signal
0025     connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(unregisterWidget(QObject *)), Qt::UniqueConnection);
0026     return true;
0027 }
0028 
0029 //____________________________________________________________
0030 bool ToolBoxEngine::updateState(const QPaintDevice *object, bool value)
0031 {
0032     PaintDeviceDataMap<WidgetStateData>::Value data(ToolBoxEngine::data(object));
0033     return (data && data.data()->updateState(value));
0034 }
0035 
0036 //____________________________________________________________
0037 bool ToolBoxEngine::isAnimated(const QPaintDevice *object)
0038 {
0039     PaintDeviceDataMap<WidgetStateData>::Value data(ToolBoxEngine::data(object));
0040     return (data && data.data()->animation() && data.data()->animation().data()->isRunning());
0041 }
0042 }