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

« back to all changes in this revision

Viewing changes to kstyles/oxygen/animations/oxygensliderengine.h

  • 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
#ifndef oxygensliderengine_h
 
2
#define oxygensliderengine_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygensliderengine.h
 
6
// stores event filters and maps widgets to timelines for animations
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
 
10
//
 
11
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
12
// of this software and associated documentation files (the "Software"), to
 
13
// deal in the Software without restriction, including without limitation the
 
14
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 
15
// sell copies of the Software, and to permit persons to whom the Software is
 
16
// furnished to do so, subject to the following conditions:
 
17
//
 
18
// The above copyright notice and this permission notice shall be included in
 
19
// all copies or substantial portions of the Software.
 
20
//
 
21
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
22
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
23
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
24
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
25
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
26
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 
27
// IN THE SOFTWARE.
 
28
//////////////////////////////////////////////////////////////////////////////
 
29
 
 
30
#include "oxygenbaseengine.h"
 
31
#include "oxygendatamap.h"
 
32
#include "oxygensliderdata.h"
 
33
 
 
34
namespace Oxygen
 
35
{
 
36
 
 
37
    //! stores slider hovered action and timeLine
 
38
    class SliderEngine: public BaseEngine
 
39
    {
 
40
 
 
41
        Q_OBJECT
 
42
 
 
43
        public:
 
44
 
 
45
        //! constructor
 
46
        SliderEngine( QObject* parent ):
 
47
        BaseEngine( parent )
 
48
        {}
 
49
 
 
50
        //! destructor
 
51
        virtual ~SliderEngine( void )
 
52
        {}
 
53
 
 
54
        //! register slider
 
55
        virtual bool registerWidget( QWidget* );
 
56
 
 
57
        //! true if widget is animated
 
58
        virtual bool isAnimated( const QObject* object )
 
59
        {
 
60
            if( DataMap<SliderData>::Value data = _data.find( object ) )
 
61
            {
 
62
 
 
63
                return data.data()->animation().data()->isRunning();
 
64
 
 
65
            } else return false;
 
66
 
 
67
        }
 
68
 
 
69
        //! update state
 
70
        virtual bool updateState( const QObject* object, bool state )
 
71
        {
 
72
 
 
73
            if( DataMap<SliderData>::Value data = _data.find( object ) )
 
74
            {
 
75
 
 
76
                return data.data()->updateState( state );
 
77
 
 
78
            } else return false;
 
79
 
 
80
        }
 
81
 
 
82
        //! animation opacity
 
83
        virtual qreal opacity( const QObject* object )
 
84
        { return isAnimated( object ) ? _data.find( object ).data()->opacity() : AnimationData::OpacityInvalid; }
 
85
 
 
86
        //! enability
 
87
        virtual void setEnabled( bool value )
 
88
        {
 
89
            BaseEngine::setEnabled( value );
 
90
            _data.setEnabled( value );
 
91
        }
 
92
 
 
93
        //! duration
 
94
        virtual void setDuration( int value )
 
95
        {
 
96
            BaseEngine::setDuration( value );
 
97
            _data.setDuration( value );
 
98
        }
 
99
 
 
100
        public slots:
 
101
 
 
102
        //! remove widget from map
 
103
        virtual bool unregisterWidget( QObject* object )
 
104
        { return _data.unregisterWidget( object ); }
 
105
 
 
106
        private:
 
107
 
 
108
        //! data map
 
109
        DataMap<SliderData> _data;
 
110
 
 
111
    };
 
112
 
 
113
}
 
114
 
 
115
#endif