[kde-doc-english] [trojita] src/Gui: GUI: Allow for continuous scrolling while holding the Space key down
Jan Kundrát
jkt at kde.org
Sun Nov 29 18:18:40 UTC 2015
Git commit a34d3c36892ea121b2ab318acc7e2d902c9c1515 by Jan Kundrát.
Committed on 27/11/2015 at 13:07.
Pushed by gerrit into branch 'master'.
GUI: Allow for continuous scrolling while holding the Space key down
QAbstractAnimation::start() doesn't restart.
Change-Id: If9b32859186506bba445a97d898ec8f128760ad3
M +5 -2 src/Gui/CompleteMessageWidget.cpp
http://commits.kde.org/trojita/a34d3c36892ea121b2ab318acc7e2d902c9c1515
diff --git a/src/Gui/CompleteMessageWidget.cpp b/src/Gui/CompleteMessageWidget.cpp
index 4306a78..2558a1f 100644
--- a/src/Gui/CompleteMessageWidget.cpp
+++ b/src/Gui/CompleteMessageWidget.cpp
@@ -75,8 +75,11 @@ void CompleteMessageWidget::keyPressEvent(QKeyEvent *ke)
animator->start();
} else if (ke->key() == Qt::Key_Space || ke->key() == Qt::Key_Backspace) {
const int delta = area->verticalScrollBar()->pageStep() * (ke->key() == Qt::Key_Backspace ? -1 : 1);
- animator->setEndValue(qMin(qMax(area->verticalScrollBar()->value() + delta, area->verticalScrollBar()->minimum()),
- area->verticalScrollBar()->maximum()));
+ const int start = animator->state() == QAbstractAnimation::Running ? animator->endValue().toInt() : area->verticalScrollBar()->value();
+ if (animator->state() == QAbstractAnimation::Running) {
+ animator->stop();
+ }
+ animator->setEndValue(qMin(qMax(start + delta, area->verticalScrollBar()->minimum()), area->verticalScrollBar()->maximum()));
animator->start();
} else { // noop, but hey.
QWidget::keyPressEvent(ke);
More information about the kde-doc-english
mailing list