~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to kstyles/oxygen/animations/oxygentoolbarengine.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//////////////////////////////////////////////////////////////////////////////
 
2
// oxygentoolbarengine.cpp
 
3
// stores event filters and maps widgets to timelines for animations
 
4
// -------------------
 
5
//
 
6
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
 
7
//
 
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:
 
14
//
 
15
// The above copyright notice and this permission notice shall be included in
 
16
// all copies or substantial portions of the Software.
 
17
//
 
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
 
24
// IN THE SOFTWARE.
 
25
//////////////////////////////////////////////////////////////////////////////
 
26
 
 
27
#include "oxygentoolbarengine.h"
 
28
#include "oxygentoolbarengine.moc"
 
29
 
 
30
#include <QtCore/QEvent>
 
31
 
 
32
namespace Oxygen
 
33
{
 
34
 
 
35
    //____________________________________________________________
 
36
    void ToolBarEngine::registerWidget( QWidget* widget )
 
37
    {
 
38
 
 
39
        if( !widget ) return;
 
40
 
 
41
        // create new data class
 
42
        if( !_data.contains( widget ) )
 
43
        {
 
44
            DataMap<ToolBarData>::Value value( new ToolBarData( this, widget, duration() ) );
 
45
            value.data()->setFollowMouseDuration( followMouseDuration() );
 
46
            _data.insert( widget, value, enabled() );
 
47
        }
 
48
 
 
49
        // connect destruction signal
 
50
        disconnect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ) );
 
51
        connect( widget, SIGNAL( destroyed( QObject* ) ), this, SLOT( unregisterWidget( QObject* ) ) );
 
52
 
 
53
    }
 
54
 
 
55
    //____________________________________________________________
 
56
    BaseEngine::WidgetList ToolBarEngine::registeredWidgets( void ) const
 
57
    {
 
58
        WidgetList out;
 
59
 
 
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() ); }
 
64
        return out;
 
65
    }
 
66
 
 
67
    //____________________________________________________________
 
68
    bool ToolBarEngine::isAnimated( const QObject* object )
 
69
    {
 
70
        if( !enabled() ) return false;
 
71
 
 
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();
 
75
        else return false;
 
76
    }
 
77
 
 
78
    //____________________________________________________________
 
79
    bool ToolBarEngine::isFollowMouseAnimated( const QObject* object )
 
80
    {
 
81
        if( !enabled() ) return false;
 
82
 
 
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();
 
86
        else return false;
 
87
    }
 
88
 
 
89
    //____________________________________________________________
 
90
    QRect ToolBarEngine::currentRect( const QObject* object )
 
91
    {
 
92
        if( !enabled() ) return QRect();
 
93
        DataMap<ToolBarData>::Value data( _data.find( object ) );
 
94
        return data ? data.data()->currentRect():QRect();
 
95
    }
 
96
 
 
97
    //____________________________________________________________
 
98
    QRect ToolBarEngine::animatedRect( const QObject* object )
 
99
    {
 
100
        if( !enabled() ) return QRect();
 
101
        DataMap<ToolBarData>::Value data( _data.find( object ) );
 
102
        return data ? data.data()->animatedRect():QRect();
 
103
    }
 
104
 
 
105
    //____________________________________________________________
 
106
    bool ToolBarEngine::isTimerActive( const QObject* object )
 
107
    {
 
108
        if( !enabled() ) return false;
 
109
        DataMap<ToolBarData>::Value data( _data.find( object ) );
 
110
        return data ? data.data()->timer().isActive():false;
 
111
    }
 
112
 
 
113
}