diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index a956563a47..1e1ea478ef 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -811,15 +811,35 @@ namespace Oxygen if( titleAnimationData_.data()->isDirty() ) { - // contrast pixmap - titleAnimationData_.data()->setPixmaps( - rect, - renderTitleText( rect, caption(), color ), - renderTitleText( rect, caption(), contrast ) ); - + // clear dirty flags titleAnimationData_.data()->setDirty( false ); - titleAnimationData_.data()->startAnimation(); - renderTitleText( painter, rect, color, contrast ); + + // finish current animation if running + if( titleAnimationData_.data()->isAnimated() ) + { titleAnimationData_.data()->finishAnimation(); } + + if( !titleAnimationData_.data()->isLocked() ) + { + + // set pixmaps + titleAnimationData_.data()->setPixmaps( + rect, + renderTitleText( rect, caption(), color ), + renderTitleText( rect, caption(), contrast ) ); + + titleAnimationData_.data()->startAnimation(); + renderTitleText( painter, rect, color, contrast ); + + } else if( !caption().isEmpty() ) { + + renderTitleText( painter, rect, caption(), color, contrast ); + + } + + // lock animations (this must be done whether or not + // animation was actually started, in order to extend locking + // every time title get changed too rapidly + titleAnimationData_.data()->lockAnimations(); } else if( titleAnimationData_.data()->isAnimated() ) { diff --git a/clients/oxygen/oxygenconfiguration.cpp b/clients/oxygen/oxygenconfiguration.cpp index 0e0a2f61d4..2ca6a87bf2 100644 --- a/clients/oxygen/oxygenconfiguration.cpp +++ b/clients/oxygen/oxygenconfiguration.cpp @@ -42,7 +42,7 @@ namespace Oxygen hideTitleBar_( false ), useOxygenShadows_( true ), useAnimations_( true ), - animateTitleChange_( false ), + animateTitleChange_( true ), animationsDuration_( 150 ), tabsEnabled_( true ), useNarrowButtonSpacing_( false ) diff --git a/clients/oxygen/oxygentitleanimationdata.cpp b/clients/oxygen/oxygentitleanimationdata.cpp index 384e1e1db8..8aee8047a0 100644 --- a/clients/oxygen/oxygentitleanimationdata.cpp +++ b/clients/oxygen/oxygentitleanimationdata.cpp @@ -33,6 +33,9 @@ namespace Oxygen { + // use 300 milliseconds for animation lock + const int TitleAnimationData::lockTime_ = 300; + //_________________________________________________________ TitleAnimationData::TitleAnimationData( QObject* parent ): QObject( parent ), @@ -81,6 +84,25 @@ namespace Oxygen emit pixmapsChanged(); } + //_________________________________________________________ + void TitleAnimationData::timerEvent( QTimerEvent* e ) + { + + if( e->timerId() != animationLockTimer_.timerId() ) + { return QObject::timerEvent( e ); } + + // stop veto + animationLockTimer_.stop(); + + if( !isAnimated() ) + { + // triggers pixmap updates + reset(); + emit pixmapsChanged(); + } + + } + //_________________________________________________________ void TitleAnimationData::BlendedPixmap::blend( qreal opacity ) { diff --git a/clients/oxygen/oxygentitleanimationdata.h b/clients/oxygen/oxygentitleanimationdata.h index d51c9c53f4..1e9b49176b 100644 --- a/clients/oxygen/oxygentitleanimationdata.h +++ b/clients/oxygen/oxygentitleanimationdata.h @@ -33,8 +33,11 @@ #include #include #include +#include +#include #include + namespace Oxygen { @@ -94,16 +97,32 @@ namespace Oxygen //@{ + //! returns true if animations are locked + bool isLocked( void ) const + { return animationLockTimer_.isActive(); } + + //! returns true if title transition animation is currently running bool isAnimated( void ) const { return animation().data()->isRunning(); } - //! start animation + //! start lock animation timer + void lockAnimations( void ) + { animationLockTimer_.start( lockTime_, this ); } + + //! start title transition animation void startAnimation( void ) { assert( !isAnimated() ); animation().data()->start(); } + //! finish title transition animation + void finishAnimation( void ) + { + assert( isAnimated() ); + animation().data()->stop(); + } + //@} //!@name opacity @@ -140,6 +159,9 @@ namespace Oxygen protected: + //! timer event + void timerEvent( QTimerEvent* ); + //! animation object const Animation::Pointer& animation( void ) const { return animation_; } @@ -212,6 +234,12 @@ namespace Oxygen BlendedPixmap contrastPixmap_; BlendedPixmap pixmap_; + //! lock time (milliseconds + static const int lockTime_; + + //! timer used to disable animations when triggered too early + QBasicTimer animationLockTimer_; + //! title animation Animation::Pointer animation_;