| 1 | #include "customScrollContainer.h" |
| 2 | |
| 3 | ScrollAreaCustom::ScrollAreaCustom(QWidget *parent) : QWidget(parent) |
| 4 | { |
| 5 | //initialize list container and timer |
| 6 | container = new ScrollListContainer(this); |
| 7 | container->move(0, 0); |
| 8 | container->resize(this->width(), 3); |
| 9 | getCord = new QTimer; |
| 10 | getCord->setSingleShot(true); |
| 11 | rfrshView = new QTimer; |
| 12 | getCord->setSingleShot(true); |
| 13 | |
| 14 | indicator = new ScrollIndicator(this); |
| 15 | indicator->resize(indicator->width(), (int)((double)this->height() * this->height() / (double)container->height())); |
| 16 | indicator->move(this->width() - indicator->width() - 3, 0); |
| 17 | |
| 18 | this->setMouseTracking(true); |
| 19 | container->setMouseTracking(true); |
| 20 | indicator->setMouseTracking(true); |
| 21 | |
| 22 | bounce = new QPropertyAnimation(container, "pos"); |
| 23 | |
| 24 | QObject::connect(getCord, SIGNAL(timeout()), this, SLOT(updateSpd())); |
| 25 | QObject::connect(rfrshView, SIGNAL(timeout()), this, SLOT(scrollContainer())); |
| 26 | QObject::connect(indicator, SIGNAL(scrollPage(int)), this, SLOT(scrollIndicator(int))); |
| 27 | } |
| 28 | |
| 29 | void ScrollAreaCustom::paintEvent(QPaintEvent *event){ |
| 30 | container->resize(this->width(), container->height()); |