Commit d8be398b authored by Nate Graham's avatar Nate Graham
Browse files

kcms/nightcolor: hide preview message after scroll manipulation

Currently, if you interact with one of the color temperature sliders
by scrolling, the preview message and full-screen color tint are
activated but never deactivated. This is because the deactivation only
happens in an `onPressedChanged` handler, but with a scroll, there is no
change to the `pressed` property's status, so it never fires and hence
the message and overlay never disappear.

This commit fixes that by using a timer to hide them that only triggers
when a slider is manipulated using a scroll.

BUG: 458675
FIXED-IN: 5.26
parent 5e852a06
Pipeline #230018 passed with stage
in 8 minutes and 44 seconds
......@@ -43,6 +43,16 @@ KCM.SimpleKCM {
root.locator.destroy();
}
function startPreview(value) {
previewMessage.state = "visible"
cA.preview(value)
}
function stopPreview() {
previewMessage.state = "invisible"
cA.stopPreview()
}
Connections {
target: kcm.nightColorSettings
function onActiveChanged() {
......@@ -70,6 +80,12 @@ KCM.SimpleKCM {
}
}
Timer {
id: previewMessageTimer
interval: Kirigami.Durations.humanMoment
onTriggered: stopPreview()
}
ColumnLayout {
spacing: 0
......@@ -186,14 +202,21 @@ KCM.SimpleKCM {
onMoved: {
kcm.nightColorSettings.dayTemperature = value
previewMessage.state = "visible"
previewMessage.text = i18n("This is what day color temperature will look like when active.")
cA.preview(value)
root.startPreview(value)
// This can fire for scroll events; in this case we need
// to use a timer to make the preview message disappear, since
// we can't make it disappear in the onPressedChanged handler
// since there is no press
if (!pressed) {
previewMessageTimer.restart()
}
}
onPressedChanged: {
previewMessage.state = "invisible"
cA.stopPreview()
if (!pressed) {
root.stopPreview()
}
}
KCM.SettingStateBinding {
......@@ -239,14 +262,21 @@ KCM.SimpleKCM {
onMoved: {
kcm.nightColorSettings.nightTemperature = value
previewMessage.state = "visible"
previewMessage.text = i18n("This is what night color temperature will look like when active.")
cA.preview(value)
root.startPreview(value)
// This can fire for scroll events; in this case we need
// to use a timer to make the preview message disappear, since
// we can't make it disappear in the onPressedChanged handler
// since there is no press
if (!pressed) {
previewMessageTimer.restart()
}
}
onPressedChanged: {
previewMessage.state = "invisible"
cA.stopPreview()
if (!pressed) {
root.stopPreview()
}
}
KCM.SettingStateBinding {
......
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