summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qabstractspinbox.cpp
diff options
context:
space:
mode:
authorNathan Collins <nathan.collins@kdab.com>2018-05-18 16:27:43 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-07-12 09:07:32 +0000
commite40f23f098a1e79c22df611b6312317582b95a3a (patch)
tree560661f5d96dc498ea6ce5fc6880c82f878ae38a /src/widgets/widgets/qabstractspinbox.cpp
parent21291d78c528b798252a046db4f17872132259f4 (diff)
Add QStyle::SH_SpinBox_StepModifier style hint
This patch allows the developer to pick which keyboard modifier increases the number of steps a QAbstractSpinBox takes when the user interacts with it. The modifier can be either Qt::ControlModifier (default), Qt::ShiftModifier or Qt::NoModifier. Qt::NoModifier disables the step modifier. Note that on macOS, Control corresponds to the Command key. Holding the modifier increases the step rate when: - scrolling; - pressing the up/down keys; - pressing the spin box up/down buttons. [ChangeLog][QtWidgets][QStyle] QStyle::SH_SpinBox_StepModifier allows the developer to pick which keyboard modifier increases the number of steps a QAbstractSpinBox takes for the following interactions: scrolling, up/down keyboard keys and the spin box buttons. The Qt::ShiftModifier can now be used, or the feature can be disabled using Qt::NoModifier. Previously, only Qt::ControlModifier could be used as the modifier. Change-Id: Ib5518127e86a8f67798a9a1d6e860c6e35896e6f Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/widgets/widgets/qabstractspinbox.cpp')
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 0459eadfff..822d896ee6 100644
--- a/src/widgets/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
@@ -106,6 +106,10 @@ QT_BEGIN_NAMESPACE
the spinbox buttons. Note that on macOS, Control corresponds to the
Command key.
+ Since Qt 5.12, QStyle::SH_SpinBox_StepModifier can be used to select
+ which Qt::KeyboardModifier increases the step rate. Qt::NoModifier
+ disables this feature.
+
QAbstractSpinBox also provide a virtual function stepEnabled() to
determine whether stepping up/down is allowed at any point. This
function returns a bitset of StepEnabled.
@@ -840,6 +844,7 @@ void QAbstractSpinBox::changeEvent(QEvent *event)
style()->styleHint(QStyle::SH_SpinBox_ClickAutoRepeatThreshold, 0, this);
if (d->edit)
d->edit->setFrame(!style()->styleHint(QStyle::SH_SpinBox_ButtonsInsideFrame, nullptr, this));
+ d->stepModifier = static_cast<Qt::KeyboardModifier>(style()->styleHint(QStyle::SH_SpinBox_StepModifier, nullptr, this));
d->reset();
d->updateEditFieldGeometry();
break;