1
//////////////////////////////////////////////////////////////////////////////
2
// oxygentoolbarengine.cpp
3
// stores event filters and maps widgets to timelines for animations
6
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
8
// Permission is hereby granted, free of charge, to any person obtaining a copy
9
// of this software and associated documentation files (the "Software"), to
10
// deal in the Software without restriction, including without limitation the
11
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12
// sell copies of the Software, and to permit persons to whom the Software is
13
// furnished to do so, subject to the following conditions:
15
// The above copyright notice and this permission notice shall be included in
16
// all copies or substantial portions of the Software.
18
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
//////////////////////////////////////////////////////////////////////////////
27
#include "oxygentoolbarengine.h"
28
#include "oxygentoolbarengine.moc"
30
#include <QtCore/QEvent>
35
//____________________________________________________________
36
void ToolBarEngine::registerWidget( QWidget* widget )
41
// create new data class
42
if( !_data.contains( widget ) )
44
DataMap<ToolBarData>::Value value( new ToolBarData( this, widget, duration() ) );
45
value.data()->setFollowMouseDuration( followMouseDuration() );
46
_data.insert( widget, value, enabled() );
49
// connect destruction signal
50
disconnect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ) );
51
connect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ) );
55
//____________________________________________________________
56
BaseEngine::WidgetList ToolBarEngine::registeredWidgets( void ) const
60
// the typedef is needed to make Krazy happy
61
typedef DataMap<ToolBarData>::Value Value;
62
foreach( const Value& value, _data )
63
{ if( value ) out.insert( value.data()->target().data() ); }
67
//____________________________________________________________
68
bool ToolBarEngine::isAnimated( const QObject* object )
70
if( !enabled() ) return false;
72
DataMap<ToolBarData>::Value data( _data.find( object ) );
73
if( !data ) return false;
74
if( Animation::Pointer animation = data.data()->animation() ) return animation.data()->isRunning();
78
//____________________________________________________________
79
bool ToolBarEngine::isFollowMouseAnimated( const QObject* object )
81
if( !enabled() ) return false;
83
DataMap<ToolBarData>::Value data( _data.find( object ) );
84
if( !data ) return false;
85
if( Animation::Pointer animation = data.data()->progressAnimation() ) return animation.data()->isRunning();
89
//____________________________________________________________
90
QRect ToolBarEngine::currentRect( const QObject* object )
92
if( !enabled() ) return QRect();
93
DataMap<ToolBarData>::Value data( _data.find( object ) );
94
return data ? data.data()->currentRect():QRect();
97
//____________________________________________________________
98
QRect ToolBarEngine::animatedRect( const QObject* object )
100
if( !enabled() ) return QRect();
101
DataMap<ToolBarData>::Value data( _data.find( object ) );
102
return data ? data.data()->animatedRect():QRect();
105
//____________________________________________________________
106
bool ToolBarEngine::isTimerActive( const QObject* object )
108
if( !enabled() ) return false;
109
DataMap<ToolBarData>::Value data( _data.find( object ) );
110
return data ? data.data()->timer().isActive():false;