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

« back to all changes in this revision

Viewing changes to libs/oxygen/oxygenshadowconfiguration.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 oxygenshadowconfiguration_h
 
2
#define oxygenshadowconfiguration_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygenshadowconfiguration.h
 
6
// shadow configuration
 
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 "oxygen_export.h"
 
31
 
 
32
#include <KConfigGroup>
 
33
#include <QtGui/QPalette>
 
34
 
 
35
namespace OxygenConfig
 
36
{
 
37
 
 
38
    static const QString SHADOW_SIZE = "Size";
 
39
    static const QString SHADOW_HOFFSET= "HorizontalOffset";
 
40
    static const QString SHADOW_VOFFSET= "VerticalOffset";
 
41
    static const QString SHADOW_INNER_COLOR = "InnerColor";
 
42
    static const QString SHADOW_OUTER_COLOR = "OuterColor";
 
43
    static const QString SHADOW_USE_OUTER_COLOR = "UseOuterColor";
 
44
 
 
45
    static const QString ANIMATIONS_DURATION = "AnimationsDuration";
 
46
    static const QString SHADOW_CACHE_MODE = "ShadowCacheMode";
 
47
 
 
48
    static const QString USE_DROP_SHADOWS = "UseDropShadows";
 
49
    static const QString USE_OXYGEN_SHADOWS = "UseOxygenShadows";
 
50
 
 
51
}
 
52
 
 
53
namespace Oxygen
 
54
{
 
55
 
 
56
    class OXYGEN_EXPORT ShadowConfiguration
 
57
    {
 
58
 
 
59
        public:
 
60
 
 
61
        //! button size enumeration
 
62
        //! default constructor
 
63
        ShadowConfiguration( QPalette::ColorGroup );
 
64
 
 
65
        //! constructor from KConfig
 
66
        ShadowConfiguration( QPalette::ColorGroup, const KConfigGroup& );
 
67
 
 
68
        //! destructor
 
69
        virtual ~ShadowConfiguration( void )
 
70
        {}
 
71
 
 
72
        //! write to kconfig group
 
73
        virtual void write( KConfigGroup& ) const;
 
74
 
 
75
        //! color group
 
76
        QPalette::ColorGroup colorGroup( void ) const
 
77
        { return _colorGroup; }
 
78
 
 
79
        //! enability
 
80
        void setEnabled( bool value )
 
81
        { _enabled = value; }
 
82
 
 
83
        //! enability
 
84
        bool isEnabled( void ) const
 
85
        { return _enabled; }
 
86
 
 
87
        //! shadow size
 
88
        qreal shadowSize( void ) const
 
89
        { return _shadowSize; }
 
90
 
 
91
        //! shadow size
 
92
        void setShadowSize( qreal value )
 
93
        { _shadowSize = value; }
 
94
 
 
95
        //! horizontal offset
 
96
        qreal horizontalOffset( void ) const
 
97
        { return _horizontalOffset; }
 
98
 
 
99
        //! horizontal offset
 
100
        void setHorizontalOffset( qreal value )
 
101
        { _horizontalOffset = value; }
 
102
 
 
103
        //! vertical offset
 
104
        qreal verticalOffset( void ) const
 
105
        { return _verticalOffset; }
 
106
 
 
107
        //! vertical offset
 
108
        void setVerticalOffset( qreal value )
 
109
        { _verticalOffset = value; }
 
110
 
 
111
        //! inner color
 
112
        QColor innerColor( void ) const
 
113
        { return _innerColor; }
 
114
 
 
115
        //! inner color
 
116
        void setInnerColor( QColor );
 
117
 
 
118
        //! mid color
 
119
        QColor midColor( void ) const
 
120
        { return _midColor; }
 
121
 
 
122
        //! outer color
 
123
        QColor outerColor( void ) const
 
124
        { return useOuterColor() ? _outerColor : _outerColor2; }
 
125
 
 
126
        //! outer color
 
127
        void setOuterColor( QColor );
 
128
 
 
129
        //! use outer color
 
130
        bool useOuterColor( void ) const
 
131
        { return _useOuterColor; }
 
132
 
 
133
        //! use outer color
 
134
        void setUseOuterColor( bool value )
 
135
        { _useOuterColor = value; }
 
136
 
 
137
        //! equal to operator
 
138
        bool operator == (const ShadowConfiguration& other ) const
 
139
        {
 
140
            return
 
141
                _colorGroup == other._colorGroup &&
 
142
                _enabled == other._enabled &&
 
143
                _shadowSize == other._shadowSize &&
 
144
                _horizontalOffset == other._horizontalOffset &&
 
145
                _verticalOffset == other._verticalOffset &&
 
146
                _innerColor == other._innerColor &&
 
147
                ( _useOuterColor == false || _outerColor == other._outerColor ) &&
 
148
                _useOuterColor == other._useOuterColor;
 
149
        }
 
150
 
 
151
        protected:
 
152
 
 
153
        //! mid color
 
154
        void setMidColor( QColor );
 
155
 
 
156
        //! calculated outer color
 
157
        QColor outerColor2( void ) const
 
158
        { return _outerColor2; }
 
159
 
 
160
        //! calculated outer color
 
161
        void setOuterColor2( QColor );
 
162
 
 
163
        //! calculate mid color
 
164
        QColor calcMidColor( void ) const;
 
165
 
 
166
        //! calculate outer color
 
167
        QColor calcOuterColor( void ) const;
 
168
 
 
169
        private:
 
170
 
 
171
        //! color group
 
172
        QPalette::ColorGroup _colorGroup;
 
173
 
 
174
        //! enability
 
175
        bool _enabled;
 
176
 
 
177
        //! shadow size
 
178
        qreal _shadowSize;
 
179
 
 
180
        //! horizontal offset
 
181
        qreal _horizontalOffset;
 
182
 
 
183
        //! vertical offset
 
184
        qreal _verticalOffset;
 
185
 
 
186
        //! inner color
 
187
        QColor _innerColor;
 
188
 
 
189
        //! mid color
 
190
        QColor _midColor;
 
191
 
 
192
        //! outer color
 
193
        QColor _outerColor;
 
194
 
 
195
        //! calculated outer color
 
196
        QColor _outerColor2;
 
197
 
 
198
        //! use outer color
 
199
        bool _useOuterColor;
 
200
 
 
201
    };
 
202
 
 
203
}
 
204
 
 
205
#endif