[kde-doc-english] [trojita] src/Gui: GUI: Scrolling within one message by space/backspace
Jan Kundrát
jkt at kde.org
Sun Nov 29 18:18:39 UTC 2015
Git commit 7e1f345be934ea785d523ff9da72e248a44f03a0 by Jan Kundrát.
Committed on 25/11/2015 at 22:30.
Pushed by gerrit into branch 'master'.
GUI: Scrolling within one message by space/backspace
This functionality was already there for situations where the focus
remained in the MsgListWidget. This patch makes it possible to continue
scrolling even once the focus shifts to the message in question.
As a bonus, we're using a pretty animation for the actual scroll.
Thanks to Jan Pobříslo <ccx at webprojekty.cz> (CcxCZ on IRC) for
reporting, and to Thomas for pointing out that mixing "eights of a
degree" and "pixels" is a recipe for disaster.
Change-Id: I0e3deb230f401c46a8d16bdd34176f25f1a1fca0
M +5 -0 src/Gui/CompleteMessageWidget.cpp
M +1 -3 src/Gui/Window.cpp
http://commits.kde.org/trojita/7e1f345be934ea785d523ff9da72e248a44f03a0
diff --git a/src/Gui/CompleteMessageWidget.cpp b/src/Gui/CompleteMessageWidget.cpp
index d1d8097..4306a78 100644
--- a/src/Gui/CompleteMessageWidget.cpp
+++ b/src/Gui/CompleteMessageWidget.cpp
@@ -73,6 +73,11 @@ void CompleteMessageWidget::keyPressEvent(QKeyEvent *ke)
} else if (ke->key() == Qt::Key_End) {
animator->setEndValue(area->verticalScrollBar()->maximum());
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()));
+ animator->start();
} else { // noop, but hey.
QWidget::keyPressEvent(ke);
}
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index c2954f2..dbda3a5 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -903,9 +903,7 @@ bool MainWindow::eventFilter(QObject *o, QEvent *e)
if (e->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(e);
if (keyEvent->key() == Qt::Key_Space || keyEvent->key() == Qt::Key_Backspace) {
- const int delta = keyEvent->key() == Qt::Key_Space ? -120 : 120;
- QWheelEvent we(QPoint(1,1), delta, Qt::NoButton, Qt::NoModifier);
- QCoreApplication::sendEvent(m_messageWidget->messageView, &we);
+ QCoreApplication::sendEvent(m_messageWidget, keyEvent);
return true;
}
return false;
More information about the kde-doc-english
mailing list