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. | |||||
348 | { | 343 | { | ||
349 | ThumbnailBarView* q; | 344 | ThumbnailBarView* q; | ||
350 | QStyle* mStyle; | 345 | QStyle* mStyle; | ||
351 | QTimeLine* mTimeLine; | 346 | QTimeLine* mTimeLine = nullptr; | ||
352 | 347 | | |||
353 | Qt::Orientation mOrientation; | 348 | Qt::Orientation mOrientation; | ||
354 | int mRowCount; | 349 | int mRowCount; | ||
Context not available. | |||||
376 | 371 | | |||
377 | const QRect rect = q->visualRect(index); | 372 | const QRect rect = q->visualRect(index); | ||
378 | 373 | | |||
379 | int oldValue = scrollBar()->value(); | | |||
380 | int newValue = scrollToValue(rect); | 374 | int newValue = scrollToValue(rect); | ||
381 | if (mTimeLine->state() == QTimeLine::Running) { | 375 | if (mTimeLine) { | ||
382 | mTimeLine->stop(); | 376 | int oldValue = scrollBar()->value(); | ||
377 | if (mTimeLine->state() == QTimeLine::Running) { | ||||
378 | mTimeLine->stop(); | ||||
379 | } | ||||
380 | mTimeLine->setFrameRange(oldValue, newValue); | ||||
381 | mTimeLine->start(); | ||||
382 | } else { | ||||
383 | scrollBar()->setValue(newValue); | ||||
383 | } | 384 | } | ||
384 | mTimeLine->setFrameRange(oldValue, newValue); | | |||
385 | mTimeLine->start(); | | |||
386 | } | 385 | } | ||
387 | 386 | | |||
388 | int scrollToValue(const QRect& rect) | 387 | int scrollToValue(const QRect& rect) | ||
Context not available. | |||||
451 | , d(new ThumbnailBarViewPrivate) | 450 | , d(new ThumbnailBarViewPrivate) | ||
452 | { | 451 | { | ||
453 | d->q = this; | 452 | d->q = this; | ||
454 | d->mTimeLine = new QTimeLine(SMOOTH_SCROLL_DURATION, this); | 453 | | ||
455 | connect(d->mTimeLine, &QTimeLine::frameChanged, this, &ThumbnailBarView::slotFrameChanged); | 454 | int animDuration = style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, this); | ||
455 | if (animDuration > 0) { | ||||
456 | d->mTimeLine = new QTimeLine(animDuration, this); | ||||
457 | connect(d->mTimeLine, &QTimeLine::frameChanged, this, &ThumbnailBarView::slotFrameChanged); | ||||
458 | } | ||||
456 | 459 | | |||
457 | d->mRowCount = 1; | 460 | d->mRowCount = 1; | ||
458 | d->mOrientation = Qt::Vertical; // To pass value-has-changed check in setOrientation() | 461 | d->mOrientation = Qt::Vertical; // To pass value-has-changed check in setOrientation() | ||
Context not available. |