From d8be398bd149a69199b001bc3a3e6d6c6dff9b7d Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Fri, 9 Sep 2022 15:17:40 -0600 Subject: [PATCH] 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 --- kcms/nightcolor/package/contents/ui/main.qml | 50 ++++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/kcms/nightcolor/package/contents/ui/main.qml b/kcms/nightcolor/package/contents/ui/main.qml index f1c7c5ba6..79177194e 100644 --- a/kcms/nightcolor/package/contents/ui/main.qml +++ b/kcms/nightcolor/package/contents/ui/main.qml @@ -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 {