Expose TabFocusBehavior in QStyleHints

TabAllWidgets in QPlatformTheme is replaced by TabFocusBehavior.

[ChangeLog][QtGui] Expose TabFocusBehavior in QStyleHints

Change-Id: Iafaad7c6a5c6bc888d1e124e6ddcdbdc46f37b1c
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
This commit is contained in:
Liang Qi 2015-01-30 11:23:56 +01:00
parent 98aae7428d
commit ce10188aa9
9 changed files with 54 additions and 7 deletions

View File

@ -173,6 +173,13 @@ public:
WheelFocus = StrongFocus | 0x4 WheelFocus = StrongFocus | 0x4
}; };
enum TabFocusBehavior {
NoTabFocus = 0x00,
TabFocusTextControls = 0x01,
TabFocusListControls = 0x02,
TabFocusAllControls = 0xff
};
enum SortOrder { enum SortOrder {
AscendingOrder, AscendingOrder,
DescendingOrder DescendingOrder
@ -1686,6 +1693,7 @@ public:
QT_Q_ENUM(TimerType) QT_Q_ENUM(TimerType)
QT_Q_ENUM(ScrollPhase) QT_Q_ENUM(ScrollPhase)
QT_Q_ENUM(MouseEventSource) QT_Q_ENUM(MouseEventSource)
QT_Q_ENUM(TabFocusBehavior)
#endif // Q_DOC #endif // Q_DOC
} }

View File

@ -1929,6 +1929,19 @@
*/ */
/*!
\enum Qt::TabFocusBehavior
\since 5.5
This enum type provides different focus behaviors for tab navigation.
\value NoTabFocus iterate nothing.
\value TabFocusTextControls iterate text controls and widgets.
\value TabFocusListControls iterate list controls and widgets.
\value TabFocusAllControls iterate all controls and widgets.
*/
/*! /*!
\enum Qt::ShortcutContext \enum Qt::ShortcutContext

View File

@ -392,6 +392,8 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QVariant(false); return QVariant(false);
case MousePressAndHoldInterval: case MousePressAndHoldInterval:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::MousePressAndHoldInterval); return QPlatformTheme::defaultThemeHint(QPlatformTheme::MousePressAndHoldInterval);
case TabFocusBehavior:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::TabFocusBehavior);
} }
return 0; return 0;

View File

@ -145,7 +145,8 @@ public:
PasswordMaskCharacter, PasswordMaskCharacter,
SetFocusOnTouchRelease, SetFocusOnTouchRelease,
ShowIsMaximized, ShowIsMaximized,
MousePressAndHoldInterval MousePressAndHoldInterval,
TabFocusBehavior
}; };
virtual QVariant styleHint(StyleHint hint) const; virtual QVariant styleHint(StyleHint hint) const;

View File

@ -132,8 +132,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, \value TabFocusBehavior (int) A Qt::TabFocusBehavior specifying
or just through text boxes and list views. This is mostly a Mac feature. the behavior of focus change when tab key was pressed.
This enum value was added in Qt 5.5.
\value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog \value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog
becomes visible. becomes visible.
@ -491,8 +492,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: case TabFocusBehavior:
return QVariant(true); return QVariant(int(Qt::TabFocusAllControls));
case IconPixmapSizes: case IconPixmapSizes:
return QVariant::fromValue(QList<int>()); return QVariant::fromValue(QList<int>());
case DialogSnapToDefaultButton: case DialogSnapToDefaultButton:

View File

@ -95,7 +95,12 @@ public:
KeyboardScheme, KeyboardScheme,
UiEffects, UiEffects,
SpellCheckUnderlineStyle, SpellCheckUnderlineStyle,
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
TabFocusBehavior,
#else
TabAllWidgets, TabAllWidgets,
TabFocusBehavior = TabAllWidgets,
#endif
IconPixmapSizes, IconPixmapSizes,
PasswordMaskCharacter, PasswordMaskCharacter,
DialogSnapToDefaultButton, DialogSnapToDefaultButton,

View File

@ -358,4 +358,18 @@ bool QStyleHints::setFocusOnTouchRelease() const
return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool(); return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool();
} }
/*!
\property QStyleHints::tabFocusBehavior
\since 5.5
\brief The focus behavior on press of the tab key.
\note Do not bind this value in QML because the change notifier
signal is not implemented yet.
*/
Qt::TabFocusBehavior QStyleHints::tabFocusBehavior() const
{
return Qt::TabFocusBehavior(themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
}
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -60,6 +60,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL) Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL) Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL)
Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL) Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL)
Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior STORED false CONSTANT FINAL)
public: public:
void setMouseDoubleClickInterval(int mouseDoubleClickInterval); void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
@ -81,6 +82,7 @@ public:
qreal fontSmoothingGamma() const; qreal fontSmoothingGamma() const;
bool useRtlExtensions() const; bool useRtlExtensions() const;
bool setFocusOnTouchRelease() const; bool setFocusOnTouchRelease() const;
Qt::TabFocusBehavior tabFocusBehavior() const;
Q_SIGNALS: Q_SIGNALS:
void cursorFlashTimeChanged(int cursorFlashTime); void cursorFlashTimeChanged(int cursorFlashTime);

View File

@ -281,8 +281,9 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
return QVariant(QPlatformDialogHelper::MacLayout); return QVariant(QPlatformDialogHelper::MacLayout);
case KeyboardScheme: case KeyboardScheme:
return QVariant(int(MacKeyboardScheme)); return QVariant(int(MacKeyboardScheme));
case TabAllWidgets: case TabFocusBehavior:
return QVariant(bool([[NSApplication sharedApplication] isFullKeyboardAccessEnabled])); return QVariant([[NSApplication sharedApplication] isFullKeyboardAccessEnabled] ?
int(Qt::TabFocusAllControls) : int(Qt::TabFocusTextControls | Qt::TabFocusListControls));
case IconPixmapSizes: { case IconPixmapSizes: {
qreal devicePixelRatio = qGuiApp->devicePixelRatio(); qreal devicePixelRatio = qGuiApp->devicePixelRatio();
QList<int> sizes; QList<int> sizes;