From 32fd79a20fb9b99913bba1537067f5dc8dd96a38 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 30 Nov 2018 16:53:12 +0100 Subject: QAbstractSlider: fix invertedControls having no effect for left/right keys There was a comment in the code that said: // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. It's not clear what that was referring to, but in its current state, a slider with invertedControls set to true will not behave as expected: pressing the left arrow key will decrease its value instead of increasing it, and vice versa for the right arrow key. As stated in the documentation (and by its name), invertedAppearance only controls the appearance of the slider, and not the effect of key events. Remove the comment and use invertedControls instead. Change-Id: I13296cbda9244413978ef0d7f0856065f74fd0bf Fixes: QTBUG-25988 Reviewed-by: Richard Moe Gustavsen --- src/widgets/widgets/qabstractslider.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/widgets/widgets/qabstractslider.cpp') diff --git a/src/widgets/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp index 99ee1eccb7..2172ebc99c 100644 --- a/src/widgets/widgets/qabstractslider.cpp +++ b/src/widgets/widgets/qabstractslider.cpp @@ -829,7 +829,6 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) break; #endif - // It seems we need to use invertedAppearance for Left and right, otherwise, things look weird. case Qt::Key_Left: #ifdef QT_KEYPAD_NAVIGATION // In QApplication::KeypadNavigationDirectional, we want to change the slider @@ -848,9 +847,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) else #endif if (isRightToLeft()) - action = d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; + action = d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; else - action = !d->invertedAppearance ? SliderSingleStepSub : SliderSingleStepAdd; + action = !d->invertedControls ? SliderSingleStepSub : SliderSingleStepAdd; break; case Qt::Key_Right: #ifdef QT_KEYPAD_NAVIGATION @@ -868,9 +867,9 @@ void QAbstractSlider::keyPressEvent(QKeyEvent *ev) else #endif if (isRightToLeft()) - action = d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; + action = d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; else - action = !d->invertedAppearance ? SliderSingleStepAdd : SliderSingleStepSub; + action = !d->invertedControls ? SliderSingleStepAdd : SliderSingleStepSub; break; case Qt::Key_Up: #ifdef QT_KEYPAD_NAVIGATION -- cgit v1.2.3