provide the Animator::registerScrollingManager(qgraphicsidget) function.
the animator creates a kineticscroll and associates it with the widget. in this way we can use kineticscroll outside of libplasma with a single call. svn path=/trunk/KDE/kdelibs/; revision=1037751
This commit is contained in:
parent
89e73cecd2
commit
b2bb69732a
20
animator.h
20
animator.h
@ -27,6 +27,7 @@
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
class QGraphicsItem;
|
||||
class QGraphicsWidget;
|
||||
class QTimeLine;
|
||||
|
||||
namespace Plasma
|
||||
@ -159,6 +160,25 @@ public:
|
||||
*/
|
||||
KDE_DEPRECATED Q_INVOKABLE bool isAnimating() const;
|
||||
|
||||
/**
|
||||
* Register a widget as a scrolling widget.
|
||||
* The widget will get animate scrolling with mouse dragging and mouse wheel.
|
||||
* It must provide
|
||||
* scrollValue, viewportGeometry and pageSize properties
|
||||
*
|
||||
* @param widget the widget that offers a scrolling behaviour
|
||||
* @since 4.4
|
||||
*/
|
||||
void registerScrollingManager(QGraphicsWidget *widget);
|
||||
|
||||
/**
|
||||
* unregister the scrolling manager of a certain widget
|
||||
*
|
||||
* @param widget the widget we don't want no longer animated
|
||||
* @since 4.4
|
||||
*/
|
||||
void unregisterScrollingManager(QGraphicsWidget *widget);
|
||||
|
||||
Q_SIGNALS:
|
||||
void animationFinished(QGraphicsItem *item, Plasma::Animator::Animation anim);
|
||||
void movementFinished(QGraphicsItem *item);
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <kglobalsettings.h>
|
||||
|
||||
#include "animationdriver.h"
|
||||
#include "private/kineticscroll_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
@ -194,6 +195,8 @@ class AnimatorPrivateDeprecated
|
||||
QSet<MovementState *> movingItemsToDelete;
|
||||
QSet<ElementAnimationState *> animatedElementsToDelete;
|
||||
QSet<CustomAnimationState *> customAnimsToDelete;
|
||||
|
||||
QHash<QGraphicsWidget *, KineticScrolling *> scrollingManagers;
|
||||
};
|
||||
|
||||
class AnimatorSingleton
|
||||
@ -828,6 +831,22 @@ void AnimatorPrivateDeprecated::cleanupStates()
|
||||
customAnimsToDelete.clear();
|
||||
}
|
||||
|
||||
void Animator::registerScrollingManager(QGraphicsWidget *widget)
|
||||
{
|
||||
if (!d->scrollingManagers.contains(widget)) {
|
||||
KineticScrolling *scroll = new KineticScrolling(widget);
|
||||
d->scrollingManagers.insert(widget, scroll);
|
||||
}
|
||||
}
|
||||
|
||||
void Animator::unregisterScrollingManager(QGraphicsWidget *widget)
|
||||
{
|
||||
if (d->scrollingManagers.contains(widget)) {
|
||||
d->scrollingManagers.value(widget)->deleteLater();
|
||||
d->scrollingManagers.remove(widget);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Plasma
|
||||
|
||||
#include <../animator.moc>
|
||||
|
@ -126,9 +126,10 @@ public:
|
||||
};
|
||||
|
||||
|
||||
KineticScrolling::KineticScrolling(): d(0)
|
||||
KineticScrolling::KineticScrolling(QGraphicsWidget *parent)
|
||||
: d(new KineticScrollingPrivate)
|
||||
{
|
||||
d = new KineticScrollingPrivate;
|
||||
setWidget(parent);
|
||||
}
|
||||
|
||||
KineticScrolling::~KineticScrolling()
|
||||
@ -355,6 +356,8 @@ void KineticScrolling::setWidget(QGraphicsWidget *parent)
|
||||
d->parent->removeEventFilter(this);
|
||||
}
|
||||
|
||||
setParent(parent);
|
||||
|
||||
d->parent = parent;
|
||||
|
||||
if (parent) {
|
||||
|
@ -38,7 +38,7 @@ class KineticScrolling: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KineticScrolling();
|
||||
KineticScrolling(QGraphicsWidget *parent);
|
||||
~KineticScrolling();
|
||||
void setWidget(QGraphicsWidget *parent);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "scrollwidget.h"
|
||||
#include "private/kineticscroll_p.h"
|
||||
//Qt
|
||||
#include <QGraphicsSceneResizeEvent>
|
||||
#include <QGraphicsGridLayout>
|
||||
@ -39,7 +38,7 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class ScrollWidgetPrivate: public KineticScrolling
|
||||
class ScrollWidgetPrivate
|
||||
{
|
||||
public:
|
||||
ScrollWidgetPrivate(ScrollWidget *parent)
|
||||
@ -275,7 +274,7 @@ void ScrollWidget::setWidget(QGraphicsWidget *widget)
|
||||
}
|
||||
|
||||
d->widget = widget;
|
||||
d->setWidget(this);
|
||||
Plasma::Animator::self()->registerScrollingManager(this);
|
||||
widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
widget->setParentItem(d->scrollingWidget);
|
||||
widget->setPos(QPoint(0,0));
|
||||
|
@ -37,12 +37,12 @@
|
||||
|
||||
#include "plasma/widgets/webview.h"
|
||||
|
||||
#include "plasma/private/kineticscroll_p.h"
|
||||
#include "plasma/animator.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class WebViewPrivate : public KineticScrolling
|
||||
class WebViewPrivate
|
||||
{
|
||||
public:
|
||||
WebViewPrivate(WebView *parent)
|
||||
@ -69,7 +69,7 @@ WebView::WebView(QGraphicsItem *parent)
|
||||
{
|
||||
d->page = 0;
|
||||
d->loaded = false;
|
||||
d->setWidget(this);
|
||||
Plasma::Animator::self()->registerScrollingManager(this);
|
||||
setAcceptsHoverEvents(true);
|
||||
setFlags(QGraphicsItem::ItemIsFocusable);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user