Fix keyboard navigation order for buttons with RTL layout

On RTL layout, right key should move to previous button, and left key should
move to next button.

Task-number: QTBUG-15790
Change-Id: If0753f9082b3a3624b95276840f5f3799b5e14bf
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
Orgad Shaneh 2010-12-09 22:20:58 +02:00 committed by Qt by Nokia
parent 4f1820e3a7
commit a4d0c56a59

View File

@ -1178,11 +1178,11 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
}
break;
case Qt::Key_Up:
case Qt::Key_Left:
next = false;
// fall through
case Qt::Key_Left:
case Qt::Key_Right:
case Qt::Key_Down:
case Qt::Key_Down: {
#ifdef QT_KEYPAD_NAVIGATION
if ((QApplication::keypadNavigationEnabled()
&& (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right))
@ -1192,13 +1192,13 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
return;
}
#endif
QWidget *pw;
QWidget *pw = parentWidget();
if (d->autoExclusive
#ifndef QT_NO_BUTTONGROUP
|| d->group
#endif
#ifndef QT_NO_ITEMVIEWS
|| ((pw = parentWidget()) && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
|| (pw && qobject_cast<QAbstractItemView *>(pw->parentWidget()))
#endif
) {
// ### Using qobject_cast to check if the parent is a viewport of
@ -1209,9 +1209,17 @@ void QAbstractButton::keyPressEvent(QKeyEvent *e)
if (hasFocus()) // nothing happend, propagate
e->ignore();
} else {
// Prefer parent widget, use this if parent is absent
QWidget *w = pw ? pw : this;
bool reverse = (w->layoutDirection() == Qt::RightToLeft);
if ((e->key() == Qt::Key_Left && !reverse)
|| (e->key() == Qt::Key_Right && reverse)) {
next = false;
}
focusNextPrevChild(next);
}
break;
}
case Qt::Key_Escape:
if (d->down) {
setDown(false);