Add QStyleHints::setTabFocusBehavior() for testing purposes

So far we've been dependent on the focus behavior setting in OS X
system preferences. This change allows us to start testing both
behaviors on any platform.

Change-Id: I9ce004f8b9479f8e722a387b795de16edb166a07
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
This commit is contained in:
J-P Nurmi 2016-02-15 14:23:28 +01:00 committed by Liang Qi
parent a93ff2c248
commit 273114582a
2 changed files with 24 additions and 2 deletions

View File

@ -76,6 +76,7 @@ public:
, m_startDragTime(-1)
, m_keyboardInputInterval(-1)
, m_cursorFlashTime(-1)
, m_tabFocusBehavior(-1)
{}
int m_mouseDoubleClickInterval;
@ -84,6 +85,7 @@ public:
int m_startDragTime;
int m_keyboardInputInterval;
int m_cursorFlashTime;
int m_tabFocusBehavior;
};
/*!
@ -416,7 +418,25 @@ bool QStyleHints::setFocusOnTouchRelease() const
Qt::TabFocusBehavior QStyleHints::tabFocusBehavior() const
{
return Qt::TabFocusBehavior(themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
Q_D(const QStyleHints);
return Qt::TabFocusBehavior(d->m_tabFocusBehavior >= 0 ?
d->m_tabFocusBehavior :
themeableHint(QPlatformTheme::TabFocusBehavior, QPlatformIntegration::TabFocusBehavior).toInt());
}
/*!
Sets the \a tabFocusBehavior.
\internal
\sa tabFocusBehavior()
\since 5.7
*/
void QStyleHints::setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior)
{
Q_D(QStyleHints);
if (d->m_tabFocusBehavior == tabFocusBehavior)
return;
d->m_tabFocusBehavior = tabFocusBehavior;
emit tabFocusBehaviorChanged(tabFocusBehavior);
}
/*!

View File

@ -67,7 +67,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
Q_PROPERTY(int startDragVelocity READ startDragVelocity 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)
Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
public:
@ -93,6 +93,7 @@ public:
bool useRtlExtensions() const;
bool setFocusOnTouchRelease() const;
Qt::TabFocusBehavior tabFocusBehavior() const;
void setTabFocusBehavior(Qt::TabFocusBehavior tabFocusBehavior);
bool singleClickActivation() const;
Q_SIGNALS:
@ -102,6 +103,7 @@ Q_SIGNALS:
void mousePressAndHoldIntervalChanged(int mousePressAndHoldInterval);
void startDragDistanceChanged(int startDragDistance);
void startDragTimeChanged(int startDragTime);
void tabFocusBehaviorChanged(Qt::TabFocusBehavior tabFocusBehavior);
private:
friend class QGuiApplication;