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:
parent
5715455901
commit
06332df743
@ -129,6 +129,9 @@ QT_BEGIN_NAMESPACE
|
|||||||
\value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying
|
\value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying
|
||||||
the underline style used misspelled words when spell checking.
|
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()
|
\sa themeHint(), QStyle::pixelMetric()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -218,6 +221,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
|||||||
return QVariant(int(0));
|
return QVariant(int(0));
|
||||||
case SpellCheckUnderlineStyle:
|
case SpellCheckUnderlineStyle:
|
||||||
return QVariant(int(QTextCharFormat::SpellCheckUnderline));
|
return QVariant(int(QTextCharFormat::SpellCheckUnderline));
|
||||||
|
case TabAllWidgets:
|
||||||
|
return QVariant(true);
|
||||||
}
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,8 @@ public:
|
|||||||
UseFullScreenForPopupMenu,
|
UseFullScreenForPopupMenu,
|
||||||
KeyboardScheme,
|
KeyboardScheme,
|
||||||
UiEffects,
|
UiEffects,
|
||||||
SpellCheckUnderlineStyle
|
SpellCheckUnderlineStyle,
|
||||||
|
TabAllWidgets
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DialogType {
|
enum DialogType {
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#include "qcocoatheme.h"
|
#include "qcocoatheme.h"
|
||||||
|
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
@ -142,6 +144,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
|||||||
return QVariant(1); // QDialogButtonBox::MacLayout
|
return QVariant(1); // QDialogButtonBox::MacLayout
|
||||||
case KeyboardScheme:
|
case KeyboardScheme:
|
||||||
return QVariant(int(MacKeyboardScheme));
|
return QVariant(int(MacKeyboardScheme));
|
||||||
|
case TabAllWidgets:
|
||||||
|
return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled]));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
|
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
|
\internal
|
||||||
@ -357,7 +357,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QWidget *oldChild = child;
|
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 {
|
do {
|
||||||
if (child->isEnabled()
|
if (child->isEnabled()
|
||||||
&& child->isVisibleTo(widget)
|
&& child->isVisibleTo(widget)
|
||||||
|
@ -397,7 +397,6 @@ QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboar
|
|||||||
#ifndef QT_NO_WHEELEVENT
|
#ifndef QT_NO_WHEELEVENT
|
||||||
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
|
int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
|
||||||
#endif
|
#endif
|
||||||
bool Q_WIDGETS_EXPORT qt_tab_all_widgets = true;
|
|
||||||
bool qt_in_tab_key_event = false;
|
bool qt_in_tab_key_event = false;
|
||||||
int qt_antialiasing_threshold = -1;
|
int qt_antialiasing_threshold = -1;
|
||||||
QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
|
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();
|
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
|
// ######## move to QApplicationPrivate
|
||||||
// Default application palettes and fonts (per widget type)
|
// Default application palettes and fonts (per widget type)
|
||||||
Q_GLOBAL_STATIC(PaletteHash, app_palettes)
|
Q_GLOBAL_STATIC(PaletteHash, app_palettes)
|
||||||
@ -2080,7 +2086,7 @@ void QApplication::setActiveWindow(QWidget* act)
|
|||||||
*/
|
*/
|
||||||
QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next)
|
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();
|
QWidget *f = toplevel->focusWidget();
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
#define AUTO_REPEAT_DELAY 300
|
#define AUTO_REPEAT_DELAY 300
|
||||||
#define AUTO_REPEAT_INTERVAL 100
|
#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
|
\class QAbstractButton
|
||||||
@ -385,7 +385,7 @@ void QAbstractButtonPrivate::moveFocus(int key)
|
|||||||
int bestScore = -1;
|
int bestScore = -1;
|
||||||
QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
|
QRect target = f->rect().translated(f->mapToGlobal(QPoint(0,0)));
|
||||||
QPoint goal = target.center();
|
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) {
|
for (int i = 0; i < buttonList.count(); ++i) {
|
||||||
QAbstractButton *button = buttonList.at(i);
|
QAbstractButton *button = buttonList.at(i);
|
||||||
|
@ -3331,12 +3331,12 @@ void tst_QTableView::resizeToContents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
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
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
void tst_QTableView::tabFocus()
|
void tst_QTableView::tabFocus()
|
||||||
{
|
{
|
||||||
if (!qt_tab_all_widgets)
|
if (!qt_tab_all_widgets())
|
||||||
QSKIP("This test requires full keyboard control to be enabled.");
|
QSKIP("This test requires full keyboard control to be enabled.");
|
||||||
|
|
||||||
// QTableView enables tabKeyNavigation by default, but you should be able
|
// QTableView enables tabKeyNavigation by default, but you should be able
|
||||||
|
@ -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
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
class tst_QApplication : public QObject
|
class tst_QApplication : public QObject
|
||||||
@ -1597,14 +1597,10 @@ void tst_QApplication::focusChanged()
|
|||||||
QSettings appleSettings(QLatin1String("apple.com"));
|
QSettings appleSettings(QLatin1String("apple.com"));
|
||||||
QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
|
QVariant appleValue = appleSettings.value(QLatin1String("AppleKeyboardUIMode"), 0);
|
||||||
tabAllControls = (appleValue.toInt() & 0x2);
|
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
|
#endif
|
||||||
|
|
||||||
// make sure Qt's idea of tabbing between widgets matches what we think it should
|
// 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);
|
tab.simulate(now);
|
||||||
if (!tabAllControls) {
|
if (!tabAllControls) {
|
||||||
|
@ -121,13 +121,13 @@ void tst_QButtonGroup::cleanup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
extern bool Q_GUI_EXPORT qt_tab_all_widgets;
|
extern bool Q_GUI_EXPORT qt_tab_all_widgets();
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
void tst_QButtonGroup::arrowKeyNavigation()
|
void tst_QButtonGroup::arrowKeyNavigation()
|
||||||
{
|
{
|
||||||
if (!qt_tab_all_widgets)
|
if (!qt_tab_all_widgets())
|
||||||
QSKIP("This test requires full keyboard control to be enabled.");
|
QSKIP("This test requires full keyboard control to be enabled.");
|
||||||
|
|
||||||
QDialog dlg(0);
|
QDialog dlg(0);
|
||||||
|
@ -65,7 +65,7 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
#if !defined(Q_WS_WIN)
|
#if !defined(Q_WS_WIN)
|
||||||
extern bool qt_tab_all_widgets;
|
extern bool qt_tab_all_widgets();
|
||||||
#endif
|
#endif
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ static inline bool tabAllWidgets()
|
|||||||
{
|
{
|
||||||
#if !defined(Q_OS_WIN)
|
#if !defined(Q_OS_WIN)
|
||||||
if (qApp->style()->inherits("QMacStyle"))
|
if (qApp->style()->inherits("QMacStyle"))
|
||||||
return qt_tab_all_widgets;
|
return qt_tab_all_widgets();
|
||||||
#endif
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,7 @@ void tst_QMenu::keyboardNavigation()
|
|||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
extern bool qt_tab_all_widgets; // from qapplication.cpp
|
extern bool qt_tab_all_widgets(); // from qapplication.cpp
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ void tst_QMenu::focus()
|
|||||||
menu.addAction("Three");
|
menu.addAction("Three");
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#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,"
|
QSKIP("Computer is currently set up to NOT tab to all widgets,"
|
||||||
" this test assumes you can tab to all widgets");
|
" this test assumes you can tab to all widgets");
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user