a new property: snapSize if one wants to always make the scroll end aligned to a certain grid (is a size, so snap can be different horizontal and vertical)
svn path=/trunk/KDE/kdelibs/; revision=1116100
This commit is contained in:
parent
ee661f4347
commit
dfb46bb03e
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "scrollwidget.h"
|
#include "scrollwidget.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
#include <QGraphicsSceneResizeEvent>
|
#include <QGraphicsSceneResizeEvent>
|
||||||
#include <QGraphicsGridLayout>
|
#include <QGraphicsGridLayout>
|
||||||
@ -443,6 +446,20 @@ public:
|
|||||||
QObject *obj = start->targetObject();
|
QObject *obj = start->targetObject();
|
||||||
obj->setProperty(start->propertyName(), maxExtent);
|
obj->setProperty(start->propertyName(), maxExtent);
|
||||||
}
|
}
|
||||||
|
} else if (group == fixupAnimation.groupX && snapSize.width() > 1 &&
|
||||||
|
q->contentsSize().width() > q->viewportGeometry().width()) {
|
||||||
|
int target = snapSize.width() * round(val/snapSize.width());
|
||||||
|
end->setStartValue(val);
|
||||||
|
end->setEndValue(target);
|
||||||
|
end->setDuration(FixupDuration);
|
||||||
|
end->start();
|
||||||
|
} else if (group == fixupAnimation.groupY && snapSize.height() > 1 &&
|
||||||
|
q->contentsSize().height() > q->viewportGeometry().height()) {
|
||||||
|
int target = snapSize.height() * round(val/snapSize.height());
|
||||||
|
end->setStartValue(val);
|
||||||
|
end->setEndValue(target);
|
||||||
|
end->setDuration(FixupDuration);
|
||||||
|
end->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void fixupX()
|
void fixupX()
|
||||||
@ -954,6 +971,7 @@ public:
|
|||||||
QPropertyAnimation *endY;
|
QPropertyAnimation *endY;
|
||||||
} fixupAnimation;
|
} fixupAnimation;
|
||||||
QPropertyAnimation *directMoveAnimation;
|
QPropertyAnimation *directMoveAnimation;
|
||||||
|
QSizeF snapSize;
|
||||||
bool stealEvent;
|
bool stealEvent;
|
||||||
bool hasOvershoot;
|
bool hasOvershoot;
|
||||||
|
|
||||||
@ -1134,6 +1152,16 @@ QPointF ScrollWidget::scrollPosition() const
|
|||||||
return QPointF();
|
return QPointF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScrollWidget::setSnapSize(const QSizeF &size)
|
||||||
|
{
|
||||||
|
d->snapSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSizeF ScrollWidget::snapSize() const
|
||||||
|
{
|
||||||
|
return d->snapSize;
|
||||||
|
}
|
||||||
|
|
||||||
void ScrollWidget::setStyleSheet(const QString &styleSheet)
|
void ScrollWidget::setStyleSheet(const QString &styleSheet)
|
||||||
{
|
{
|
||||||
d->styleSheet = styleSheet;
|
d->styleSheet = styleSheet;
|
||||||
|
@ -49,6 +49,7 @@ class PLASMA_EXPORT ScrollWidget : public QGraphicsWidget
|
|||||||
Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition)
|
Q_PROPERTY(QPointF scrollPosition READ scrollPosition WRITE setScrollPosition)
|
||||||
Q_PROPERTY(QSizeF contentsSize READ contentsSize)
|
Q_PROPERTY(QSizeF contentsSize READ contentsSize)
|
||||||
Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
|
Q_PROPERTY(QRectF viewportGeometry READ viewportGeometry)
|
||||||
|
Q_PROPERTY(QSizeF snapSize READ snapSize WRITE setSnapSize)
|
||||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||||
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
|
Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
|
||||||
Q_PROPERTY(bool overShoot READ hasOverShoot WRITE setOverShoot)
|
Q_PROPERTY(bool overShoot READ hasOverShoot WRITE setOverShoot)
|
||||||
@ -200,6 +201,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
QPointF scrollPosition() const;
|
QPointF scrollPosition() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the nap size of the kinetic scrolling:
|
||||||
|
* the scrolling will always stop at multiples of that size.
|
||||||
|
*
|
||||||
|
* @arg the desired snap size
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
void setSnapSize(const QSizeF &size);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the snap size of the kinetic scrolling
|
||||||
|
* @since 4.5
|
||||||
|
*/
|
||||||
|
QSizeF snapSize() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the stylesheet used to control the visual display of this ScrollWidget
|
* Sets the stylesheet used to control the visual display of this ScrollWidget
|
||||||
|
Loading…
x
Reference in New Issue
Block a user