Mac: Bring back "Text boxes and list only" tab navigation

Added ThemeHint::TabAllWidgets as a mean to access that platform
specific bool. The default implementation returns always true when
querying QPlatformTheme::themeHint().

Several auto-tests had to be updated to reflect for qt_tab_all_widgets'
type change. One XFAIL removed from tst_QApplication::focusChanged().

Task-number: QTBUG-24372
Change-Id: Ie1f0486c19898fe54c53aa4a27e378485075e512
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
Gabriel de Dietrich 2012-10-09 11:27:01 +02:00 committed by The Qt Project
parent 5715455901
commit 06332df743
11 changed files with 33 additions and 21 deletions

View File

@ -129,6 +129,9 @@ QT_BEGIN_NAMESPACE
\value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying
the underline style used misspelled words when spell checking.
\value TabAllWidgets (bool) Whether tab navigation should go through all the widgets or components,
or just through text boxes and list views. This is mostly a Mac feature.
\sa themeHint(), QStyle::pixelMetric()
*/
@ -218,6 +221,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant(int(0));
case SpellCheckUnderlineStyle:
return QVariant(int(QTextCharFormat::SpellCheckUnderline));
case TabAllWidgets:
return QVariant(true);
}
return QVariant();
}

View File

@ -96,7 +96,8 @@ public:
UseFullScreenForPopupMenu,
KeyboardScheme,
UiEffects,
SpellCheckUnderlineStyle
SpellCheckUnderlineStyle,
TabAllWidgets
};
enum DialogType {

View File

@ -39,6 +39,8 @@
**
****************************************************************************/
#import <Cocoa/Cocoa.h>
#include "qcocoatheme.h"
#include <QtCore/QVariant>
@ -142,6 +144,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
return QVariant(1); // QDialogButtonBox::MacLayout
case KeyboardScheme:
return QVariant(int(MacKeyboardScheme));
case TabAllWidgets:
return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled]));
default:
break;
}

View File

@ -190,7 +190,7 @@ QT_BEGIN_NAMESPACE
*/
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets;
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
/*!
\internal
@ -357,7 +357,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
}
QWidget *oldChild = child;
uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
do {
if (child->isEnabled()
&& child->isVisibleTo(widget)

View File

@ -397,7 +397,6 @@ QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboar
#ifndef QT_NO_WHEELEVENT
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
#endif
bool Q_WIDGETS_EXPORT qt_tab_all_widgets = true;
bool qt_in_tab_key_event = false;
int qt_antialiasing_threshold = -1;
QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
@ -416,6 +415,13 @@ inline bool QApplicationPrivate::isAlien(QWidget *widget)
return widget && !widget->isWindow();
}
bool Q_WIDGETS_EXPORT qt_tab_all_widgets()
{
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
return theme->themeHint(QPlatformTheme::TabAllWidgets).toBool();
return true;
}
// ######## move to QApplicationPrivate
// Default application palettes and fonts (per widget type)
Q_GLOBAL_STATIC(PaletteHash, app_palettes)
@ -2080,7 +2086,7 @@ void QApplication::setActiveWindow(QWidget* act)
*/
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next)
{
uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
QWidget *f = toplevel->focusWidget();
if (!f)

View File

@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
#define AUTO_REPEAT_DELAY 300
#define AUTO_REPEAT_INTERVAL 100
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets;
Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets();
/*!
\class QAbstractButton
@ -385,7 +385,7 @@ void QAbstractButtonPrivate::moveFocus(int key)
int bestScore = -1;
QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
QPoint goal = target.center();
uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
uint focus_flag = qt_tab_all_widgets() ? Qt::TabFocus : Qt::StrongFocus;
for (int i = 0; i < buttonList.count(); ++i) {
QAbstractButton *button = buttonList.at(i);

View File

@ -3331,12 +3331,12 @@ void tst_QTableView::resizeToContents()
}
QT_BEGIN_NAMESPACE
extern bool Q_GUI_EXPORT qt_tab_all_widgets; // qapplication.cpp
extern bool Q_GUI_EXPORT qt_tab_all_widgets(); // qapplication.cpp
QT_END_NAMESPACE
void tst_QTableView::tabFocus()
{
if (!qt_tab_all_widgets)
if (!qt_tab_all_widgets())
QSKIP("This test requires full keyboard control to be enabled.");
// QTableView enables tabKeyNavigation by default, but you should be able

View File

@ -100,7 +100,7 @@ static QList<struct QWindowSystemInterface::TouchPoint> touchPointList(const QLi
extern bool Q_GUI_EXPORT qt_tab_all_widgets; // from qapplication.cpp
extern bool Q_GUI_EXPORT qt_tab_all_widgets(); // from qapplication.cpp
QT_END_NAMESPACE
class tst_QApplication : public QObject
@ -1597,14 +1597,10 @@ void tst_QApplication::focusChanged()
QSettings appleSettings(QLatin1String("apple.com"));
QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
tabAllControls = (appleValue.toInt() & 0x2);
if (!tabAllControls) {
QEXPECT_FAIL("", "QTBUG-24372 Mac tab key \"Text boxes and lists only\" vs "
"\"All controls\" setting is not respected in Qt5", Abort);
}
#endif
// make sure Qt's idea of tabbing between widgets matches what we think it should
QCOMPARE(qt_tab_all_widgets, tabAllControls);
QCOMPARE(qt_tab_all_widgets(), tabAllControls);
tab.simulate(now);
if (!tabAllControls) {

View File

@ -121,13 +121,13 @@ void tst_QButtonGroup::cleanup()
}
QT_BEGIN_NAMESPACE
extern bool Q_GUI_EXPORT qt_tab_all_widgets;
extern bool Q_GUI_EXPORT qt_tab_all_widgets();
QT_END_NAMESPACE
void tst_QButtonGroup::arrowKeyNavigation()
{
if (!qt_tab_all_widgets)
if (!qt_tab_all_widgets())
QSKIP("This test requires full keyboard control to be enabled.");
QDialog dlg(0);

View File

@ -65,7 +65,7 @@
QT_BEGIN_NAMESPACE
#if !defined(Q_WS_WIN)
extern bool qt_tab_all_widgets;
extern bool qt_tab_all_widgets();
#endif
QT_END_NAMESPACE
@ -73,7 +73,7 @@ static inline bool tabAllWidgets()
{
#if !defined(Q_OS_WIN)
if (qApp->style()->inherits("QMacStyle"))
return qt_tab_all_widgets;
return qt_tab_all_widgets();
#endif
return true;
}

View File

@ -366,7 +366,7 @@ void tst_QMenu::keyboardNavigation()
#ifdef Q_OS_MAC
QT_BEGIN_NAMESPACE
extern bool qt_tab_all_widgets; // from qapplication.cpp
extern bool qt_tab_all_widgets(); // from qapplication.cpp
QT_END_NAMESPACE
#endif
@ -378,7 +378,7 @@ void tst_QMenu::focus()
menu.addAction("Three");
#ifdef Q_OS_MAC
if (!qt_tab_all_widgets)
if (!qt_tab_all_widgets())
QSKIP("Computer is currently set up to NOT tab to all widgets,"
" this test assumes you can tab to all widgets");
#endif