diff options
author | Sami Merilä <sami.merila@nokia.com> | 2009-10-02 13:15:56 (GMT) |
---|---|---|
committer | Sami Merilä <sami.merila@nokia.com> | 2009-10-02 13:15:56 (GMT) |
commit | c206ea53ebac0436bad0c00c1e340f23efb3aa16 (patch) | |
tree | 935d443ba4945469925d8c11c5b0b3f9c2966446 /src | |
parent | 8fa169202bf2bf169b65a72daee6b497f36be65c (diff) | |
download | Qt-c206ea53ebac0436bad0c00c1e340f23efb3aa16.zip Qt-c206ea53ebac0436bad0c00c1e340f23efb3aa16.tar.gz Qt-c206ea53ebac0436bad0c00c1e340f23efb3aa16.tar.bz2 |
Filedialog impossible to use with keypad navigation
QFileDialog contains own internal derived classes for line edit and
list view. Unfortunately, these classes do not handle keypad navigation
correctly - they just accept the navigation key events, causing the
navigation to halt.
Added support for QFileDialogListView, QFileDialogTreeView and
private filedialog class QFileDialogPrivate to handle and possibly ignore
keypad navigaion key events.
Additionally, added support to keypad navigation to ignore empty
widgets. This allows keypad navigation not to go invisible when empty
widgets are tried to be navigated into.
Task-number: QT-643
Reviewed-by: Alessandro Portale
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/dialogs/qfiledialog.cpp | 22 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 10 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/gui/dialogs/qfiledialog.cpp index 297c900..eb5fed0 100644 --- a/src/gui/dialogs/qfiledialog.cpp +++ b/src/gui/dialogs/qfiledialog.cpp @@ -3022,6 +3022,12 @@ bool QFileDialogPrivate::itemViewKeyboardEvent(QKeyEvent *event) { case Qt::Key_Escape: q->hide(); return true; +#ifdef QT_KEYPAD_NAVIGATION + case Qt::Key_Down: + case Qt::Key_Up: + return (QApplication::navigationMode() != Qt::NavigationModeKeypadTabOrder + && QApplication::navigationMode() != Qt::NavigationModeKeypadDirectional); +#endif default: break; } @@ -3142,7 +3148,17 @@ void QFileDialogListView::keyPressEvent(QKeyEvent *e) if (!d_ptr->itemViewKeyboardEvent(e)) { QListView::keyPressEvent(e); } +#ifdef QT_KEYPAD_NAVIGATION + if ((QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder + || QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) + && !hasEditFocus()) { + e->ignore(); + } else { + e->accept(); + } +#else e->accept(); +#endif } QFileDialogTreeView::QFileDialogTreeView(QWidget *parent) : QTreeView(parent) @@ -3189,7 +3205,11 @@ void QFileDialogLineEdit::keyPressEvent(QKeyEvent *e) { int key = e->key(); QLineEdit::keyPressEvent(e); - if (key != Qt::Key_Escape) + if (key != Qt::Key_Escape +#ifdef QT_KEYPAD_NAVIGATION + && QApplication::navigationMode() == Qt::NavigationModeNone +#endif + ) e->accept(); if (hideOnEsc && (key == Qt::Key_Escape || key == Qt::Key_Return || key == Qt::Key_Enter)) { e->accept(); diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 0b75b06..3cfbb09 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11444,11 +11444,15 @@ QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction) QWidget *targetWidget = 0; int shortestDistance = INT_MAX; foreach(QWidget *targetCandidate, QApplication::allWidgets()) { - - if (targetCandidate->focusProxy()) //skip if focus proxy set - continue; const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint())); + + // For focus proxies, the child widget handling the focus can have keypad navigation focus, + // but the owner of the proxy cannot. + // Additionally, empty widgets should be ignored. + if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty()) + continue; + if ( targetCandidate != sourceWidget && targetCandidate->focusPolicy() & Qt::TabFocus && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top()) |