1
//////////////////////////////////////////////////////////////////////////////
2
// oxygenmenubarengine.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 "oxygenmenubarengine.h"
28
#include "oxygenmenubarengine.moc"
30
#include <QtCore/QEvent>
35
//____________________________________________________________
36
MenuBarEngineV1::MenuBarEngineV1( QObject* parent, MenuBarBaseEngine* other ):
37
MenuBarBaseEngine( parent )
41
foreach( QWidget* widget, other->registeredWidgets() )
42
{ registerWidget( widget ); }
46
//____________________________________________________________
47
bool MenuBarEngineV1::registerWidget( QWidget* widget )
50
if( !widget ) return false;
52
// create new data class
53
if( !_data.contains( widget ) ) _data.insert( widget, new MenuBarDataV1( this, widget, duration() ), enabled() );
55
// connect destruction signal
56
connect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ), Qt::UniqueConnection );
61
//____________________________________________________________
62
bool MenuBarEngineV1::isAnimated( const QObject* object, const QPoint& position )
64
DataMap<MenuBarDataV1>::Value data( _data.find( object ) );
65
if( !data ) return false;
66
if( Animation::Pointer animation = data.data()->animation( position ) ) return animation.data()->isRunning();
70
//____________________________________________________________
71
BaseEngine::WidgetList MenuBarEngineV1::registeredWidgets( void ) const
76
// the typedef is needed to make Krazy happy
77
typedef DataMap<MenuBarDataV1>::Value Value;
78
foreach( const Value& value, _data )
79
{ if( value ) out.insert( value.data()->target().data() ); }
85
//____________________________________________________________
86
MenuBarEngineV2::MenuBarEngineV2( QObject* parent, MenuBarBaseEngine* other ):
87
MenuBarBaseEngine( parent ),
88
_followMouseDuration( 150 )
92
foreach( QWidget* widget, other->registeredWidgets() )
93
{ registerWidget( widget ); }
97
//____________________________________________________________
98
bool MenuBarEngineV2::registerWidget( QWidget* widget )
101
if( !widget ) return false;
103
// create new data class
104
if( !_data.contains( widget ) )
106
DataMap<MenuBarDataV2>::Value value( new MenuBarDataV2( this, widget, duration() ) );
107
value.data()->setFollowMouseDuration( followMouseDuration() );
108
_data.insert( widget, value, enabled() );
111
// connect destruction signal
112
connect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ), Qt::UniqueConnection );
118
//____________________________________________________________
119
bool MenuBarEngineV2::isAnimated( const QObject* object, const QPoint& )
121
if( !enabled() ) return false;
122
DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
123
if( !data ) return false;
124
if( data.data()->animation() && data.data()->animation().data()->isRunning() ) return true;
125
else if( Animation::Pointer animation = data.data()->progressAnimation() ) return animation.data()->isRunning();
130
//____________________________________________________________
131
QRect MenuBarEngineV2::currentRect( const QObject* object, const QPoint& )
133
if( !enabled() ) return QRect();
134
DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
135
return data ? data.data()->currentRect():QRect();
138
//____________________________________________________________
139
QRect MenuBarEngineV2::animatedRect( const QObject* object )
141
if( !enabled() ) return QRect();
142
DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
143
return data ? data.data()->animatedRect():QRect();
147
//____________________________________________________________
148
bool MenuBarEngineV2::isTimerActive( const QObject* object )
150
if( !enabled() ) return false;
151
DataMap<MenuBarDataV2>::Value data( _data.find( object ) );
152
return data ? data.data()->timer().isActive():false;
155
//____________________________________________________________
156
BaseEngine::WidgetList MenuBarEngineV2::registeredWidgets( void ) const
161
// the typedef is needed to make Krazy happy
162
typedef DataMap<MenuBarDataV2>::Value Value;
163
foreach( const Value& value, _data )
164
{ if( value ) out.insert( value.data()->target().data() ); }