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 <dakerfp@gmail.com>
This commit is contained in:
parent
cba7e6204a
commit
8a3162b431
@ -41,21 +41,30 @@ Item {
|
|||||||
property bool _showButtons: stepSize != 0
|
property bool _showButtons: stepSize != 0
|
||||||
property bool _inverted: _isVertical ?
|
property bool _inverted: _isVertical ?
|
||||||
!scrollbar.inverted : scrollbar.inverted
|
!scrollbar.inverted : scrollbar.inverted
|
||||||
property alias _value: range.value
|
|
||||||
|
|
||||||
implicitWidth: _isVertical ? 22 : 200
|
implicitWidth: _isVertical ? 22 : 200
|
||||||
implicitHeight: _isVertical ? 200 : 22
|
implicitHeight: _isVertical ? 200 : 22
|
||||||
|
|
||||||
visible: flickableItem && handle.width < contents.width
|
visible: flickableItem && handle.width < contents.width
|
||||||
|
|
||||||
|
function incrementValue(increment) {
|
||||||
|
if (!flickableItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_isVertical)
|
||||||
|
flickableItem.contentY += increment;
|
||||||
|
else
|
||||||
|
flickableItem.contentX += increment;
|
||||||
|
}
|
||||||
|
|
||||||
Keys.onUpPressed: {
|
Keys.onUpPressed: {
|
||||||
if (!_isVertical)
|
if (!_isVertical)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
range.value -= stepSize;
|
incrementValue(-stepSize);
|
||||||
else
|
else
|
||||||
range.value += stepSize;
|
incrementValue(stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onDownPressed: {
|
Keys.onDownPressed: {
|
||||||
@ -63,9 +72,9 @@ Item {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
range.value += stepSize;
|
incrementValue(stepSize);
|
||||||
else
|
else
|
||||||
range.value -= stepSize;
|
incrementValue(-stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onLeftPressed: {
|
Keys.onLeftPressed: {
|
||||||
@ -73,9 +82,9 @@ Item {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
range.value += stepSize;
|
incrementValue(stepSize);
|
||||||
else
|
else
|
||||||
range.value -= stepSize;
|
incrementValue(-stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Keys.onRightPressed: {
|
Keys.onRightPressed: {
|
||||||
@ -83,9 +92,9 @@ Item {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
range.value -= stepSize;
|
incrementValue(-stepSize);
|
||||||
else
|
else
|
||||||
range.value += stepSize;
|
incrementValue(stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -133,9 +142,9 @@ Item {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
scrollbar.forceActiveFocus();
|
scrollbar.forceActiveFocus();
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
_value += stepSize;
|
incrementValue(stepSize);
|
||||||
else
|
else
|
||||||
_value -= stepSize;
|
incrementValue(-stepSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,9 +182,9 @@ Item {
|
|||||||
onTriggered: {
|
onTriggered: {
|
||||||
scrollbar.forceActiveFocus();
|
scrollbar.forceActiveFocus();
|
||||||
if (_inverted)
|
if (_inverted)
|
||||||
_value -= stepSize
|
incrementValue(-stepSize);
|
||||||
else
|
else
|
||||||
_value += stepSize;
|
incrementValue(stepSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +229,6 @@ Item {
|
|||||||
}
|
}
|
||||||
position: handle.x
|
position: handle.x
|
||||||
onPositionChanged: { handle.x = position; }
|
onPositionChanged: { handle.x = position; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlasmaCore.FrameSvgItem {
|
PlasmaCore.FrameSvgItem {
|
||||||
|
Loading…
Reference in New Issue
Block a user