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
wilder-5.26
Nate Graham 4 years ago
parent 5e852a068d
commit d8be398bd1
  1. 50
      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 {

Loading…
Cancel
Save