MCPcopy Create free account
hub / github.com/Liniyous/ElaWidgetTools / ElaScrollBar

Function ElaScrollBar

ElaWidgetTools/ElaScrollBar.cpp:15–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include <QTimer>
14#include <QWheelEvent>
15
16ELA_PROPERTY_Q_CPP(ElaScrollBar, bool, IsAnimation)
17ELA_PROPERTY_Q_CPP(ElaScrollBar, qreal, SpeedLimit)
18ElaScrollBar::ElaScrollBar(QWidget* parent)
19 : QScrollBar(parent), d_ptr(new ElaScrollBarPrivate())
20{
21 Q_D(ElaScrollBar);
22 d->q_ptr = this;
23 setSingleStep(1);
24 setObjectName("ElaScrollBar");
25 setAttribute(Qt::WA_OpaquePaintEvent, false);
26 d->_pSpeedLimit = 20;
27 d->_pTargetMaximum = 0;
28 d->_pIsAnimation = false;
29 d->_scrollAnimation = new ElaScrollAnimation(this);
30 connect(this, &ElaScrollBar::rangeChanged, d, &ElaScrollBarPrivate::onRangeChanged);
31 ElaScrollBarStyle* scrollBarStyle = new ElaScrollBarStyle(style());
32 d->_scrollBarStyle = scrollBarStyle;
33 scrollBarStyle->setParent(this);
34 scrollBarStyle->setScrollBar(this);
35 setStyle(scrollBarStyle);
36 connect(d->_scrollAnimation, &ElaScrollAnimation::positionChanged, this, [this, d](const QPointF& position) {
37 const QScopedValueRollback<bool> updating(d->_isUpdatingScroll, true);
38 setValue(qRound(position.x() / d->_scrollScale));
39 });
40 connect(this, &QScrollBar::valueChanged, this, [d]() {
41 if (!d->_isUpdatingScroll)
42 {
43 d->_scrollAnimation->stop();
44 d->_pixelRemainder = 0;
45 }
46 });

Callers

nothing calls this directly

Calls 1

startExpandAnimationMethod · 0.80

Tested by

no test coverage detected