Skip to content

Commit

Permalink
Add QStyleHints::setMousePressAndHoldInterval()
Browse files Browse the repository at this point in the history
Allows speeding up press & hold auto tests in qtquick core & controls.

Change-Id: I66717b581996977e894e3c386880ab90379abaef
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
  • Loading branch information
J-P Nurmi committed Nov 13, 2015
1 parent e876391 commit bc6af06
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/gui/kernel/qstylehints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ class QStyleHintsPrivate : public QObjectPrivate
public:
inline QStyleHintsPrivate()
: m_mouseDoubleClickInterval(-1)
, m_mousePressAndHoldInterval(-1)
, m_startDragDistance(-1)
, m_startDragTime(-1)
, m_keyboardInputInterval(-1)
, m_cursorFlashTime(-1)
{}

int m_mouseDoubleClickInterval;
int m_mousePressAndHoldInterval;
int m_startDragDistance;
int m_startDragTime;
int m_keyboardInputInterval;
Expand Down Expand Up @@ -128,6 +130,21 @@ int QStyleHints::mouseDoubleClickInterval() const
themeableHint(QPlatformTheme::MouseDoubleClickInterval, QPlatformIntegration::MouseDoubleClickInterval).toInt();
}

/*!
Sets the \a mousePressAndHoldInterval.
\internal
\sa mousePressAndHoldInterval()
\since 5.7
*/
void QStyleHints::setMousePressAndHoldInterval(int mousePressAndHoldInterval)
{
Q_D(QStyleHints);
if (d->m_mousePressAndHoldInterval == mousePressAndHoldInterval)
return;
d->m_mousePressAndHoldInterval = mousePressAndHoldInterval;
emit mousePressAndHoldIntervalChanged(mousePressAndHoldInterval);
}

/*!
\property QStyleHints::mousePressAndHoldInterval
\brief the time limit in milliseconds that activates
Expand All @@ -137,7 +154,10 @@ int QStyleHints::mouseDoubleClickInterval() const
*/
int QStyleHints::mousePressAndHoldInterval() const
{
return themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
Q_D(const QStyleHints);
return d->m_mousePressAndHoldInterval >= 0 ?
d->m_mousePressAndHoldInterval :
themeableHint(QPlatformTheme::MousePressAndHoldInterval, QPlatformIntegration::MousePressAndHoldInterval).toInt();
}

/*!
Expand Down
4 changes: 3 additions & 1 deletion src/gui/kernel/qstylehints.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_PROPERTY(int keyboardAutoRepeatRate READ keyboardAutoRepeatRate STORED false CONSTANT FINAL)
Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval NOTIFY keyboardInputIntervalChanged FINAL)
Q_PROPERTY(int mouseDoubleClickInterval READ mouseDoubleClickInterval NOTIFY mouseDoubleClickIntervalChanged FINAL)
Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval STORED false CONSTANT FINAL)
Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval NOTIFY mousePressAndHoldIntervalChanged FINAL)
Q_PROPERTY(QChar passwordMaskCharacter READ passwordMaskCharacter STORED false CONSTANT FINAL)
Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL)
Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL)
Expand All @@ -66,6 +66,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
public:
void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
int mouseDoubleClickInterval() const;
void setMousePressAndHoldInterval(int mousePressAndHoldInterval);
int mousePressAndHoldInterval() const;
void setStartDragDistance(int startDragDistance);
int startDragDistance() const;
Expand All @@ -90,6 +91,7 @@ class Q_GUI_EXPORT QStyleHints : public QObject
void cursorFlashTimeChanged(int cursorFlashTime);
void keyboardInputIntervalChanged(int keyboardInputInterval);
void mouseDoubleClickIntervalChanged(int mouseDoubleClickInterval);
void mousePressAndHoldIntervalChanged(int mousePressAndHoldInterval);
void startDragDistanceChanged(int startDragDistance);
void startDragTimeChanged(int startDragTime);

Expand Down

0 comments on commit bc6af06

Please sign in to comment.