Changeset View
Changeset View
Standalone View
Standalone View
lib/thumbnailview/thumbnailbarview.cpp
Context not available. | |||||
49 | namespace Gwenview | 49 | namespace Gwenview | ||
---|---|---|---|---|---|
50 | { | 50 | { | ||
51 | 51 | | |||
52 | /** | | |||
53 | * Duration in ms of the smooth scroll | | |||
54 | */ | | |||
55 | const int SMOOTH_SCROLL_DURATION = 250; | | |||
56 | | ||||
57 | /** | 52 | /** | ||
58 | * Space between the item outer rect and the content, and between the | 53 | * Space between the item outer rect and the content, and between the | ||
59 | * thumbnail and the caption | 54 | * thumbnail and the caption | ||
Context not available. | |||||
351 | { | 346 | { | ||
352 | ThumbnailBarView* q; | 347 | ThumbnailBarView* q; | ||
353 | QStyle* mStyle; | 348 | QStyle* mStyle; | ||
354 | QTimeLine* mTimeLine; | 349 | QTimeLine* mTimeLine = nullptr; | ||
355 | 350 | | |||
356 | Qt::Orientation mOrientation; | 351 | Qt::Orientation mOrientation; | ||
357 | int mRowCount; | 352 | int mRowCount; | ||
Context not available. | |||||
379 | 374 | | |||
380 | const QRect rect = q->visualRect(index); | 375 | const QRect rect = q->visualRect(index); | ||
381 | 376 | | |||
382 | int oldValue = scrollBar()->value(); | | |||
383 | int newValue = scrollToValue(rect); | 377 | int newValue = scrollToValue(rect); | ||
384 | if (mTimeLine->state() == QTimeLine::Running) { | 378 | if (mTimeLine) { | ||
385 | mTimeLine->stop(); | 379 | int oldValue = scrollBar()->value(); | ||
380 | if (mTimeLine->state() == QTimeLine::Running) { | ||||
381 | mTimeLine->stop(); | ||||
382 | } | ||||
383 | mTimeLine->setFrameRange(oldValue, newValue); | ||||
384 | mTimeLine->start(); | ||||
385 | } else { | ||||
386 | scrollBar()->setValue(newValue); | ||||
386 | } | 387 | } | ||
387 | mTimeLine->setFrameRange(oldValue, newValue); | | |||
388 | mTimeLine->start(); | | |||
389 | } | 388 | } | ||
390 | 389 | | |||
391 | int scrollToValue(const QRect& rect) | 390 | int scrollToValue(const QRect& rect) | ||
Context not available. | |||||
454 | , d(new ThumbnailBarViewPrivate) | 453 | , d(new ThumbnailBarViewPrivate) | ||
455 | { | 454 | { | ||
456 | d->q = this; | 455 | d->q = this; | ||
457 | d->mTimeLine = new QTimeLine(SMOOTH_SCROLL_DURATION, this); | 456 | | ||
458 | connect(d->mTimeLine, &QTimeLine::frameChanged, this, &ThumbnailBarView::slotFrameChanged); | 457 | int animDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this); | ||
458 | if (animDuration > 0) { | ||||
459 | d->mTimeLine = new QTimeLine(animDuration, this); | ||||
460 | connect(d->mTimeLine, &QTimeLine::frameChanged, this, &ThumbnailBarView::slotFrameChanged); | ||||
461 | } | ||||
459 | 462 | | |||
460 | d->mRowCount = 1; | 463 | d->mRowCount = 1; | ||
461 | d->mOrientation = Qt::Vertical; // To pass value-has-changed check in setOrientation() | 464 | d->mOrientation = Qt::Vertical; // To pass value-has-changed check in setOrientation() | ||
Context not available. |