Revert "Code style fix"

This reverts commit e1d7df5ce9.

The offending patch removed handling of page-up and page-down
shortcuts in QScrollView (including subclasses like QTextBrowser).

Pick-to: 6.2
Fixes: QTBUG-97908
Fixes: QTBUG-90352
Change-Id: If760e983a082edb53e12e1311e2c7f2676d80bb2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
This commit is contained in:
Richard Moe Gustavsen 2021-11-02 09:02:45 +01:00
parent f04dbdfc97
commit 8ba3a2f911

View File

@ -1232,49 +1232,57 @@ void QAbstractScrollArea::contextMenuEvent(QContextMenuEvent *e)
void QAbstractScrollArea::keyPressEvent(QKeyEvent * e)
{
Q_D(QAbstractScrollArea);
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
e->ignore();
return;
}
if (false){
#ifndef QT_NO_SHORTCUT
} else if (e == QKeySequence::MoveToPreviousPage) {
d->vbar->triggerAction(QScrollBar::SliderPageStepSub);
} else if (e == QKeySequence::MoveToNextPage) {
d->vbar->triggerAction(QScrollBar::SliderPageStepAdd);
#endif
switch (e->key()) {
case Qt::Key_Up:
d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
break;
case Qt::Key_Down:
d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
break;
case Qt::Key_Left:
} else {
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
&& (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
//if we aren't using the hbar or we are already at the leftmost point ignore
e->ignore();
return;
}
if (QApplicationPrivate::keypadNavigationEnabled() && !hasEditFocus()) {
e->ignore();
return;
}
#endif
d->hbar->triggerAction(
layoutDirection() == Qt::LeftToRight
? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);
break;
case Qt::Key_Right:
switch (e->key()) {
case Qt::Key_Up:
d->vbar->triggerAction(QScrollBar::SliderSingleStepSub);
break;
case Qt::Key_Down:
d->vbar->triggerAction(QScrollBar::SliderSingleStepAdd);
break;
case Qt::Key_Left:
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
&& (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
//if we aren't using the hbar or we are already at the rightmost point ignore
e->ignore();
return;
}
if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
&& (!d->hbar->isVisible() || d->hbar->value() == d->hbar->minimum())) {
//if we aren't using the hbar or we are already at the leftmost point ignore
e->ignore();
return;
}
#endif
d->hbar->triggerAction(
layoutDirection() == Qt::LeftToRight
? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
break;
default:
e->ignore();
return;
d->hbar->triggerAction(
layoutDirection() == Qt::LeftToRight
? QScrollBar::SliderSingleStepSub : QScrollBar::SliderSingleStepAdd);
break;
case Qt::Key_Right:
#ifdef QT_KEYPAD_NAVIGATION
if (QApplicationPrivate::keypadNavigationEnabled() && hasEditFocus()
&& (!d->hbar->isVisible() || d->hbar->value() == d->hbar->maximum())) {
//if we aren't using the hbar or we are already at the rightmost point ignore
e->ignore();
return;
}
#endif
d->hbar->triggerAction(
layoutDirection() == Qt::LeftToRight
? QScrollBar::SliderSingleStepAdd : QScrollBar::SliderSingleStepSub);
break;
default:
e->ignore();
return;
}
}
e->accept();
}