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

« back to all changes in this revision

Viewing changes to kstyles/oxygen/config/oxygenanimationconfigitem.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 oxygenanimationconfigitem_h
 
2
#define oxygenanimationconfigitem_h
 
3
 
 
4
//////////////////////////////////////////////////////////////////////////////
 
5
// oxygenanimationconfigitem.h
 
6
// animation configuration item
 
7
// -------------------
 
8
//
 
9
// Copyright (c) 2010 Hugo Pereira Da Costa <hugo@oxygen-icons.org>
 
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 <QtCore/QString>
 
31
#include <QtCore/QWeakPointer>
 
32
 
 
33
#include <cassert>
 
34
 
 
35
#include "ui_oxygenanimationconfigitem.h"
 
36
#include "ui_oxygenfollowmouseanimationconfigbox.h"
 
37
#include "ui_oxygengenericanimationconfigbox.h"
 
38
 
 
39
namespace Oxygen
 
40
{
 
41
 
 
42
    class GenericAnimationConfigBox: public QFrame
 
43
    {
 
44
 
 
45
        Q_OBJECT
 
46
 
 
47
        public:
 
48
 
 
49
        //! constructor
 
50
        GenericAnimationConfigBox(QWidget* parent):
 
51
        QFrame( parent )
 
52
        { ui.setupUi( this ); }
 
53
 
 
54
        //! duration spin box
 
55
        QSpinBox* durationSpinBox( void ) const
 
56
        { return ui.durationSpinBox; }
 
57
 
 
58
        private:
 
59
 
 
60
        Ui_GenericAnimationConfigBox ui;
 
61
 
 
62
    };
 
63
 
 
64
    class FollowMouseAnimationConfigBox: public QFrame
 
65
    {
 
66
        Q_OBJECT
 
67
 
 
68
        public:
 
69
 
 
70
        //! constructor
 
71
        FollowMouseAnimationConfigBox(QWidget* parent):
 
72
        QFrame( parent )
 
73
        {
 
74
            ui.setupUi( this );
 
75
            ui.followMouseDurationSpinBox->setEnabled( false );
 
76
            connect( ui.typeComboBox, SIGNAL( currentIndexChanged( int ) ), SLOT( typeChanged( int ) ) );
 
77
        }
 
78
 
 
79
        //! type ComboBox
 
80
        KComboBox* typeComboBox( void ) const
 
81
        { return ui.typeComboBox; }
 
82
 
 
83
        //! duration spin box
 
84
        QSpinBox* durationSpinBox( void ) const
 
85
        { return ui.durationSpinBox; }
 
86
 
 
87
        //! duration spin box
 
88
        QLabel* durationLabel( void ) const
 
89
        { return ui.durationLabel; }
 
90
 
 
91
        //! follow mouse duration spinbox
 
92
        QSpinBox* followMouseDurationSpinBox( void ) const
 
93
        { return ui.followMouseDurationSpinBox; }
 
94
 
 
95
        protected slots:
 
96
 
 
97
        //! type changed
 
98
        void typeChanged( int value )
 
99
        {
 
100
            ui.followMouseDurationLabel->setEnabled( value == 1 );
 
101
            ui.followMouseDurationSpinBox->setEnabled( value == 1 );
 
102
        }
 
103
 
 
104
        private:
 
105
 
 
106
        Ui_FollowMouseAnimationConfigBox ui;
 
107
 
 
108
    };
 
109
 
 
110
    class AnimationConfigItem: public QWidget
 
111
    {
 
112
 
 
113
        Q_OBJECT
 
114
 
 
115
        public:
 
116
 
 
117
        //! constructor
 
118
        explicit AnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() );
 
119
 
 
120
        //! title
 
121
        virtual void setTitle( const QString& value )
 
122
        { ui.enableCheckBox->setText( value ); }
 
123
 
 
124
        //! title
 
125
        virtual QString title( void ) const
 
126
        { return ui.enableCheckBox->text(); }
 
127
 
 
128
        //! description
 
129
        virtual void setDescription( const QString& value )
 
130
        {
 
131
            _description = value;
 
132
            ui.descriptionButton->setEnabled( !_description.isEmpty() );
 
133
        }
 
134
 
 
135
        //! description
 
136
        virtual const QString& description( void ) const
 
137
        { return _description; }
 
138
 
 
139
        //! enability
 
140
        virtual void setEnabled( const bool& value )
 
141
        { ui.enableCheckBox->setChecked( value ); }
 
142
 
 
143
        //! enability
 
144
        virtual bool enabled( void ) const
 
145
        { return ui.enableCheckBox->isChecked(); }
 
146
 
 
147
        //! config widget
 
148
        virtual QWidget* configurationWidget( void ) const = 0;
 
149
 
 
150
        //! initialize config widget
 
151
        virtual void initializeConfigurationWidget( QWidget* ) = 0;
 
152
 
 
153
        //! configuration button
 
154
        KPushButton* configurationButton( void ) const
 
155
        { return ui.configurationButton; }
 
156
 
 
157
        signals:
 
158
 
 
159
        //! emmited when changed
 
160
        void changed( void );
 
161
 
 
162
        protected slots:
 
163
 
 
164
        //! about info
 
165
        virtual void about( void );
 
166
 
 
167
        protected:
 
168
 
 
169
        //! set configuration widget
 
170
        virtual void setConfigurationWidget( QWidget* widget );
 
171
 
 
172
        private:
 
173
 
 
174
        //! description
 
175
        QString _description;
 
176
 
 
177
        //! ui
 
178
        Ui_AnimationConfigItem ui;
 
179
 
 
180
    };
 
