diff options
| author | Ashish Bansal <[email protected]> | 2015-05-06 15:47:18 +0530 |
|---|---|---|
| committer | Ashish Bansal <[email protected]> | 2015-05-06 15:47:18 +0530 |
| commit | 1fe148805dbe524645b352621bd42493d10988ff (patch) | |
| tree | 18b0bcea20aa7b3e51984229ec74a84c533cec03 /src/kitemviews/kitemlistcontainer.cpp | |
| parent | c1a2c0f1a76dd1df7109d11a9f511b8c33d85054 (diff) | |
Scroll by page if Shift Key is pressed
If shift key is pressed along with scroll, scroll up/down by whole page.
REVIEW: 123596
Diffstat (limited to 'src/kitemviews/kitemlistcontainer.cpp')
| -rw-r--r-- | src/kitemviews/kitemlistcontainer.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/kitemviews/kitemlistcontainer.cpp b/src/kitemviews/kitemlistcontainer.cpp index f5c785a3e..c9d521ce7 100644 --- a/src/kitemviews/kitemlistcontainer.cpp +++ b/src/kitemviews/kitemlistcontainer.cpp @@ -186,11 +186,21 @@ void KItemListContainer::wheelEvent(QWheelEvent* event) const QScrollBar* scrollBar = smoothScroller->scrollBar(); if (!event->pixelDelta().isNull()) { const int numPixels = event->pixelDelta().y(); - smoothScroller->scrollTo(scrollBar->value() - numPixels); + if (event->modifiers().testFlag(Qt::ShiftModifier)) { + const int scrollingDirection = numPixels > 0 ? 1 : -1; + smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection); + } else { + smoothScroller->scrollTo(scrollBar->value() - numPixels); + } } else { const int numDegrees = event->angleDelta().y() / 8; const int numSteps = numDegrees / 15; - smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4); + if (event->modifiers().testFlag(Qt::ShiftModifier)) { + const int scrollingDirection = numSteps > 0 ? 1 : -1; + smoothScroller->scrollTo(scrollBar->value() - scrollBar->pageStep() * scrollingDirection); + } else { + smoothScroller->scrollTo(scrollBar->value() - numSteps * scrollBar->pageStep() / 4); + } } event->accept(); |
