diff --git a/widgets/boxlayout.cpp b/widgets/boxlayout.cpp index f9ac4edb5..f3d4378a9 100644 --- a/widgets/boxlayout.cpp +++ b/widgets/boxlayout.cpp @@ -438,12 +438,7 @@ void BoxLayout::setGeometry(const QRectF& geo) d->geometry = geometry; - if ( animator() && animator()->timeLine() ) { - animator()->timeLine()->setCurrentTime(0); - if ( animator()->timeLine()->state() == QTimeLine::NotRunning ) { - animator()->timeLine()->start(); - } - } + startAnimation(); } diff --git a/widgets/flowlayout.cpp b/widgets/flowlayout.cpp index efe56788d..25822a742 100644 --- a/widgets/flowlayout.cpp +++ b/widgets/flowlayout.cpp @@ -193,8 +193,7 @@ void FlowLayout::setGeometry(const QRectF& geo) d->geometry = geo; - if ( animator() && animator()->timeLine() ) - animator()->timeLine()->start(); + startAnimation(); } Qt::Orientations FlowLayout::expandingDirections() const diff --git a/widgets/layout.cpp b/widgets/layout.cpp index 4d94a43f6..a2892e701 100644 --- a/widgets/layout.cpp +++ b/widgets/layout.cpp @@ -21,9 +21,11 @@ #include #include +#include #include #include "widget.h" +#include "layoutanimator.h" namespace Plasma { @@ -146,5 +148,14 @@ QSizeF Layout::maximumSize() const { return QSizeF(INFINITY,INFINITY); } +void Layout::startAnimation() +{ + if ( animator() && animator()->timeLine() ) { + animator()->timeLine()->setCurrentTime(0); + if ( animator()->timeLine()->state() == QTimeLine::NotRunning ) { + animator()->timeLine()->start(); + } + } +} } diff --git a/widgets/layout.h b/widgets/layout.h index e3dad9108..c5a69ae78 100644 --- a/widgets/layout.h +++ b/widgets/layout.h @@ -152,6 +152,16 @@ class PLASMA_EXPORT Layout : public LayoutItem /** TODO Document me */ void invalidate(); + protected: + /** + * Starts a layout animation. Subclasses may call this + * at the end of their setGeometry() implementation to + * start the timeline associated with the layout's animator() + * if there is one. If an animation is already in progress then + * the timeline is reset to 0ms and the animation continues. + */ + void startAnimation(); + private: class Private; Private *const d;