181
 
 
182
    //! generic animation config item
 
183
    class GenericAnimationConfigItem: public AnimationConfigItem
 
184
    {
 
185
 
 
186
        Q_OBJECT
 
187
 
 
188
        public:
 
189
 
 
190
        //! constructor
 
191
        explicit GenericAnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() ):
 
192
            AnimationConfigItem( parent, title, description )
 
193
        {}
 
194
 
 
195
        //! configure
 
196
        virtual void initializeConfigurationWidget( QWidget* );
 
197
 
 
198
        //! configuration widget
 
199
        virtual QWidget* configurationWidget( void ) const
 
200
        {
 
201
            assert( _configurationWidget );
 
202
            return _configurationWidget.data();
 
203
        }
 
204
 
 
205
        //! duration
 
206
        virtual int duration( void ) const
 
207
        { return (_configurationWidget) ? _configurationWidget.data()->durationSpinBox()->value():0; }
 
208
 
 
209
        public slots:
 
210
 
 
211
        //! duration
 
212
        virtual void setDuration( int value )
 
213
        {
 
214
            if( _configurationWidget )
 
215
            { _configurationWidget.data()->durationSpinBox()->setValue( value ); }
 
216
        }
 
217
 
 
218
        private:
 
219
 
 
220
        //! configuration widget
 
221
        QWeakPointer<GenericAnimationConfigBox> _configurationWidget;
 
222
 
 
223
    };
 
224
 
 
225
    //! generic animation config item
 
226
    class FollowMouseAnimationConfigItem: public AnimationConfigItem
 
227
    {
 
228
 
 
229
        Q_OBJECT
 
230
 
 
231
        public:
 
232
 
 
233
        //! constructor
 
234
        explicit FollowMouseAnimationConfigItem( QWidget* parent, const QString& title = QString(), const QString& description = QString() ):
 
235
            AnimationConfigItem( parent, title, description )
 
236
        {}
 
237
 
 
238
        //! initialize configuration widget
 
239
        virtual void initializeConfigurationWidget( QWidget* );
 
240
 
 
241
        //! configuration widget
 
242
        virtual QWidget* configurationWidget( void ) const
 
243
        {
 
244
            assert( _configurationWidget );
 
245
            return _configurationWidget.data();
 
246
        }
 
247
 
 
248
        //! type
 
249
        virtual int type( void ) const
 
250
        { return (_configurationWidget) ? _configurationWidget.data()->typeComboBox()->currentIndex():0; }
 
251
 
 
252
        //! duration
 
253
        virtual int duration( void ) const
 
254
        { return (_configurationWidget) ? _configurationWidget.data()->durationSpinBox()->value():0; }
 
255
 
 
256
        //! duration
 
257
        virtual int followMouseDuration( void ) const
 
258
        { return (_configurationWidget) ? _configurationWidget.data()->followMouseDurationSpinBox()->value():0; }
 
259
 
 
260
        //! hide duration spinbox
 
261
        virtual void hideDurationSpinBox( void )
 
262
        {
 
263
            if( _configurationWidget )
 
264
            {
 
265
                _configurationWidget.data()->durationLabel()->hide();
 
266
                _configurationWidget.data()->durationSpinBox()->hide();
 
267
            }
 
268
        }
 
269
 
 
270
        public slots:
 
271
 
 
272
        //! type
 
273
        virtual void setType( int value )
 
274
        {
 
275
            if( _configurationWidget )
 
276
            { _configurationWidget.data()->typeComboBox()->setCurrentIndex( value ); }
 
277
        }
 
278
 
 
279
        //! duration
 
280
        virtual void setDuration( int value )
 
281
        {
 
282
            if( _configurationWidget )
 
283
            { _configurationWidget.data()->durationSpinBox()->setValue( value ); }
 
284
        }
 
285
 
 
286
        //! follow mouse duration
 
287
        virtual void setFollowMouseDuration( int value )
 
288
        {
 
289
            if( _configurationWidget )
 
290
            { _configurationWidget.data()->followMouseDurationSpinBox()->setValue( value ); }
 
291
        }
 
292
 
 
293
        private:
 
294
 
 
295
        //! configuration widget
 
296
        QWeakPointer<FollowMouseAnimationConfigBox> _configurationWidget;
 
297
 
 
298
    };
 
299
 
 
300
}
 
301
 
 
302
#endif