Commit 9c51fa02 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

applets/batterymonitor: scroll to item position when item gets focus

parent a62d9808
Pipeline #231152 passed with stage
in 8 minutes and 36 seconds
......@@ -70,6 +70,13 @@ PlasmaExtras.Representation {
// HACK: workaround for https://bugreports.qt.io/browse/QTBUG-83890
PlasmaComponents3.ScrollBar.horizontal.policy: PlasmaComponents3.ScrollBar.AlwaysOff
function scrollToY(yPos) {
if (!PlasmaComponents3.ScrollBar.vertical.visible) {
return;
}
PlasmaComponents3.ScrollBar.vertical.position = Math.min(1, Math.max(0, yPos / batteryList.implicitHeight));
}
Column {
id: batteryList
......@@ -114,6 +121,7 @@ PlasmaExtras.Representation {
stepSize: batterymonitor.maximumScreenBrightness/100
onMoved: batterymonitor.screenBrightness = value
onActiveFocusChanged: if (activeFocus) scrollView.scrollToY(y)
// Manually dragging the slider around breaks the binding
Connections {
......@@ -142,6 +150,7 @@ PlasmaExtras.Representation {
KeyNavigation.tab: KeyNavigation.down
onMoved: batterymonitor.keyboardBrightness = value
onActiveFocusChanged: if (activeFocus) scrollView.scrollToY(y)
// Manually dragging the slider around breaks the binding
Connections {
......@@ -168,6 +177,8 @@ PlasmaExtras.Representation {
degradationReason: dialog.degradationReason
profileHolds: dialog.profileHolds
onActivateProfileRequested: dialog.activateProfileRequested(profile)
onActiveFocusChanged: if (activeFocus) scrollView.scrollToY(y)
}
Repeater {
......@@ -193,6 +204,8 @@ PlasmaExtras.Representation {
event.accepted = false;
}
}
onActiveFocusChanged: if (activeFocus) scrollView.scrollToY(y)
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment