1
// krazy:excludeall=qclasses
3
//////////////////////////////////////////////////////////////////////////////
4
// oxygentransitions.cpp
5
// container for all transition engines
8
// Copyright (c) 2009 Hugo Pereira Da Costa <hugo.pereira@free.fr>
10
// Permission is hereby granted, free of charge, to any person obtaining a copy
11
// of this software and associated documentation files (the "Software"), to
12
// deal in the Software without restriction, including without limitation the
13
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
14
// sell copies of the Software, and to permit persons to whom the Software is
15
// furnished to do so, subject to the following conditions:
17
// The above copyright notice and this permission notice shall be included in
18
// all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
27
//////////////////////////////////////////////////////////////////////////////
29
#include "oxygentransitions.h"
30
#include "oxygentransitions.moc"
31
#include "oxygenpropertynames.h"
32
#include "oxygenstyleconfigdata.h"
37
//________________________________________________________--
38
Transitions::Transitions( QObject* parent ):
42
registerEngine( _comboBoxEngine = new ComboBoxEngine( this ) );
43
registerEngine( _labelEngine = new LabelEngine( this ) );
44
registerEngine( _lineEditEngine = new LineEditEngine( this ) );
45
registerEngine( _stackedWidgetEngine = new StackedWidgetEngine( this ) );
49
//________________________________________________________--
50
void Transitions::setupEngines( void )
54
TransitionWidget::setSteps( StyleConfigData::animationSteps() );
56
// default enability, duration and maxFrame
57
bool animationsEnabled( StyleConfigData::animationsEnabled() );
60
comboBoxEngine().setEnabled( animationsEnabled && StyleConfigData::comboBoxTransitionsEnabled() );
61
labelEngine().setEnabled( animationsEnabled && StyleConfigData::labelTransitionsEnabled() );
62
lineEditEngine().setEnabled( animationsEnabled && StyleConfigData::lineEditTransitionsEnabled() );
63
stackedWidgetEngine().setEnabled( animationsEnabled && StyleConfigData::stackedWidgetTransitionsEnabled() );
66
comboBoxEngine().setDuration( StyleConfigData::comboBoxTransitionsDuration() );
67
labelEngine().setDuration( StyleConfigData::labelTransitionsDuration() );
68
lineEditEngine().setDuration( StyleConfigData::lineEditTransitionsDuration() );
69
stackedWidgetEngine().setDuration( StyleConfigData::stackedWidgetTransitionsDuration() );
73
//____________________________________________________________
74
void Transitions::registerWidget( QWidget* widget ) const
79
// check against noAnimations propery
80
QVariant propertyValue( widget->property( PropertyNames::noAnimations ) );
81
if( propertyValue.isValid() && propertyValue.toBool() ) return;
84
if( QLabel* label = qobject_cast<QLabel*>( widget ) ) {
86
// do not animate labels from tooltips
87
if( widget->window() && widget->window()->windowFlags().testFlag( Qt::ToolTip ) ) return;
88
else if( widget->window() && widget->window()->inherits( "KWin::GeometryTip" ) ) return;
89
else labelEngine().registerWidget( label );
91
} else if( QComboBox* comboBox = qobject_cast<QComboBox*>( widget ) ) {
93
comboBoxEngine().registerWidget( comboBox );
95
} else if( QLineEdit* lineEdit = qobject_cast<QLineEdit*>( widget ) ) {
97
lineEditEngine().registerWidget( lineEdit );
99
} else if( QStackedWidget* stack = qobject_cast<QStackedWidget*>( widget ) ) {
101
stackedWidgetEngine().registerWidget( stack );
107
//____________________________________________________________
108
void Transitions::unregisterWidget( QWidget* widget ) const
111
if( !widget ) return;
113
// the following allows some optimization of widget unregistration
114
// it assumes that a widget can be registered atmost in one of the
115
// engines stored in the list.
116
foreach( const BaseEngine::Pointer& engine, _engines )
117
{ if( engine && engine.data()->unregisterWidget( widget ) ) break; }