diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-10-24 23:50:38 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-10-25 08:45:24 +0000 |
commit | 90659c9bed2464d87602c3d25eed2db2c4004b9a (patch) | |
tree | c72ff8f6ef4315b96d2cedf76d4a5aafa615335c /src/quicktemplates2/qquickabstractbutton.cpp | |
parent | 2de38813d72ff243459897aea2b2596287e4e1d3 (diff) |
Add QQuickAbstractButton::autoRepeatDelay and autoRepeatInterval
[ChangeLog][Controls][AbstractButton] Added autoRepeatDelay and
autoRepeatInterval properties.
Change-Id: Ib086ef429218c6507688865d82726fdcf838633c
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickabstractbutton.cpp')
-rw-r--r-- | src/quicktemplates2/qquickabstractbutton.cpp | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickabstractbutton.cpp b/src/quicktemplates2/qquickabstractbutton.cpp index 44d1da25..82147c06 100644 --- a/src/quicktemplates2/qquickabstractbutton.cpp +++ b/src/quicktemplates2/qquickabstractbutton.cpp @@ -179,6 +179,8 @@ QQuickAbstractButtonPrivate::QQuickAbstractButtonPrivate() holdTimer(0), delayTimer(0), repeatTimer(0), + repeatDelay(AUTO_REPEAT_DELAY), + repeatInterval(AUTO_REPEAT_INTERVAL), #if QT_CONFIG(shortcut) shortcutId(0), #endif @@ -286,14 +288,14 @@ void QQuickAbstractButtonPrivate::startRepeatDelay() { Q_Q(QQuickAbstractButton); stopPressRepeat(); - delayTimer = q->startTimer(AUTO_REPEAT_DELAY); + delayTimer = q->startTimer(repeatDelay); } void QQuickAbstractButtonPrivate::startPressRepeat() { Q_Q(QQuickAbstractButton); stopPressRepeat(); - repeatTimer = q->startTimer(AUTO_REPEAT_INTERVAL); + repeatTimer = q->startTimer(repeatInterval); } void QQuickAbstractButtonPrivate::stopPressRepeat() @@ -637,6 +639,9 @@ void QQuickAbstractButton::setAutoExclusive(bool exclusive) and \l clicked() signals while the button is pressed and held down. The default value is \c false. + + The initial delay and the repetition interval are defined in milliseconds + by \l autoRepeatDelay and \l autoRepeatInterval. */ bool QQuickAbstractButton::autoRepeat() const { @@ -818,6 +823,56 @@ void QQuickAbstractButton::setAction(QQuickAction *action) emit actionChanged(); } +/*! + \since QtQuick.Controls 2.4 (Qt 5.11) + \qmlproperty int QtQuick.Controls::AbstractButton::autoRepeatDelay + + This property holds the initial delay of auto-repetition in milliseconds. + The default value is \c 300 ms. + + \sa autoRepeat, autoRepeatInterval +*/ +int QQuickAbstractButton::autoRepeatDelay() const +{ + Q_D(const QQuickAbstractButton); + return d->repeatDelay; +} + +void QQuickAbstractButton::setAutoRepeatDelay(int delay) +{ + Q_D(QQuickAbstractButton); + if (d->repeatDelay == delay) + return; + + d->repeatDelay = delay; + emit autoRepeatDelayChanged(); +} + +/*! + \since QtQuick.Controls 2.4 (Qt 5.11) + \qmlproperty int QtQuick.Controls::AbstractButton::autoRepeatInterval + + This property holds the interval of auto-repetition in milliseconds. + The default value is \c 100 ms. + + \sa autoRepeat, autoRepeatDelay +*/ +int QQuickAbstractButton::autoRepeatInterval() const +{ + Q_D(const QQuickAbstractButton); + return d->repeatInterval; +} + +void QQuickAbstractButton::setAutoRepeatInterval(int interval) +{ + Q_D(QQuickAbstractButton); + if (d->repeatInterval == interval) + return; + + d->repeatInterval = interval; + emit autoRepeatIntervalChanged(); +} + #if QT_CONFIG(shortcut) QKeySequence QQuickAbstractButton::shortcut() const { |