diff options
author | Liang Qi <liang.qi@digia.com> | 2013-05-10 11:54:37 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-14 17:27:14 +0200 |
commit | e443f6dc7df2e5a0bd2ab890c3b6094500f5b9ab (patch) | |
tree | c216dfcbb80c622d10efd6c51411a807c5ac253f /src | |
parent | 00556b20067c3a4adf6ff33a17d2a4232fdce6ee (diff) |
Mac: respect the system settings in Full Keyboard Access
Iterate all or not in nextPrevItemInTabFocusChain function.
Change-Id: I95289b042f3d9924c28ffb9c8c7124c767addf2e
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 41 | ||||
-rw-r--r-- | src/quick/items/qquickitem_p.h | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 5ad53e99b6..1667736d46 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -58,6 +58,7 @@ #include <QtCore/qdebug.h> #include <QtCore/qcoreevent.h> #include <QtCore/qnumeric.h> +#include <QtGui/qpa/qplatformtheme.h> #include <private/qqmlglobal_p.h> #include <private/qqmlengine_p.h> @@ -2034,6 +2035,41 @@ QQuickItem::~QQuickItem() /*! \internal +*/ +bool QQuickItemPrivate::qt_tab_all_widgets() +{ + if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) + return theme->themeHint(QPlatformTheme::TabAllWidgets).toBool(); + return true; +} + +/*! + \internal +*/ +bool QQuickItemPrivate::canAcceptTabFocus(QQuickItem *item) +{ + bool result = true; + + if (item->window() && item == item->window()->contentItem()) + return true; + +#ifndef QT_NO_ACCESSIBILITY + result = false; + if (QObject *acc = qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)) { + int role = acc->property("role").toInt(); + if (role == QAccessible::EditableText + || role == QAccessible::Table + || role == QAccessible::List + || role == QAccessible::SpinBox) + result = true; + } +#endif + + return result; +} + +/*! + \internal \brief QQuickItemPrivate::focusNextPrev focuses the next/prev item in the tab-focus-chain \param item The item that currently has the focus \param forward The direction @@ -2059,6 +2095,8 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo Q_ASSERT(item); Q_ASSERT(item->activeFocusOnTab()); + bool all = QQuickItemPrivate::qt_tab_all_widgets(); + QQuickItem *from = 0; if (forward) { from = item->parentItem(); @@ -2121,7 +2159,8 @@ QQuickItem* QQuickItemPrivate::nextPrevItemInTabFocusChain(QQuickItem *item, boo } from = last; - } while (skip || !current->activeFocusOnTab() || !current->isEnabled() || !current->isVisible()); + } while (skip || !current->activeFocusOnTab() || !current->isEnabled() || !current->isVisible() + || !(all || QQuickItemPrivate::canAcceptTabFocus(current))); return current; } diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 12a5165d9b..c71da3c330 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -491,6 +491,9 @@ public: static bool focusNextPrev(QQuickItem *item, bool forward); static QQuickItem *nextPrevItemInTabFocusChain(QQuickItem *item, bool forward); + static bool qt_tab_all_widgets(); //todo: move to QGuiApplication? + static bool canAcceptTabFocus(QQuickItem *item); + qreal x; qreal y; qreal width; |