From 8a3162b431c8b45fbb0233f3fe4f76b28ec70ad2 Mon Sep 17 00:00:00 2001 From: Daker Fernandes Pinheiro Date: Fri, 15 Jul 2011 10:03:17 -0300 Subject: [PATCH] Fix Plasma ScrollBar flickableItem position binding when mouse or keys are used The RangeModel value was being incremented directly by the mouse and keys events, and it was overriding the binding with the flickableItem position. Once the ScrollBar button was clicked, the direct manipulation of the flickable component was not updating the scroll position. The new function 'incrementValue' now does the correct work. Signed-off-by: Daker Fernandes Pinheiro --- .../plasmacomponents/ScrollBar.qml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/declarativeimports/plasmacomponents/ScrollBar.qml b/declarativeimports/plasmacomponents/ScrollBar.qml index a2635540c..0f29fc9d5 100644 --- a/declarativeimports/plasmacomponents/ScrollBar.qml +++ b/declarativeimports/plasmacomponents/ScrollBar.qml @@ -41,21 +41,30 @@ Item { property bool _showButtons: stepSize != 0 property bool _inverted: _isVertical ? !scrollbar.inverted : scrollbar.inverted - property alias _value: range.value implicitWidth: _isVertical ? 22 : 200 implicitHeight: _isVertical ? 200 : 22 visible: flickableItem && handle.width < contents.width + function incrementValue(increment) { + if (!flickableItem) + return; + + if (_isVertical) + flickableItem.contentY += increment; + else + flickableItem.contentX += increment; + } + Keys.onUpPressed: { if (!_isVertical) return; if (_inverted) - range.value -= stepSize; + incrementValue(-stepSize); else - range.value += stepSize; + incrementValue(stepSize); } Keys.onDownPressed: { @@ -63,9 +72,9 @@ Item { return; if (_inverted) - range.value += stepSize; + incrementValue(stepSize); else - range.value -= stepSize; + incrementValue(-stepSize); } Keys.onLeftPressed: { @@ -73,9 +82,9 @@ Item { return; if (_inverted) - range.value += stepSize; + incrementValue(stepSize); else - range.value -= stepSize; + incrementValue(-stepSize); } Keys.onRightPressed: { @@ -83,9 +92,9 @@ Item { return; if (_inverted) - range.value -= stepSize; + incrementValue(-stepSize); else - range.value += stepSize; + incrementValue(stepSize); } @@ -133,9 +142,9 @@ Item { onTriggered: { scrollbar.forceActiveFocus(); if (_inverted) - _value += stepSize; + incrementValue(stepSize); else - _value -= stepSize; + incrementValue(-stepSize); } } } @@ -173,9 +182,9 @@ Item { onTriggered: { scrollbar.forceActiveFocus(); if (_inverted) - _value -= stepSize + incrementValue(-stepSize); else - _value += stepSize; + incrementValue(stepSize); } } } @@ -220,7 +229,6 @@ Item { } position: handle.x onPositionChanged: { handle.x = position; } - } PlasmaCore.FrameSvgItem {